POST
a "query" to an HTTP endpoint,
instead of hitting different HTTP
endpoints for different resources.
user
and address
separately.
ctrl + enter
or cmd + enter
(mac) or click on the ▶️ icon to
run the GraphQL query
GET
calls, you would have used a query
parameter. For example, to fetch only 10
todos you might have made this API call: GET /api/todos?limit=10
.
limit: 10
. GraphQL servers will provide a list
of arguments that can be used in ()
next to specific fields. In our case, we
are using Hasura for creating the
GraphQL backend which provides filter,
sort and pagination arguments. The
GraphQL server or API that you use,
might provide a different set of
arguments that can be used.
Fetch users (with limit 1), and their todos (ordered by descending creation time, and limited to 5).
'POST'
, 'PUT'
, 'PATCH'
, 'DELETE'
APIs.
Protip: Now let's say we don't know what the name of the mutation to create a todo. GraphiQL to the rescue! Head to GraphiQL and on the right, click on the "docs" tab. Type "todo" there and you'll see a list of GraphQL queries and types that use todo. Read through their descriptions and you'll soon find thatinsert_todos
is what you need.
insert_todos
.
insert_todos
mutation. But the "fields" of
the mutation specify the shape of the response
that you want from the server.