Skip to content

prisma-labs/graphql-import-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphql-import-loader

CircleCI npm version

Webpack loader for graphql-import

Install

yarn add --dev graphql-import-loader

Usage

Resolve GraphQL file import statements as a string. See the tests for more details

# import { A } from 'src/schema/a.graphql'
# import { B } from 'src/schema/b.graphql'
# import { C, D } from 'src/schema/cd.graphql'

type Complex  {
  id: ID!
  a: A!
  b: B!
  c: C!
  d: D!
}
import typeDefs from './schema.graphql'
// webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        exclude: /node_modules/,
        test: /\.graphql$/,
        use: [{ loader: 'graphql-import-loader' }]
      }
    ]
  }
}

Examples

Simple Server:

import { GraphQLServer } from 'graphql-yoga'
import resolvers from './resolvers'
import typeDefs from './schema.graphql'

const server = new GraphQLServer({ typeDefs, resolvers })
server.start(() => console.log('Server running on :4000'))

Advanced:

serverless-prisma: Serverless starter kit using Prisma (early-stages)