Organizing the Backend Project
Explore how to organize your GraphQL backend project for clearer code management by separating schema, resolvers, and configuration files. Learn to configure your server, run with nodemon, and set up a local GraphQL playground for testing your API.
We'll cover the following...
We'll cover the following...
Organizing the server
To make our project more organized, we’ll split our code into the following files:
-
resolvers.js: A file fort our resolvers. -
schema.graphql: The GraphQL schema for our project. -
schema.js: A file that contains code to read the GraphQL schema. -
nodemon.json: The configuration for thenodemontool.
This is how the files are structured on the disk:
First, we need to move our schema to a separate file. For now, it contains a single appName query.
Now we need to read it.
...