Does this work with express-graphql or replace it?
See original GitHub issueThanks @enisdenjo for this awesome package!
A question, does this work with express-graphql or replace it?
Before I had something like
import { graphqlHTTP } from 'express-graphql';
const graphQLMiddleware = graphqlHTTP({
context: {
dataLoaders: {
user: userDataLoader,
},
},
schema,
});
However, when I write code like this, it does not supports context:
import { createServer } from 'graphql-transport-ws';
createServer(
{
context: { // <- not support here
dataLoaders: {
user: userDataLoader,
},
},
schema,
},
{
server,
path: '/graphql',
}
);
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
expressGraphQL is not a function - Stack Overflow
Please replace your expressGraphQL with graphqlHTTP as it was destructured. Use: const { graphqlHTTP } = require('express-graphql');.
Read more >Running an Express GraphQL Server
The simplest way to run a GraphQL API server is to use Express, a popular web application framework for Node.js. You will need...
Read more >ExpressJS vs GraphQL | What are the differences? - StackShare
Express is a minimal and flexible node.js web application framework, ... whereas "Schemas defined by the requests made by the user", "Will replace...
Read more >Creating A GraphQL Server With Node.js And Express - Medium
GraphQL is a language that enables you to provide a complete and understandable description of the data in your API. Furthermore it gives...
Read more >Create a GraphQL HTTP server with Express. - GitHub
The official GraphQL over HTTP work group is standardizing the way you transport GraphQL over HTTP and it made great progress bringing up...
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 Free
Top 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

Hey @Hongbo-Miao, you’re very welcome!
Thank you for asking this question. In short - yes, this library supports
express-graphqland it should fulfil all your requirements.On the side note,
101 Switching Protocolsis good. This indicates that the HTTP handshake went well and the browser is “switching” to the WebSocket Protocol.Back to your problem - we don’t support specifying the context during the server creation (#13); however, you can still inject it in the
executeand/orsubscribeoperations. Also, you can indeed perform all 3 operations through WebSocket.Here is how:
Thanks @enisdenjo for the explaining!
Oh now I get it, with
graphql-transport-ws, it can provide query and mutation onwsorwssprotocal. And thanks for thecontextmethod!I succeed on the demo using Schema Definition Language with
buildSchema, but my case actually failed on using GraphQLSchema object way, since it is different topic, I will ask in another ticket. Posted at https://github.com/enisdenjo/graphql-transport-ws/issues/15