1.0.4 • Published 5 years ago

structure-graphql v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

structure-graphql

Tool for structuring the GraphQL project.

Usage

  1. Define the convenient structure. For instance:
src/
  |- graphql/
      |- author/
      |   |- resolver.ts
      |   |- schema.graphql
      |
      |- book/
          |- resolver.ts
          |- schema.graphql
  1. Import all schemas and resolvers from the following folder.
const { typeDefs, resolvers } = getTypesAndResolvers({
  folder: 'src/graphql'
})
  1. Use them for the schema.
import { makeExecutableSchema } from 'graphql-tools'

const schema = makeExecutableSchema({ typeDefs, resolvers })

Notes

  • Schema extensions: .graphql, .gql
  • Resolver extensions: .js, .ts
  • Resolver filenames: resolver (default).
    • This is a custom option that can be set in the resolversFilename field. Also can be a glob (e.g. *resolver).