Questions tagged [graphql-js]

The JavaScript reference implementation for GraphQL, a query language created by Facebook for describing data requirements on complex application data models.

1291 questions
9
votes
1 answer

GraphQL nested query definition

I'm trying to create tree-like structure for my queries, to get rid off queries like peopleList, peopleSingle, peopleEdit, peopleAdd, peopleDelete companyList, companySingle, companyEdit, companyAdd, companyDelete etc. In the end I would like to…
CorwinCZ
  • 402
  • 1
  • 3
  • 12
9
votes
3 answers

GraphQL: Accessing another resolver/field output from a sibling resolver

need some help. Let say Im requesting the following data: { parent { obj1 { value1 } obj2 { value2 } } } And I need the result of value2 in value1 resolver for calculation. Thought of returning a promise in…
alonp99
  • 143
  • 1
  • 8
9
votes
0 answers

How to generate GraphQL Types from Entity Framework Models

Is there a tool to generate GraphQL types from the models of Entity Framework?
Kabeer
  • 3,922
  • 6
  • 35
  • 61
9
votes
1 answer

How to pass request body into GraphQL Context?

I'm currently attempting to get the request body into context, because part of the body contains a JWT that needs to be decoded. However when I try the following I get undefined for context: app.use('/', graphqlHTTP((req) => ({ schema:…
kennet postigo
  • 495
  • 1
  • 5
  • 16
9
votes
3 answers

How to pass total count to the client in pageInfo

I use first after and last before to do pagination. hasNextPage and hasPreviousPage are very useful. But what I need is also the total count so that I can calculate and show things like page 5 of 343 pages on the client. Unfortunately that is not…
Christine
  • 2,998
  • 1
  • 18
  • 33
8
votes
1 answer

Uncaught TypeError: Cannot read property 'data' of undefined with Gatsby and graphQl

I'm testing Gatsby and GraphQl for the first time and I'm trying on a simple example.... I have this error when I want to display the title via a GraphQl request in my layout? : Uncaught TypeError: Cannot read property 'site' of undefined here is…
E.D
  • 309
  • 4
  • 17
8
votes
6 answers

Unexpected while using graphql

Getting EOF error every time at same line, changed code many times and even degraded to previous versions of graphql but no positive results. My code is: const graphql = require('graphql') const _ = require('lodash') const { …
Ansh Gujral
  • 171
  • 1
  • 1
  • 11
8
votes
1 answer

Apollo GraphQL client: how to distinguish an optimistic response from a real response into a watchQuery

The question is about the interaction of a mutation, optimistic response, and a watchQuery. I have a mutation "myMutation" which has an "optimisticResponse" and an implemented "update" function. Every time I do a mutation query the "update" function…
Dolios
  • 163
  • 6
8
votes
1 answer

Call GraphQL endpoints using Cypress .request

I have googled cypress request with graphql but I see lots of people mentioning mock up server, stub and so on. But I am not able to find a ful example of how to use GraphQL with cy.request.
Tsuna
  • 1,728
  • 3
  • 19
  • 35
8
votes
2 answers

Implementing pagination in vanilla GraphQL

Every tutorial I have found thus far has achieved pagination in GraphQL via Apollo, Relay, or some other magic framework. I was hoping to find answers in similar asked questions here but they don't exist. I understand how to setup the queries but…
NetOperator Wibby
  • 1,178
  • 5
  • 21
  • 40
8
votes
1 answer

How and when to generate an ID for graphql?

I am connecting graphql with an SQLite database. In sql, ids are integers but in graphql ids are strings. After searching, based on this question - When to use GraphQLID instead of GraphQLInt? Stated are three suggestions: Start using UUIDs for…
Ezekiel Chow
  • 81
  • 1
  • 2
8
votes
1 answer

How to create generics with the schema language?

Using facebook's reference library, I found a way to hack generic types like this: type PagedResource = (pagedQuery: PagedQuery) => PagedResponse ​ interface PagedQuery { query: Query; take: number; skip:…
Daniel Birowsky Popeski
  • 6,624
  • 7
  • 40
  • 96
8
votes
2 answers

Remove unnecessary fields before mutation in GraphQL

I've got a type called Article in my schema: type Article { id: ID! updated: DateTime headline: String subline: String } For updates to it, there's a corresponding input type that is used by a updateArticle(id: ID!, article: ArticleInput!)…
amann
  • 3,899
  • 2
  • 27
  • 40
8
votes
2 answers

Handling Mongoose Populated Fields in GraphQL

How do I represent a field that could be either a simple ObjectId string or a populated Object Entity? I have a Mongoose Schema that represents a 'Device type' as follows // assetSchema.js import * as mongoose from 'mongoose' const Schema =…
viztastic
  • 1,473
  • 1
  • 12
  • 16
8
votes
1 answer

GraphQL: Filtering, sorting and paging on nested entities from separate data sources?

I'm attempting to use graphql to tie together a number of rest endpoints, and I'm stuck on how to filter, sort and page the resulting data. Specifically, I need to filter and/or sort by nested values. I cannot do the filtering on the rest…
onthegojohn
  • 166
  • 1
  • 4