June 2025
Intermediate to advanced
837 pages
24h 50m
English
To obtain read access to the GraphQL interface, you must first extend the schema. You need a new data type called movie that maps the structure of a record. Then, you must define a movie field that you can query. Listing 11.5 shows the new version of the schema.
import { buildSchema } from 'graphql';import expressGraphql from 'express-graphql'; const schema = buildSchema(` type Movie { id: Int! title: String! year: Int public: Int user: Int } type Query { greet: String movie: [Movie] }`); const rootValue = {...}; export default expressGraphql.graphqlHTTP({...}
Listing 11.5 Extending the Schema with the "Movie" Type
As you’ve already seen, GraphQL has its own type system, which is quite similar to ...
Read now
Unlock full access