Questions tagged [apollo-server]

Apollo Server is a GraphQL server for Express, Connect, Hapi and Koa, written in TypeScript

Apollo Server is a community-maintained open-source server.

It works with all Node.js HTTP server frameworks: Express, Connect, Hapi and Koa.

Useful links:

2126 questions
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-descriptive". How do I add descriptions to the schema?
derekdreery
  • 3,860
  • 4
  • 29
  • 38
52
votes
1 answer

Why am I getting a "Cannot return null for non-nullable field" error when doing a mutation?

I'm trying my hand at (Apollo) GraphQL on the server side and have been having a probably silly issue. I'm trying to sign up a user, but keep getting the error shown in the linked image below. What is the problem? Ignore the very simple auth flow,…
Collins Orlando
  • 1,521
  • 4
  • 18
  • 25
47
votes
3 answers

Apollo/GraphQL field type for object with dynamic keys

Let's say my graphql server wants to fetch the following data as JSON where person3 and person5 are some id's: "persons": { "person3": { "id": "person3", "name": "Mike" }, "person5": { "id": "person5", "name": "Lisa" …
Andru
  • 5,954
  • 3
  • 39
  • 56
36
votes
6 answers

Why does a GraphQL query return null?

I have an graphql/apollo-server/graphql-yoga endpoint. This endpoint exposes data returned from a database (or a REST endpoint or some other service). I know my data source is returning the correct data -- if I log the result of the call to the data…
Daniel Rearden
  • 80,636
  • 11
  • 185
  • 183
35
votes
5 answers

How to load a .graphql file using `apollo-server`?

I am currently loading the GraphQL schema using a separate .graphql file, but it is encapsulated within strings: schema.graphql const schema = ` type CourseType { _id: String! name: String! } type Query { courseType(_id: String):…
Sam Sverko
  • 1,480
  • 4
  • 15
  • 32
35
votes
6 answers

How do I handle deletes in react-apollo

I have a mutation like mutation deleteRecord($id: ID) { deleteRecord(id: $id) { id } } and in another location I have a list of elements. Is there something better I could return from the server, and how should I update the list? More…
derekdreery
  • 3,860
  • 4
  • 29
  • 38
31
votes
3 answers

What is the difference between apollo server and express-graphql

I would like to build an application and its recommended to use GraphQl for API, I am not sure which platform to select and what are the differences. apollo server vs express-graphql I need to use TypeScript for the project too. Any good Idea…
MJ X
  • 8,506
  • 12
  • 74
  • 99
31
votes
2 answers

Stitching secure subscriptions using makeRemoteExecutableSchema

We have implemented schema stitching where GraphQL server fetches schema from two remote servers and stitches them together. Everything was working fine when we were only working with Query and Mutations, but now we have a use-case where we even…
28
votes
4 answers

How to parse GraphQL request string into an object

I am running Apollo lambda server for GraphQL. I want to intercept the GraphQL query/mutation from the POST request body and parse it so I can find out which query/mutation the request is asking for. The environment is Node.js. The request isn't…
Nick Ramsbottom
  • 583
  • 1
  • 6
  • 17
25
votes
5 answers

apollo-server-express CORS issue

So I am migrating to apollo-server-express 2.3.3 ( I was using 1.3.6 ) I've followed several guides, making the necessary tweaks but am stuck in a CORS issue. According to the docs you have to use the applyMiddleware function to wire up the apollo…
José Del Valle
  • 691
  • 1
  • 13
  • 27
25
votes
3 answers

How to create a nested resolver in apollo graphql server

Given the following apollo server graphql schema I wanted to break these down into separate modules so I don't want the author query under the root Query schema.. and want it separated. So i added another layer called authorQueries before adding it…
elbarto
  • 253
  • 1
  • 3
  • 7
24
votes
2 answers

"Abstract type X must resolve to an Object type at runtime for field Query.user with value

this my code schema gql` type Query { user: X! } type User { name: String! } type Time { age: Int! } union X = User | Time `; resolvers { X: { __resolveType: obj => { if (obj.name) return { name: "Amasia" }; …
Edgar
  • 6,022
  • 8
  • 33
  • 66
23
votes
2 answers

What should be the GraphQL mutation return type when there is no data to return?

I have an Apollo GraphQL server and I have a mutation that deletes a record. This mutation receives the UUID of the resource, calls a REST (Ruby on Rails) API and that API just returns an HTTP code of success and an empty body (204 No Content) when…
Mario
  • 1,213
  • 2
  • 12
  • 37
21
votes
9 answers

createReadStream() throwing RangeError: Maximum call stack size exceeded when uploading file

I am trying to use Apollo Server's Upload scalar to send files to S3 directly. My schema: const { gql } = require('apollo-server-express') module.exports = gql` extend type Mutation { createPicture( name: String! picture: Upload! ):…
W. Reyna
  • 724
  • 2
  • 7
  • 24
20
votes
2 answers

How can I correctly type the context object in Apollo Server?

I'm using apollo server with typescript and I'm having trouble getting the context parameter inside of my resolver to pick up that the name property on context is a string. Right now it's typed as any and I'd like it to be typed as string. I also…
Dennis Martinez
  • 6,344
  • 11
  • 50
  • 67
1
2 3
99 100