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

GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.

There are GraphQL implementations in almost every server-side language, and powerful clients for most UI platforms.

20808 questions
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: String! postedBy: User votes: [Vote!]! } Due to…
DefLee
  • 685
  • 1
  • 5
  • 6
65
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
  • 7,518
  • 16
  • 69
  • 117
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 author { firstName …
jboothe
  • 1,043
  • 1
  • 11
  • 15
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
  • 2,541
  • 10
  • 34
  • 42
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 output - I don't want to duplicate code if I don't…
MonkeyBonkey
  • 46,433
  • 78
  • 254
  • 460
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 I'm not even sure where to debug from as I am…
Boladek
  • 611
  • 1
  • 4
  • 4
61
votes
2 answers

GraphQLError: Syntax Error: Expected Name, found

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($uuid: String!) { tripDetails(uuid: $uuid){ …
Malik Bagwala
  • 2,695
  • 7
  • 23
  • 38
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 field resolver lambda will be called N times. AWS…
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 me an error saying : Type "Date" not found in…
Mohamed Taboubi
  • 6,663
  • 11
  • 55
  • 87
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 back to the client. I have created a custom…
return007
  • 823
  • 1
  • 7
  • 19
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 explanations.
Malakai
  • 3,011
  • 9
  • 35
  • 49
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: String createdAt: String updatedAt: String …
ilrein
  • 3,833
  • 4
  • 31
  • 48
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: d71a7ea9-5502-d5fe-2e36-0ae49c635a29 { testing { …
Gopard
  • 922
  • 1
  • 12
  • 26
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 lot of documentations everywhere about all these…
Christine
  • 3,014
  • 2
  • 24
  • 34
55
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 app: [GraphQL error]: Message: Cannot query field…
simo
  • 23,342
  • 38
  • 121
  • 218