GraphQL offers a query language for your API and a runtime for executing those queries with your existing data. If you're setting foot into this fascinating world, this MCQ guide will test and strengthen your basic understanding. Let's jump right in!
1. What is GraphQL?
Answer:
Explanation:
GraphQL is a query language designed for APIs, not a database or a web framework.
2. Which HTTP method does GraphQL typically use?
Answer:
Explanation:
GraphQL typically uses POST method to send both queries and mutations.
3. In GraphQL, what is a "mutation"?
Answer:
Explanation:
In GraphQL, "mutations" are used to change or modify data.
4. Which of the following best describes a GraphQL resolver?
Answer:
Explanation:
Resolvers in GraphQL determine how to fetch the data for a particular field.
5. How do you specify the shape of your return data in a GraphQL query?
Answer:
Explanation:
In GraphQL, curly braces {} are used to specify the shape of the returned data.
6. Which of the following is a core feature of GraphQL?
Answer:
Explanation:
One of the core features of GraphQL is that it lets clients specify exactly what data they need.
7. Which GraphQL concept describes a set of rules to create consistent, type-safe, and easily evolvable API schemas?
Answer:
Explanation:
The GraphQL Type System defines the set of rules required for creating consistent and type-safe schemas.
8. What does a ! in a GraphQL schema signify?
Answer:
Explanation:
In a GraphQL schema, a ! indicates that the field is non-nullable.
9. Which of the following is NOT true about GraphQL?
Answer:
Explanation:
GraphQL is not tied to any specific frontend framework like React. It can be used with any frontend or backend technology.
10. In GraphQL, which keyword is used to group multiple operations in one request?
Answer:
Explanation:
"Batch" is the term commonly used in the GraphQL ecosystem to describe grouping multiple operations into one request.
11. Which type of operation in GraphQL is used to maintain a real-time connection with the server?
Answer:
Explanation:
Subscriptions in GraphQL allow for real-time functionality by maintaining a persistent connection with the server.
12. Which tool is often used to experiment with GraphQL queries in a visual interface?
Answer:
Explanation:
Both GraphiQL and GraphQL Playground are popular tools that provide a visual interface to experiment with GraphQL queries.
13. What role does the @deprecated directive play in GraphQL?
Answer:
Explanation:
In GraphQL, the @deprecated directive is used to indicate that a field is no longer recommended for use and may be removed in the future.
14. What is the primary advantage of using GraphQL fragments?
Answer:
Explanation:
Fragments in GraphQL allow users to construct sets of fields, and then include them in queries where you need to.
15. How do you pass dynamic values in a GraphQL query?
Answer:
Explanation:
In GraphQL, you pass dynamic values into a query using arguments.
16. What does a GraphQL Schema define?
Answer:
Explanation:
A GraphQL schema defines the capabilities of the API by specifying the data types and operations available.
17. Which of the following is NOT a part of a GraphQL server's responsibilities?
Answer:
Explanation:
While a GraphQL server does handle the request and invokes resolvers, it doesn't specifically manage database connections. That would typically be handled by other parts of the backend or database drivers.
18. How can you fetch data from multiple sources in a single GraphQL query?
Answer:
Explanation:
GraphQL allows for a single query to fetch data from multiple sources. This is accomplished through resolvers, which can fetch data from various sources, such as databases, REST APIs, third-party services, etc.
19. What would be a primary reason to use GraphQL over a traditional REST API?
Answer:
Explanation:
One of the significant benefits of GraphQL over traditional REST is that it allows clients to specify exactly the data they need, preventing over-fetching or under-fetching of data.
20. Is GraphQL frontend or backend specific?
Answer:
Explanation:
GraphQL is neither frontend nor backend specific. It provides a layer that sits in between, serving as an interface for frontend to fetch and manipulate data from backend systems.
Comments
Post a Comment