GraphQL 面试题与答案
相关差异对比
问题 16. What is the role of directives in GraphQL?
Directives in GraphQL are used to modify the behavior of a field or an entire query. They provide a way to conditionally include or skip fields, apply transformations, and control the execution of a query.
问题 17. How does GraphQL handle versioning of APIs?
GraphQL avoids versioning by allowing clients to specify the exact shape of the response they need. This flexibility prevents breaking changes, as clients can evolve independently without relying on specific API versions.
问题 18. What is the purpose of the `context` object in GraphQL resolvers?
The `context` object in GraphQL resolvers is used to share contextual information, such as authentication details or database connections, among different parts of the application. It is often passed as an argument to resolvers.
问题 19. Explain the concept of batching in GraphQL.
Batching in GraphQL involves combining multiple queries or mutations into a single request to the server. This helps in reducing the number of network requests and improving the overall efficiency of data fetching.
问题 20. What is a schema in GraphQL?
A schema in GraphQL defines the types of data that can be queried and the relationships between them. It serves as a contract between the client and the server, specifying the structure of the API.
用户评价最有帮助的内容: