server example with modules
See original GitHub issueI 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
| +-- types
| | +-- index.js (grouped types)
| | +-- auth.graphql (imports from prisma api)
| | +-- post.graphql (imports from prisma api)
| +-- resolvers
| | +-- index.js (grouped resolvers)
| | +-- auth.js
| | +-- post.js
| + index.js (server)
src/index.js (server)
const resolvers = require('./resolvers')
const typeDefs = require('./types')
const server = new GraphQLServer({
typeDefs,
resolvers,
...
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Server module example | Drupal.org
Here is a commented example of a server module which uses hook_server() to become a server.
Read more >Building a server module — Group-Office documentation
The package is a group of modules that belong to each other. It is used to group modules per type or per customer....
Read more >Mapping modules to servers - IBM
You can map modules of an application or stand-alone Web module to one or more target servers during or after application installation using...
Read more >How To Create a Web Server in Node.js with the HTTP Module
First, we'll create an HTML file that the web server will return. Create a new HTML file: touch index.
Read more >Developing modules for the Apache HTTP Server 2.4
sum, the server will let all modules know, that this request should be served by "example-handler ". As you will see later, when...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@beebase why do you need to import post.graphql? Merging the schema will take care of this into a single schema declaration for the
GraphQLServer
command behind the scenes ingraphql-yoga
.Based on your comments above it sounds like you have two directories with
.graphql
files? One with user defined schema, and a second with prisma defined schema.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.
merge-graphql-schemas
creates a concatenated type definition that contains all the references. This concatenated (merged) type definition can then be passed to theGraphQLServer
call. The code below has worked for me, give it a shot.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.
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.