-
Notifications
You must be signed in to change notification settings - Fork 575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server example with modules #136
Comments
Refer apollographql/apollo-server#43 Hope it helps you |
I still don't see a decent solution for modularization with .graphql files.
I tried https://github.com/okgrow/merge-graphql-schemas to merge the module files (auth, post) |
@beebase Did you ever find a solution for modularization with graphql-yoga? |
@beebase why do you need to import post.graphql? Merging the schema will take care of this into a single schema declaration for the Based on your comments above it sounds like you have two directories with // ... other code
const typesArray = [...fileLoader(path.join(__dirname, './userDefinedSchemaFolder'), ...fileLoader(path.join(__dirname, './prismaSchemaFolder')]
const typeDefs = mergeTypes(typesArray, { all: true })
const resolvers = ...
const server = new GraphQLServer({
typeDefs,
resolvers
}) If I am misunderstanding you and there truly is only one folder of schema definitions, then my initial statement will work. You do not need to import schema definitions into files that references that schema. const { fileLoader, mergeTypes, mergeResolvers } = require('merge-graphql-schemas')
const typesArray = fileLoader(path.join(__dirname, './types')
const typeDefs = mergeTypes(typesArray, { all: true })
const resolversArray = fileLoader(path.join(__dirname, './resolvers')
const resolvers = mergeResolvers(resolversArray)
const server = new GraphQLServer({
typeDefs,
resolvers
}) Let me know if that works, or you have question. I don't use prisma so I am not familiar with the api or directory structure. |
I have not been able to get |
@jboothe @kissmygritts I paused my graphql project since my post end January. I was hitting a wall trying to modularise prisma. Tried different approaches but none of them worked for me. Couldn't find any example code either. |
Yeah, if I knew how to solve it I would gladly submit a PR example project. I find it hard to believe someone has not solved this. |
I was trying to use achieve this with
https://github.com/okgrow/merge-graphql-schemas
but I'm not sure if that's the right direction. There seem to be many ways to structure graphql servers.
Would be nice if one of the yoga server examples would show how to set up a modularised structure in front of the prisma API
src/index.js (server)
The text was updated successfully, but these errors were encountered: