Webpack loader for graphql-import
yarn add --dev graphql-import-loader
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' }]
}
]
}
}
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)