Questions tagged [express-graphql]

GraphQL HTTP Server Middleware

Create a GraphQL HTTP server with any HTTP web framework that supports connect styled middleware, including Connect itself, Express and Restify.

310 questions
6
votes
1 answer

How to use GraphQLError for customize messaging?

I am trying to do customize messaging with GraphQLError. There are few use cases that I want to handle with GraphQL Error: when username and password did not match, I want to return customize the message that username and password did not…
Piyush Bansal
  • 1,219
  • 1
  • 12
  • 34
6
votes
1 answer

How to unit test express-graphql mutations?

I have an Express-GraphQL API with a query and a mutation which works in GraphiQL, unit tests of query works, but a unit test of mutation returns a 405 error. my GraphQL schema is as follows: type Subject { type: String } type Category { name:…
Josh Reuben
  • 279
  • 1
  • 7
5
votes
3 answers

My Apollo Server's Subscription doesn't works: Cannot read property 'headers' of undefined

I tried to used it with the context connection, and adding the subscription params into the Apollo Server but it doesn't work. Is my first time using Apollo Server Subscriptions and i don't know if the error is in the server configuration or in the…
5
votes
1 answer

Explanation for different implementations of resolver function in graphql

I've been reading through the graphQL docs and found that they've explained the implementation of the graphql server in 2 ways: one using graphql-yoga which is a fully featured graphql server and another one is using graphql, express-graphql and…
5
votes
1 answer

Add schema directive for all the queries in GraphQL

Is there a way to add a schema directive by overriding one of the methods of SchemaDirectiveVisitor for all the queries and mutations? For example to check the authentication token in a directive. Would be nice to add it just once not for every…
cosmarc
  • 511
  • 3
  • 18
5
votes
2 answers

Intercept Apollo/graphql requests

we are using Apollo/Graphql in our application, and we are facing an issue. The application is developed in Angular 5, and NodeJS as backend with graphql server that will respond to the front end. To intercept Http request in angular, we implement…
5
votes
1 answer

GraphQL Mutation Body Parser

Just updated to 'graphql-server-express' version 1.3.0 and now I am getting this error when running any mutations: POST body missing. Did you forget use body-parser middleware? When initializing the server, I am including the "body-parser" package…
matt
  • 63
  • 1
  • 4
4
votes
2 answers

Why graphQLErrors are always empty in react components?

I want to show some errors that comes from graphql server to user. Have some component with callback that use some mutation onSave() => { this.props.mutate({ mutation: CHANGE_ORDER_MUTATION, variables: { ids, …
comalex3
  • 2,040
  • 1
  • 21
  • 36
4
votes
1 answer

How to throw multiple errors with express-graphql?

In an express-graphql app, I have a userLogin resolver like so: const userLogin = async ({ id, password }), context, info) => { if (!id) { throw new Error('No id provided.') } if (!password) { throw new Error('No password…
François Romain
  • 10,389
  • 15
  • 77
  • 112
4
votes
0 answers

Mount middleware after graphqlHTTP.Middleware

I have a question about express-graphql. I’m trying to get a middleware run after the GraphQL resolver. These were my first two attempts: app.use('/api', graphqlHTTP({ schema: graphqlSchema }) ); app.use((req, res, next) => { …
zagen
  • 41
  • 1
  • 4
4
votes
1 answer

GraphQL descriptive success messages in mutations

Currently in GraphQL JS implementation there is no standard way of returning a descriptive success message from mutation, such as "User created successfully", etc. My question has 2 parts: My thinking is that it is beneficial to return a success…
andr111
  • 2,864
  • 10
  • 32
  • 42
3
votes
0 answers

Why my GraphQL subscriptions are working on local server but not when deployed on live server

I am building a GraphQL server and have subscriptions in it. Once I deploy the server on my local machine and check the subscription in Playground it works, i.e. it listens to events and I get the newly added data. It means the subscriptions…
Fateh
  • 89
  • 5
3
votes
1 answer

GraphQLObjectType for subscriptions

I implemented a GraphQL server using Express, and I have an issue with the setup of GraphQL Subscription type. I'm developing a real time chat app and I'm trying to publish an event after a new message is created, but I don't understand how should I…
3
votes
0 answers

Error with Auth0 and Graphql - TypeError: Cannot read property 'publicKey' of undefined

I am currently trying to setup authentication for Graphql via Auth0. The issue we are facing is inside our authenticate Mutation returning the error \validateAndParseIdToken.js:25 jwt.verify(idToken, key.publicKey, { …
tsbi11
  • 43
  • 4
3
votes
3 answers

Apollo Graphql Import Issue with cacheControl directive

I am using "graphql-import": "^0.7.1" I tried to add @cacheControl directive to my graphql schema type Post @cacheControl(maxAge: 240) { id: Int! title: String author: Author votes: Int @cacheControl(maxAge: 30) readByCurrentUser:…
WitVault
  • 19,604
  • 18
  • 88
  • 116
1
2
3
20 21