Questions tagged [graphql]

GraphQL is an API technology designed to describe the complex, nested data dependencies of modern web applications. It is often considered an alternative to SOAP or REST

Filter by
Sorted by
Tagged with
355 votes
6 answers

How to query all the GraphQL type fields without writing a long query?

Assume you have a GraphQL type and it includes many fields. How to query all the fields without writing down a long query that includes the names of all the fields? For example, If I have these ...
BlackSigma's user avatar
  • 3,555
269 votes
9 answers

When and How to use GraphQL with microservice architecture

I'm trying to understand where GraphQL is most suitable to use within a microservice architecture. There is some debate about having only 1 GraphQL schema that works as API Gateway proxying the ...
Fabrizio Fenoglio's user avatar
253 votes
12 answers

Nodemon Error: "System limit for number of file watchers reached"

I'm learning GraphQL and am using prisma-binding for GraphQL operations. I'm facing this nodemon error while I'm starting my Node.js server and its giving me the path of schema file which is auto ...
Rehan Sattar's user avatar
  • 3,547
204 votes
4 answers

How to properly make mock throw an error in Jest?

I'm testing my GraphQL api using Jest. I'm using a separate test suit for each query/mutation I have 2 tests (each one in a separate test suit) where I mock one function (namely, Meteor's callMethod)...
Le garcon's user avatar
  • 7,217
179 votes
6 answers

What is the difference between Falcor and GraphQL?

GraphQL consists of a type system, query language and execution semantics, static validation, and type introspection, each outlined below. To guide you through each of these components, we've ...
Gajus's user avatar
  • 69.2k
177 votes
4 answers

What's the point of input type in GraphQL?

Could you please explain why if input argument of mutation is object it should be input type? I think much simpler just reuse type without providing id. For example: type Sample { id: String ...
Dmitrii Dushkin's user avatar
177 votes
3 answers

In GraphQL what's the meaning of "edges" and "node"?

I am consuming a GraphQL endpoint and I get results that contain edges and node tags. I am supplying a clean JSON structure for my query, so this doesn't make sense to me. It seems as if the GraphQL ...
Ska's user avatar
  • 6,658
141 votes
3 answers

What is an exclamation point in GraphQL?

In a schema file that I have I noticed there are exclamation marks after some types, like # Information on an account relationship type AccountEdge { cursor: String! node: Account! } What do ...
JuanCaicedo's user avatar
  • 3,152
127 votes
6 answers

Are there any disadvantages to GraphQL? [closed]

All the articles about GraphQL will tell you how wonderful it is, but are there any disadvantages or shortcomings to it? Thank you.
Dr.Nemo's user avatar
  • 1,461
123 votes
14 answers

Get GraphQL whole schema query

I want to get the schema from the server. I can get all entities with the types but I'm unable to get the properties. Getting all types: query { __schema { queryType { fields { ...
Aleksandrenko's user avatar
96 votes
10 answers

GraphQL Expected Iterable, but did not find one for field xxx.yyy

I'm currently trying GraphQL with NodeJS and I don't know, why this error occurs with the following query: { library{ name, user { name email } } } I am not sure if the ...
Vetterjack's user avatar
  • 2,257
96 votes
6 answers

Can graphql return aggregate counts?

Graphql is great and I've started using it in my app. I have a page that displays summary information and I need graphql to return aggregate counts? Can this be done?
orbital's user avatar
  • 953
94 votes
5 answers

Is it possible to not return any data when using a GraphQL mutation?

I have several GraphQL queries and mutations, now I'm trying to implement a delete mutation without returning any data: type Mutation{ addElement(element: ElementData): ID ...
angrykoala's user avatar
  • 3,804
92 votes
1 answer

what's the difference between parseValue and parseLiteral in GraphQLScalarType

Looking through the GraphQL documentation for custom scalar types (I'm trying to create my own date type) I'm not sure what the difference between parseValue and parseLiteral are.
MonkeyBonkey's user avatar
  • 46.5k
90 votes
14 answers

How to send graphql query by postman?

I use POST type URL http://######/graphql Body: query: "query: "{'noteTypes': {'name', 'label', 'labelColor', 'groupName', 'groupLabel', 'imageUrl'}}" But it return "message": "Must provide ...
ZPPP's user avatar
  • 1,566
88 votes
2 answers

Shouldn't the login be a Query in GraphQL?

In the tutorial on GraphQL authentication, the login is a Mutation: type Mutation { post(url: String!, description: String!): Link! signup(email: String!, password: String!, name: String!): ...
Anna B's user avatar
  • 5,997
86 votes
3 answers

How do I add a description to a field in "GraphQL schema language"

I have a graphql schema, a fragment of which looks like this: type User { username: String! password: String! } In graphiql, there is a description field, but it always says "self-...
derekdreery's user avatar
  • 3,870
86 votes
16 answers

GraphQL gql Syntax Error: Expected Name, found }

I'm attempting to set up Apollo GraphQL support in a new React project, but when I try to compile a query using gql I keep receiving the error: Syntax Error: Expected Name, found } This is generated ...
Nathan's user avatar
  • 1,927
82 votes
5 answers

Firebase & GraphQL [closed]

Does anyone have any experience with GraphQL and Firebase? I figure one would place the firebase calls in the resolver of the relevant field, passing some variable from the props of the component into ...
omgj's user avatar
  • 1,369
78 votes
1 answer

Field \"me\" of type \"User\" must have a selection of subfields

Hi I am trying to learn GraphQL language. I have below snippet of code. // Welcome to Launchpad! // Log in to edit and save pads, run queries in GraphiQL on the right. // Click "Download" above to ...
N Sharma's user avatar
  • 33.5k
78 votes
8 answers

Document a GraphQL API

With REST we can use Swagger, RAML or other technologies to document our API and generate an HTML documentation that our consumers can read without any need of interaction with the servers. Does ...
Francisco Canela's user avatar
78 votes
4 answers

Can a GraphQL input type inherit from another type or interface?

Is it possible to use inheritance with GraphQL input types? Something like that (this, of course, doesn't work with input types): interface UserInputInterface { firstName: String lastName: ...
kyrisu's user avatar
  • 4,551
77 votes
2 answers

What is the point of naming queries and mutations in GraphQL?

Pardon the naive question, but I've looked all over for the answer and all I've found is either vague or makes no sense to me. Take this example from the GraphQL spec: query getZuckProfile($...
Nolan's user avatar
  • 2,219
76 votes
2 answers

Apollo GraphQL React - how to query on click?

In the Apollo React docs there are examples of fetching automatically when the component is shown, but I'd like to run a query when a button is ...
atkayla's user avatar
  • 8,163
75 votes
9 answers

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
  • 1,990
75 votes
5 answers

GraphQL Error field type must be Input Type but got:

Here is the mutation: const createNotebook = mutationWithClientMutationId ({ name: 'CreateNotebook', inputFields: { token: { type: GraphQLString, }, ...
lee huang's user avatar
  • 1,209
75 votes
2 answers

How to add default values to input arguments in graphql

I have this input type and I would like to add a default Value to one of the fields. I want to add 0 to the value field inside the ExampleInput. type ExampleType { value: Int another: String } ...
Adolfo's user avatar
  • 1,335
74 votes
3 answers

Handling errors with react-apollo useMutation hook

I have been trying to get my head around this problem but haven't found a strong answer to it. I am trying to execute a login mutation using the useMutation hook. TLDR; I want to know what exactly is ...
d_bhatnagar's user avatar
  • 1,429
74 votes
2 answers

OData vs GraphQL [closed]

Is there a good comparison of GraphQL & OData in terms of performance, developers usability, community, etc.. All articles that I find in the Internet are very bias. What would be the best way to ...
Yar0myr's user avatar
  • 757
73 votes
4 answers

How do you extend types in GraphQL?

For example, a Pet is an Animal with an owner and name. type Animal { species: String } type Pet extends Animal { owner: Owner name: String }
atkayla's user avatar
  • 8,163
67 votes
1 answer

GraphQL: Non-nullable array/list

I'm learning GraphQL now and while walking through tutorial I met behavior that I can't understand. Let's say we have defined type in schema: type Link { id: ID! url: String! description: ...
DefLee's user avatar
  • 685
66 votes
2 answers

What do 3 dots/periods/ellipsis in a relay/graphql query mean?

The relay docs contain this fragment: query RebelsRefetchQuery { node(id: "RmFjdGlvbjox") { id ... on Faction { name } } } What does this ... on Faction on syntax mean?
jbrown's user avatar
  • 7,558
64 votes
5 answers

How do you prevent nested attack on GraphQL/Apollo server?

How do you prevent a nested attack against an Apollo server with a query such as: { authors { firstName posts { title author { firstName posts{ title ...
jboothe's user avatar
  • 1,053
63 votes
3 answers

How to query list of objects with array as an argument in GraphQL

I'm trying to query a list of objects having array of IDs. Something similar to following SQL query: SELECT name FROM events WHERE id IN(1,2,3,...); How do I achieve this in GraphQL?
Rafael Sedrakyan's user avatar
62 votes
2 answers

GraphQLError: Syntax Error: Expected Name, found <EOF>

I got the above error on a graphql query, I am using apollo-react by the way and using the Query component for rendering the data this is my code const GET_VEHICLE_CHECKS = gql` query getVehicleChecks(...
Malik Bagwala's user avatar
62 votes
4 answers

Can you make a graphql type both an input and output type?

I have some object types that I'd like to use as both input and output - for instance a currency type or a reservation type. How do I define my schema to have a type that supports both input and ...
MonkeyBonkey's user avatar
  • 46.5k
61 votes
15 answers

UnhandledPromiseRejectionWarning: Error: You must `await server.start()` before calling `server.applyMiddleware()` at ApolloServer

I am trying to start my nestJs server and It keeps giving me this error: UnhandledPromiseRejectionWarning: Error: You must await server.start() before calling server.applyMiddleware() at ApolloServer ...
Boladek's user avatar
  • 611
61 votes
3 answers

N+1 queries in AWS AppSync

When using AWS AppSync with lambda data sources you can encounter N+1 query problem. Basically when you have individual field resolver on your type and your query returns an array of those types you ...
AlpacaGoesCrazy's user avatar
60 votes
2 answers

Date and Json in type definition for graphql

Is it possible to have a define a field as Date or JSON in my graphql schema ? type Individual { id: Int name: String birthDate: Date token: JSON } actually the server is returning ...
Mohamed Taboubi's user avatar
59 votes
6 answers

Error: Network error: Error writing result to store for query (Apollo Client)

I am using Apollo Client to make an application to query my server using Graphql. I have a python server on which I execute my graphql queries which fetches data from the database and then returns it ...
return007's user avatar
  • 823
58 votes
7 answers

The difference between Mutation and Query

I'm reading GraphQL Docs about Query and Mutation. However, there is a lack of real examples which shows the difference and most importantly — when is it appropriate to use them. Many thanks for the ...
Malakai's user avatar
  • 3,021
57 votes
7 answers

Cleaning Unwanted Fields From GraphQL Responses

I have an object that my GraphQL client requests. It's a reasonably simple object: type Element { content: [ElementContent] elementId: String name: String notes: String type: ...
ilrein's user avatar
  • 3,833
56 votes
8 answers

Graphql post body "Must provide query string."

I use Express-graphql middleware. I send the following request in the body line: POST /graphql HTTP/1.1 Host: local:8083 Content-Type: application/graphql Cache-Control: no-cache Postman-Token: ...
Gopard's user avatar
  • 922
56 votes
1 answer

In Relay, what role do the node interface and the global ID spec play?

I started out with the relay-starter-kit and also worked my way through the Relay and GraphQL documentation. But there are quite a few areas that are unexplained and mysterious. Seriously I read a ...
Christine's user avatar
  • 3,014
56 votes
9 answers

Why I got error: Cannot query field xx on type "Query"?

Although I copied and pasted the graphQL query from the GraphiQL tool after I tested it at GraphiQL successfully , the query returned with an error when I tried it in Apollo client within a reactJS ...
simo's user avatar
  • 23.4k
55 votes
3 answers

What is Over-Fetching or Under-fetching?

I've been playing sometimes with graphQL. Before graphQL, we normally use REST API. Many developers said that graphQL fixes some problems of the REST. (e.g. over-fetching & under-fetching). I ...
Saber Alex's user avatar
  • 1,564
55 votes
1 answer

When should I use a Relay GraphQL connection and when a plain list?

In Relay GraphQL, connections and lists are both array-like, but they have different features. When should I use each?
Greg Hurrell's user avatar
  • 5,217
54 votes
6 answers

GraphQL dynamic query building

I have a GraphQL server which is able to serve timeseries data for a specified source (for example, sensor data). An example query to fetch the data for a sensor might be: query fetchData { ...
Matt Wilson's user avatar
  • 8,169
53 votes
6 answers

GraphQL Blackbox / "Any" type?

Is it possible to specify that a field in GraphQL should be a blackbox, similar to how Flow has an "any" type? I have a field in my schema that should be able to accept any arbitrary value, which ...
Jon Cursi's user avatar
  • 3,301
53 votes
8 answers

How to connect GraphQL and PostgreSQL

GraphQL has mutations, Postgres has INSERT; GraphQL has queries, Postgres has SELECT's; etc., etc.. I haven't found an example showing how you could use both in a project, for example passing all the ...
Ska's user avatar
  • 6,658

2 3 4 5