The schema lives in src/Presentation/GraphQL: queries in Queries, mutations in Mutations, object types in Types and the errors mutations return in Errors. The endpoint is /graphql, which also serves Nitro to a browser, and /graphql?sdl returns the schema as SDL. In a solution created with --include-auth, every query and mutation, version included, needs a token (see Secure the API).
Ids are the UUID scalar. Field and type descriptions come from the XML comments on the code, so Nitro shows the same text as this page.
query matches anywhere in the title, the full name or, on reviews, the review text, ignoring case, and can be up to 100 characters. movieId and authorId filter the reviews to one movie, one author, or both, and minStars, from 1 to 5, keeps only reviews with at least that many stars.
The mutations follow Hot Chocolate’s mutation conventions: one input in, one payload out. Each payload has the result and an errors list, which is null when it worked and holds a ValidationError or NotFoundError when it didn’t. Ask for __typename and the fields you need on each.
mutation {
createReview(input: { authorId: "01fa8b58-05d2-abd4-e55c-2633222dd0a5", movieId: "cb188ef6-14e7-f85f-2f78-924c2ab26b28", stars: 5, text: "Great film. I cried at the ending." }) {
Every list query returns a Relay-style connection.
Field
Description
nodes
The items on this page
edges
The items with their cursors
pageInfo.hasNextPage
Whether there are more items after this page
pageInfo.endCursor
Pass it as after to get the next page
totalCount
The number of items across every page
Argument
Default
Rules
first
10
1 to 50. Asking for more fails with the HC0051 error
after
none
A cursor from a previous page. Leave it out for the first page
Paging only goes forwards. There’s no last or before, and hasPreviousPage and startCursor are there because the connection spec says so, not because they’re useful. To read everything, start without after and keep sending endCursor back until hasNextPage is false.
A mutation that can’t do its job says why in its payload’s errors, and the result field is null. Both error types implement the Error interface, so message is always there.
Type
When
Fields
ValidationError
The input breaks one of the rules above
message, and fields: each field that broke a rule, with its messages
NotFoundError
The input names a movie, author or review that doesn’t exist
message, which says which
{
"data": {
"createReview": {
"review": null,
"errors": [
{
"__typename": "ValidationError",
"message": "One or more validation errors occurred.",
"fields": [{ "field": "Stars", "messages": ["A star rating must be between 1 and 5."] }]
}
]
}
}
}
{
"data": {
"createReview": {
"review": null,
"errors": [{ "__typename": "NotFoundError", "message": "The Movie with the supplied id was not found." }]