Skip to content

How to using multi server with multi schema #204

Answered by enisdenjo
phongjimmy asked this question in Q&A
Discussion options

You must be logged in to vote

Hey there! The useServer function actually means "use this server for graphql". It, on its own, does not spin up any new servers, it just "uses" the one you provide. Meaning, you can have as many servers as you want.

Adapting the example to your use case, what you're trying to achieve would look something like this:
⚠️ Heads up, untested code ahead!

import express from 'express';
import { graphqlHTTP } from 'express-graphql';
import ws from 'ws';
import url from 'url';
import { useServer } from 'graphql-ws/lib/use/ws';

const app = express();

// register admin and user routes as usual
app.use('/admin', graphqlHTTP({ schema: adminSchema }));
app.use('/graphql', graphqlHTTP({ schema: userS…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by enisdenjo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #203 on June 13, 2021 14:06.