wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz sur Apollo GraphQL

Total questions: 38

Worksheet time: 19mins

Name
Class
Date
1.

What is GraphQL?

a)

A query language for REST APIs

b)

A query language for graph-based APIs

c)

A framework for database development

d)

A general-purpose programming language

2.

What is the main difference between REST and GraphQL?

a)

GraphQL allows retrieving multiple resources in a single request

b)

REST allows performing complex queries on databases

c)

GraphQL is faster than REST

d)

REST is only compatible with JavaScript

3.

What does the term "Schema" mean in GraphQL?

a)

A representation of the database

b)

A configuration file for queries

c)

The definition of data types, queries, and mutations

d)

A description of business logic

4.

What are scalar types in GraphQL?

a)

Types that can contain multiple sub-types

b)

Basic types like String, Int, Float, Boolean, and ID

c)

Types that define resolution functions

d)

Types specific to mutations

5.

How do you define a GraphQL schema with Apollo Server in Node.js?

a)

Use graphql-tools to generate a schema based on YAML files.

b)

Define a schema using typeDefs that represent types, queries, and mutations, then associate it with resolvers.

c)

Use JSON files to describe the types.

d)

Define schemas only with simple JavaScript objects.

6.

What is a "resolver" in Apollo Server?

a)

An object containing data

b)

A function that resolves the values of a field in a query

c)

A file that defines the structure of the schema

d)

A means of filtering data in the database

7.

What is a "resolver" in Apollo Server?

a)

It is a function that resolves user queries in the application.

b)

It is a function that generates schemas for REST APIs.

c)

It is a function that associates a field of a GraphQL type with a data source, often a database or an external service.

d)

It is a function that performs calculations on the data sent by the user.

8.

What are the correct statements about the structure of the resolvers object?

a)

The Query and Mutation types in the schema must have corresponding keys in the resolvers object

b)

The resolvers object can contain a maximum of 10 resolver functions

c)

The names of the resolver functions must match the names of the fields in the schema

d)

The resolver functions can have any name

9.

What is the AST (Abstract Syntax Tree) in GraphQL?

a)

A tree that defines the schema of data types

b)

A tree representation of the structure of a GraphQL query after it has been validated

c)

A tool for generating Apollo server code

d)

A list of data that will be sent to the GraphQL server

10.

What is the purpose of a "query" in GraphQL?

a)

Modify data on the server

b)

Retrieve data from the server

c)

Add data to the database

d)

Manage authentication and permissions

11.

What is the format of the result of a GraphQL query after being transformed into an AST?

a)

An XML file

b)

A JSON tree representing the structure of the query and data

c)

A string with SQL instructions

d)

A binary file

12.

What is the role of the AST during the validation of a GraphQL query?

a)

It checks the syntax of the query to ensure that the fields are correctly defined

b)

It executes the requested mutation

c)

It optimizes the queries for the server

d)

It converts the data to JSON before sending it

13.

What is the structure of the response of a GraphQL request in case of an error?

a)

An HTTP error message

b)

An object data with a null value and an array errors

c)

A redirection to an error page

d)

No response, the error is directly handled by the client

14.

In GraphQL, what does a "mutation" represent?

a)

A data reading operation

b)

A data modification or addition operation

15.

In GraphQL, what does a "mutation" represent?

a)

A data reading operation

b)

A data modification or addition operation

c)

A data deletion operation

d)

An operation to obtain multiple resources in a single request

16.

What is the default behavior of Apollo Server when an error occurs in a mutation?

a)

Apollo Server continues the execution of the mutation and ignores the error

b)

Apollo Server cancels the mutation and returns an error in the response

c)

Apollo Server returns an HTTP 404 error

d)

Apollo Server redirects to an error page

17.

What happens in a GraphQL mutation if an error occurs during the execution of the mutation?

a)

The error is returned in the errors field of the response

b)

The error blocks the transaction and is not returned

c)

The error is logged in a log file but the mutation continues

d)

The mutation is ignored and no data is returned

18.

What is a DataSource in Apollo Server and why is it used?

a)

It is an abstraction for making SQL queries directly

b)

A DataSource is a mechanism for retrieving data from different sources (REST APIs, databases, etc.)

c)

It is a type of mutation for sending data to an external API

d)

A DataSource is a local cache for storing GraphQL responses

19.

How to implement a custom DataSource in Apollo Server?

a)

By using ApolloDataSource as a base class

b)

By calling an external REST service on each request

c)

By creating a datasource.js file that contains a data object

d)

By using a schema file to define resolvers

20.

What is the advantage of using DataSources in Apollo Server for managing external API calls?

a)

They allow centralizing error management logic

b)

They handle caching to avoid making multiple identical requests

c)

They manage the security of API calls

d)

They simplify the creation of GraphQL schemas

21.

What methods are typically present in a RESTDataSource class of Apollo Server?

a)

get(), post(), put(), delete()

b)

fetch(), query(), update(), remove()

c)

query(), mutate(), subscribe()

d)

add(), remove(), update(), fetch()

22.

In the context of GraphQL, a cache for the DataSource can be useful for:

a)

It helps to resolve a query that has been made for the first time much more quickly.

b)

It helps to manage the mixing of different endpoints with different caching policies.

c)

It helps to resolve more quickly the fields of queries that have already been retrieved.

d)

It prevents unnecessary REST API calls for data that is not frequently updated.

23.

What does Apollo Server do when the request is transformed into an AST?

a)

It executes it immediately on the database

b)

It compiles it into JavaScript code

c)

It validates it to ensure it complies with the schema and GraphQL rules

d)

It caches it in the local cache before resolving it

24.

What does the error code GRAPH_VALIDATION_FAILED mean in Apollo Server?

a)

The request is malformed or contains syntax errors

b)

The data returned by the request is not valid

c)

The user is not authorized to execute the request

d)

The server failed to connect to the database

25.

How does Apollo Server handle errors in a GraphQL request?

a)

It only sends HTTP error codes

b)

It captures them and returns them in an errors object in the response

c)

It redirects the user to an error page

d)

It automatically retries the request in case of an error

26.

In Apollo Server, what is the format of the response for a successful mutation?

a)

{ data: { mutationName: result } }

b)

{ mutationName: result }

c)

{ success: true, data: result }

d)

{ status: 'success', data: result }

27.

How does Apollo Server handle query resolution?

a)

It directly executes SQL queries

b)

It resolves the fields of queries using "resolvers"

c)

It sends the queries to an external server

d)

It compiles the queries into JavaScript

28.

How does Apollo Server handle errors during the execution of a mutation?

a)

It returns an object with errors and the modified data

b)

It continues the execution of the mutation despite the error

c)

It cancels all ongoing mutations

d)

It returns only an error message without data

29.

What role does Apollo Client play in a GraphQL application?

a)

Manage the database

b)

Serve GraphQL queries to a server

c)

Manage local state and GraphQL queries from the client

d)

Handle mutations and subscriptions

30.

What does Apollo Client do with errors from a GraphQL request?

a)

It hides them to avoid repeating errors

b)

It sends a notification to the user

c)

It passes them as error objects in the response

d)

It stops the execution of any other request

31.

How does Apollo Client optimize the performance of queries?

a)

It uses real-time queries

b)

It caches responses and uses the cache to avoid repeated queries

c)

It compresses data before sending it to the server

d)

It allows parallel execution of queries

32.

How does Apollo Client manage the caching of query results in React?

a)

Apollo Client never caches the results.

b)

Apollo Client uses an in-memory cache to store the responses of queries and reuse them to avoid making network requests again.

c)

Apollo Client stores all data in the browser's local storage.

d)

Apollo Client only caches the results of mutations.

33.

What are the differences between the useQuery and useMutation hooks?

a)

The useQuery hook returns an array, while the useMutation hook returns an object

b)

The useQuery hook returns an object, while the useMutation hook returns an array

c)

The useQuery hook is used to send queries, while the useMutation hook is used to send mutations

d)

The useQuery hook executes automatically on component render, while the useMutation hook returns a mutate function that must be called to trigger the mutation

34.

What is the purpose of ApolloProvider in a React project?

a)

Provide the instance of Apollo Client to the entire React application

b)

Initialize Apollo Server

c)

Manage mutations

d)

Define the GraphQL schema

35.

What is the role of ApolloProvider in a React application?

a)

ApolloProvider initializes Apollo Server.

b)

ApolloProvider allows the React application to communicate with the Apollo server.

c)

ApolloProvider is used to handle errors in GraphQL queries.

d)

ApolloProvider is used to add mutations to the schema.

36.

What is a "query hook" in Apollo Client and how do you use it in React?

a)

A "query hook" allows you to execute POST type requests in the React component.

b)

A "query hook" allows you to execute GraphQL queries and manage loading, error, and data states.

c)

A "query hook" allows you to synchronize data between multiple React components.

d)

A "query hook" is a way to manage server-side caching.

37.

What is the purpose of Apollo Studio?

a)

Provide an IDE for writing Apollo code

b)

Offer an interface to manage and monitor GraphQL APIs

c)

Automatically create GraphQL schemas

d)

Deploy Node.js applications

38.

What information can you explore in Apollo Graph Studio?

a)

The structure of the GraphQL schema

b)

The history of HTTP requests

c)

The server logs

d)

User statistics