Now that we've defined all our types, queries, and mutations, we need to merge all our GraphQL files to create our GraphQL schema, which is basically one big file containing all our GraphQL definitions.
For this, you need to create a file called /backend/src/graphql/types/index.ts that contains the following code:
import path from 'path'
import { loadFilesSync } from '@graphql-tools/load-files'
import { mergeTypeDefs } from '@graphql-tools/merge'
const typesArray = loadFilesSync(path.join(__dirname, './'), { extensions: ['graphql'] })
export default mergeTypeDefs(typesArray)
We are using @graphql-tools packages to load our GraphQL files and merging them into typesArray using the mergeTypesDefs method.