-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
I tried to implement the code sample for express in order to migrate away from express-graphql. The express-graphql version works and returns a response, but the http-graphql version does not respond.
Code:
import * as express from 'express';
import { graphqlHTTP } from 'express-graphql';
import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql';
import { createHandler } from 'graphql-http/lib/use/express';
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: "Query",
fields: {hello: {type: GraphQLString, resolve: () => "hello"}}
})
});
const app = express();
// express-graphql implementation
app.use('/graphql', graphqlHTTP({ schema: schema }));
// graphql-http express implementation
app.all('/graphql2', createHandler({ schema }));
app.listen(4000);
The I use curl:
curl http://localhost:4000/graphql --data-urlencode "query=query Q { hello }"
{"data":{"hello":"hello"}}
curl http://localhost:4000/graphql2 --data-urlencode "query=query Q { hello }"
Expected Behaviour
A response of {"data":{"hello":"hello"}} for both /graphql and /graphql2.
Actual Behaviour
Only /graphql (the express-graphql implementation) returns any response.
Version: 1.17.1
Node version: 16.14.0
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested