Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
0 answers
109 views

How to add custom HTTP response to graphql createHandler method?

GraphQl returns 200 even in case of error but with errors object in response. I want to set it to 400. Assume I need to integrate it into createHandler? import { createHandler } from "graphql-...
John Glabb's user avatar
  • 1,589
0 votes
1 answer
291 views

How to change Http Status code when getting error from GraphQL?

I want to change http status code when throw error like with "throw new Error("this is my error.")"? I want this because i should return localized error message in frontend. How ...
Tarik Ulker's user avatar
-1 votes
1 answer
98 views

How to enable explorer tab and add authorization prefix in graphiql playground?

How to add (ex. "Authorization" : null ) prefix in graphiql playground How to enable explorer tab to get available query and mutations
dmx's user avatar
  • 83
0 votes
1 answer
359 views

how to interact and fetch data from elasticsearch to graphql APOLLO 4

so here's my code, i'm really stuck my friends, i have no idea how to send data from my database to graphql, even when i try to do a POST request i receive NULL! here's my code divided in 5 files. ...
anfield's user avatar
  • 41
1 vote
3 answers
3k views

graphql-http Missing query

Followed steps by steps just trying to integrate graphql from provided documentation of expressjs, https://github.com/graphql/graphql-http#with-express import express from 'express'; // yarn add ...
Faivsq's user avatar
  • 23
1 vote
0 answers
90 views

Error: RootQueryType fields must be an object with field names as keys or a function which returns such an object

userData is just an array of object with some dummy data something like this { id: 1, first_name: "Deny", last_name: "Scrange", email: "dscrange0@...
Rishikesh singh's user avatar
0 votes
1 answer
35 views

Running method on every call using express-graphql

I'm using express-graqphl and was wondering if there is any concept of running a function before each graphql endpoint is executed? I'd like to have this for things like validating JWTs and other ...
d512's user avatar
  • 34k
2 votes
0 answers
71 views

Accessing GraphiQL over a JWT protected route in ExpressJS

So far I've always had one big painpoint with GraphQL. I'm very well aware that you can specify headerEditorEnabled when you setup express-graphql like this: graphiql: { headerEditorEnabled: true, }, ...
Dac0d3r's user avatar
  • 1,854
0 votes
1 answer
423 views

How to create an array in the GraphQL's argumment as GraphQL Code First Approach

In GraphQL Code First Approach I am trying to pass the same argumment for createUser in createManyUser but I want to pass it as an array to create many users at once. I searched a lot but couldn't ...
Maher Aldous's user avatar
1 vote
0 answers
279 views

buildschema from graphql throws 'TypeError: nodes.flatMap is not a function'

Am using node version 10.24.0. But when I try the example from the official site. const graphql = require('graphql'); const schema = graphql.buildSchema(` type Query { hello: String }`); I ...
Adithya Sama's user avatar
0 votes
1 answer
83 views

Do not work .map() to mapping all data which I get from database in mongoose and express-graphql

I get all data in mongoose using .find() and try to mapping this data in express and express-graphql. So .find() work correctly and return all data but when I try to use .map() for mapping all data ...
Towfiq Amiri's user avatar
0 votes
1 answer
257 views

GraphQL schema formats

I'm learning graphQl and I saw that there are multiple formats to write schemas. There is the "JavaScript" format: const rootQuery = new GraphQLObjectType({ name:"root", ...
shamgar's user avatar
  • 120
0 votes
0 answers
132 views

sequelize not returning a graphql type

I am following multiple tutorials on the internet and most of them use this implementation where the resolver query method returns a promise where its return type is a graphql typescript generated ...
crypto zaur's user avatar
0 votes
1 answer
489 views

Graphql keeps returning null in graphql and express

I'm trying to query data in GraphQL and express. I wrote the schema and the resolvers, but no matter what I do, it keeps returning null. I tried to re-write everything, I tried to use apollo-express, ...
DiamondWolfCode's user avatar
1 vote
1 answer
409 views

express-graphql : context is always undefined

I have a simple implementation of graphQl on my api, but can't seem to get any other arguments than args from the resolvers. The code is pretty simple, so it shouldn't cause any issue : const ...
Fed's user avatar
  • 11
0 votes
2 answers
525 views

GraphQL Explorer not working with Express Sessions

I'm trying to create a login system with GraphQL and Express, but the sessions aren't being saved. Whenever I log in, req.session.userId stays undefined. My code: (async () => { await connect(...
mathletedev's user avatar
0 votes
2 answers
1k views

How can I share data between 2 resolver functions in Express GraphQL?

I have 2 queries, and corresponding functions, but while writing the resolver, I'm not sure how to store the 1st func data, then reuse it in the second one. Note: I do not want to call the function ...
Min Yoongi's user avatar
0 votes
0 answers
78 views

How to group nested data in GraphQL

{ "data": { "books": [ { "name": "Himu", "genre": "novel", "author": { "name&...
soykot2910's user avatar
0 votes
2 answers
4k views

typeDefs must contain only strings, documents, schemas, or functions, got object

I am working on an express apollo server and structured all the graphql types like below: I am using 'graphql-tools/load-files' and 'graphql-tools/merge' for merging all the types. My index.js file ...
Fozle Rabbi Shafi's user avatar
0 votes
0 answers
35 views

If graphQL uses an async concept and has http capability why does it conflict with the REST API design of Node/Express with http?

I've set up a TypeScript/Node/Express API that includes 'http' for REST and 'express-graphql'. After coding the schema, resolvers and types for TypeScript conformity I run with nodemon ts-node and ...
Brian Quinn's user avatar
2 votes
2 answers
2k views

Unable to import SchemaDirectiveVisitor from apollo-server-express

const { SchemaDirectiveVisitor } = require('apollo-server-express'); class ReplaceDirective extends SchemaDirectiveVisitor { visitFieldDefinition(field) { const { replacement } = this.args; ...
Vipul's user avatar
  • 75
-1 votes
1 answer
409 views

GraphQLObjectType is not a constructor

I'm trying to follow a graphql tutorial, even thoughg I followed it and double checked I keep getting the above error and I have no idea why dont you really hate when the bot asks you to type more, ...
Whisky-Toad's user avatar
1 vote
1 answer
779 views

Meaning of "Expected undefined to be a GraphQL type"?

I am setting up my first GraphQL endpoint with graphql and graphql-express. My MongoDB schema has two types: User and Card, where a User can have many Cards. I set up the root types and resolvers ...
QuestionMark's user avatar
0 votes
1 answer
597 views

Graphql query is always returning null

I am trying to get course data using graphql, but server is always returning null as a response This is my code in file server.js : var express=require('express'); const { graphqlHTTP } = require('...
HardRock's user avatar
  • 1,081
4 votes
1 answer
2k views

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 ...
Fateh's user avatar
  • 101
0 votes
0 answers
890 views

Setting cookies on Graphql-yoga server throws a CORS error but it isn't

Edit: It definitely isn't actually CORS. It is like it is just ignoring my attempts to write the tokens into cookies... I am also having trouble getting it to throw an error that I can find useful... ...
Jordan Rhea's user avatar
  • 1,206
1 vote
4 answers
2k views

GraphQL Subscriptions using Express-GraphQL

Can anyone tell me how to implement GraphQL Subscriptions using Express-GraphQL in Node?
dharshini priya's user avatar
4 votes
1 answer
6k views

Cookie not set, even though it is in response headers. Using express-session cookies

Problem: Trying to set the cookie on login using express-session, but think I'm missing something obvious. The response to the login POST request includes Set-Cookie. I've also set the Access-Control-...
gddh's user avatar
  • 91
77 votes
9 answers
40k views

graphqlHTTP is not a function

Here is my simple graphql express app const express = require('express'); const graphqlHTTP = require('express-graphql'); const app = express(); app.use( '/graphql', graphqlHTTP({ ...
Sachin Titus's user avatar
  • 2,329
0 votes
1 answer
517 views

Apollo server 2.0 not working with join-monster-graphql-tools-adapter and oracle

I am building a graphql server on expressjs. Below is the code: const express = require('express'); const app = express(); const {ApolloServer} = require('apollo-server-express'); const server = new ...
abhirham's user avatar
  • 191
0 votes
1 answer
9k views

Cannot query field signup on type Query

Started messing around with GraphQL, but I'm stuck with this error. Not sure if it's a problem in the schema definition or in the query. const express_graphql = require('express-graphql') const { ...
AFMeirelles's user avatar
1 vote
1 answer
216 views

MongoDB, Express + GraphQL server: Updated data model with new fields, but queries do not pick up new fields

I created a GraphQL server in combination with Express + MongoDB. I started with the following data model: const AuthorSchema = new Schema({ name: { type: String, required: true }, age: { type: ...
Tyler Knapp's user avatar
2 votes
1 answer
2k views

Graphql create relations between two queries.Error cannot access before initialization

I have this code: const ProductType = new GraphQLObjectType({ name: 'Product', fields: { id: { type: GraphQLID }, name: { type: GraphQLString }, category: { ...
Dory Miller's user avatar
0 votes
1 answer
206 views

express-graphql - how can I pass res object to a custom function in context?

In my config, I have the following: - expressGraphQL((req, res) => ({ ..., context: { req, res, database, }, })) I would like to be able to pass res to a custom function in the context, like so: -...
U4EA's user avatar
  • 912
0 votes
0 answers
302 views

How to send success response message using express-graphql?

im new to graphql and using express-graphql for my server. I have question on mutation part, how we can send sucsess message if some operation (lika changing password) is succeeded, here is my ...
principiorum's user avatar
1 vote
1 answer
3k views

Deployed my app on heroku but got error: Failed to load resource: net::ERR_CONNECTION_REFUSED

My app's front-end is Reactjs and backend is Node js. I used express server and graphql-express server. I deployed my app successfully. But it starts with data is loading and then nothing shows. But ...
Krisna's user avatar
  • 3,403
2 votes
0 answers
729 views

{"errors":[{"message":"Must provide query string."}]}

I want to upload image on by using graphql-upload package This is my scheme file const { GraphQLSchema, GraphQLObjectType, GraphQLBoolean } = require("graphql"); const { GraphQLUpload } = require("...
Krisna's user avatar
  • 3,403
0 votes
0 answers
47 views

Requesting for a list of post in graphQL gives error in Node js

I'm watching a tutorial and coding exactly as the instructor. I get this error at a point in the lesson. I get this error in my browser : The below code is not mine, credits goes to maximilian ...
SPS's user avatar
  • 933
1 vote
1 answer
364 views

Send GraphQLUpload to imagekit.io from node server running express-graphql

Inexperienced dev here. This issue is driving me crazy. I am sending an image file from a react front end via a graphQL mutation to a node server running express-graphql. The uploadFile mutation ...
Will's user avatar
  • 11
1 vote
0 answers
180 views

How to connect a multi page web app to graphql?

I have a backend graphql server in express, node. I have a react Single Page Application(SPA) admin web app that communicates to graphql via Apollo. I need a a Multi Page Application (MPA) Content ...
Kucl Stha's user avatar
  • 585
1 vote
2 answers
2k views

Attach a property in context(request in express.js) object

I'm new to GraphQL, and I'm now trying to make an API server with express-graphql. What I want to do is add new property in context object for resolvers, which can be done when I initialize the ...
cadenzah's user avatar
  • 978
0 votes
0 answers
401 views

Must provide query string in graphql

I am doing sample programs with node, graphql i done basic code to return some events my code is const express = require('express'); const bodyParser = require('body-parser'); const graphqlHttp = ...
SaranViji's user avatar
  • 403
4 votes
1 answer
1k views

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(...
tsbi11's user avatar
  • 53
2 votes
2 answers
1k views

Making update request using graphql

I am trying to make crud application using graphql. But I am not sure about update request. I tried, but it's not working. Here see my code. Create post and query posts are working fine. I am using ...
aditya kumar's user avatar
  • 3,005
11 votes
0 answers
537 views

How to have cache to express-graphql?

In my nodejs application I use graphql with express-graphql. I can't see any cache option that library provide. How should I do the cache for graphql requests? (I need to support get and post)
Jon Sud's user avatar
  • 11.6k
0 votes
1 answer
2k views

zeit-now v2 + apollo-server-express: playground error: Server cannot be reached

Currently I am trying to get an api for my nextjs project to work. For deployment I am using zeit's NOW v2 (locally via "now dev"). Everything works fine except the graphql-server. In playground and ...
Kian's user avatar
  • 735
0 votes
1 answer
546 views

Express GraphQL TTFB is extremely long

I have a very simple setup. Express-GraphQL API with MongoDB database. MongoDB responses are in general quite fast but when I would like to return from GrapQL API, TTFB is taking too long especially ...
btutal's user avatar
  • 135
3 votes
0 answers
1k views

How to use GraphQL subscriptions with Postgraphile?

I am very new to GraphQL, so maybe I am just missing something here. i am currently creating an GraphQL endpoint of a Postgres SQL Database using the PostGraphile I am able to perform queries, but i ...
CESCO's user avatar
  • 7,718
2 votes
1 answer
630 views

Cast to number failed for value - GraphQL

I'm new to graphQL. I'm trying to play with graphiql and I'm trying to perform a where Where I want to retrive the authors with age greater than 30. resolver.js Query: { authorGratherThan: ...
Patricio Vargas's user avatar
0 votes
3 answers
2k views

How to set a server name or host name globally and use it in any file?

I am working in graphql using node js. I want to get the hostname of a server and use it in anywhere of file. here is my code: app.use('/api',graphqlHTTP((req,res)=>({ context:{ ...
Upasana's user avatar
  • 45