Files
main.tsmain
What you'll learn
- Explain what GraphQL changes from REST: one endpoint, a typed schema, and the client choosing the fields it gets
- Configure GraphQLModule with the Apollo driver, the schema generated in memory from code, GraphiQL and introspection, and know why production turns the last two off
- Describe an object type with @ObjectType() and @Field(), and state Int, String and nullability exactly
- Answer queries with a @Resolver's @Query() methods, taking typed arguments with @Args()
Press Run tests to start the app. Its log appears here.Graded endpoints
One endpoint for every query: the client names the fields it wants, and gets exactly those
A different selection of the same query: nickname is null where the service has none
The cat query takes an Int! argument; here it comes from the variables, typed
The query is nullable, so an unknown id is a null answer, not an error
The query is checked against the schema before anything runs, and refused with a 400
Introspection: id and age are Int! (a plain number would be a Float), name and breed String!, and nickname a nullable String
A browser asking the endpoint for a page gets GraphiQL, where the schema can be explored; open the app in a new tab to use it