Instructor: We'll start by installing GraphQL in Apollo Server. Once these are installed, we will import Apollo Server from the Apollo Server package, and then we'll create a new instance of Apollo Server.
The Apollo Server requires two things -- typeDefs which is the GraphQL schema, and resolvers which are functions that return data for each field. We're going to pass these into the Apollo Server constructor.
Our typeDefs are our schema. We'll create a type called Query that has a query for total days that should return an Int. We need to match this in our resolvers with a function called Total Days that Returns an Int, in this case, 100. We also can comment our schema. I can say, Count of Total Days Sche During a Season, and this will appear in the documentation.
Now from here, I'll call .listen on the server to run it. Once the server starts, the URL where the server is running will be passed to this function. The default URL is localhost 4000.
Then I'm going to log that to the console, and I'll handle any errors with .cacheconsole.error. Now I can run the index.js file with Node., and this should run the server on localhost 4000. It'll open up the playground where I can run a query for total days that returns 100.
Our typeDefs string contains the schema. Each of these fields map to a resolver that returns data for that field.