GraphQL as an API Layer — Concept Check
Questions on GraphQL as an API Layer. GraphQL aggregates data from multiple microservices in a single query, reducing over-fetching and under-fetching; ideal for flexible client-driven data requirements.
Questions in this quiz
8 questions on GraphQL as an API Layer — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A client application is experiencing over-fetching of data when using REST APIs. How can GraphQL address this issue?
- ABy providing a fixed data structure for all clients
- BBy caching responses to reduce data retrieval time
- CBy allowing clients to specify exactly what data they need
- DBy reducing the number of API endpoints
2.In a microservices architecture, how does GraphQL help in reducing the number of network calls?
- AGraphQL uses a single endpoint for all data requests
- BGraphQL combines multiple REST calls into a single query
- CGraphQL replaces all microservices with a single service
- DGraphQL caches all data, eliminating the need for network calls
3.A developer notices that fetching customer data for each order results in N HTTP calls. How can Spring for GraphQL's DataLoader solve this problem?
- ABy batching and caching requests within a single execution tick
- BBy caching responses globally across all requests
- CBy using separate threads for each HTTP call
- DBy pre-fetching all possible customer data at startup
4.What is a key benefit of using Apollo Federation in a microservices architecture?
- AIt allows each service to own part of the schema
- BIt requires all services to share a single database
- CIt automatically scales services based on load
- DIt eliminates the need for a centralized API gateway
5.A team is using Spring for GraphQL and wants to map query fields to methods. Which annotation should they use?
- A@QueryMapping
- B@SchemaMapping
- C@FieldMapping
- D@GraphQLQuery
6.A developer mistakenly believes that GraphQL requires multiple endpoints like REST. What is the correct understanding?
- AGraphQL requires one endpoint per service
- BGraphQL uses a single endpoint for all queries
- CGraphQL endpoints are dynamically generated
- DGraphQL uses multiple endpoints for different data types
7.In Spring for GraphQL, where should the schema files be placed for schema-first development?
- AUnder src/main/java/graphql/
- BUnder src/main/resources/graphql/
- CIn the config folder
- DIn the root directory
8.When extending a type in Apollo Federation, which directive is used to indicate fields from other services?
- A@requires
- B@external
- C@key
- D@provides