graphql-import-loader
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

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)

Package Sidebar

Install

npm i graphql-import-loader

Weekly Downloads

684

Version

0.2.1

License

MIT

Unpacked Size

4.24 kB

Total Files

6

Last publish

Collaborators

  • schickling