All Questions
Tagged with express-graphql express
77 questions
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-...
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 ...
-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
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.
...
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 ...
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@...
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 ...
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, },
...
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 ...
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 ...
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 ...
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",
...
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 ...
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, ...
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 ...
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(...
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 ...
0
votes
0
answers
78
views
How to group nested data in GraphQL
{
"data": {
"books": [
{
"name": "Himu",
"genre": "novel",
"author": {
"name&...
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 ...
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 ...
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;
...
-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, ...
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 ...
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('...
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 ...
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... ...
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?
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-...
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({
...
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 ...
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 { ...
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: ...
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: {
...
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: -...
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 ...
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 ...
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("...
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 ...
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 ...
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 ...
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 ...
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 = ...
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(...
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 ...
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)
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 ...
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 ...
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 ...
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: ...
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:{
...