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
9
votes
5 answers

Is there a way to get rid of [Object: null prototype] in GraphQL

I'm trying to make one-to-many relationship database with Mongoose and GraphQL. Whenever I insert the data to GraphQL mutation argument, I will get [Object: null prototype] error. I notice the object will have [Object: null prototype] in front of it…
FIrman
  • 131
  • 1
  • 2
  • 8
9
votes
2 answers

ApolloServer.applyMiddleware({ express }) getting UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'use of undefined

const { ApolloServer, gql } = require('apollo-server-express') const express = require("express"); const next = require("next"); const dev = process.env.NODE_ENV === "development"; const app = next({ dev }); const handle =…
9
votes
1 answer

Tracking online user with GraphQL Apollo

I need to handle events "user is now online" and "user is now offline" on GraphQL Apollo Node.js server. What's the best way to do it? My investigation: I pretty sure that I don't need to implement any heartbeat logic, because subscriptions are…
Andrew Gura
  • 382
  • 2
  • 11
8
votes
4 answers

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

After updating the apollo-server to version 3 the following error is shown in the console C:\projects\my_project\node_modules\apollo-server-core\src\ApolloServer.ts:554 throw new Error( ^ Error: You must `await server.start()`…
Roman Mahotskyi
  • 4,576
  • 5
  • 35
  • 68
8
votes
0 answers

req.cookies from apollo-server-micro return empty object

I couldn't get req.cookies, even req.headers as it return empty object and undefined. I tried 'request.credentials' value with include and same-origin, both not working. I can get req.cookies from getServerSideProps but I don't want do this on every…
Alan Yong
  • 993
  • 2
  • 12
  • 25
8
votes
0 answers

React re-render causing Apollo useQuery to be called twice

I have a simple React component that uses Apollo's useQuery to fetch data. The problem is, because the component is being rendered twice, it is calling useQuery twice, which is then calling the Apollo resolver twice, which is then calling the…
Ben
  • 5,085
  • 9
  • 39
  • 58
8
votes
1 answer

Is it possible to define the HTTP headers for the GraphQL Playground that comes with Apollo Server?

I want to define some http headers for the GraphQL Playground, to be enabled by default and/or always. Essentially, I want to add: "apollographql-client-name": "playground" "apollographql-client-version": "yada-yada" to be able to distinguish…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
8
votes
1 answer

Argument of type 'ApolloServer' is not assignable to parameter of type 'ApolloServerBase'

I write integration tests using apollo-server-testing package follow this official docs. But when I pass the instance of the ApolloServer class to createTestClient method, tsc throw a type incompatible error. Argument of type 'ApolloServer' is not…
Lin Du
  • 88,126
  • 95
  • 281
  • 483
8
votes
1 answer

graphql server side validation

I just want to get a gauge of what people think is the best practice for doing validation of user input fileds (such as url or email address) on the server with a graphql / orm setup. My application is using apollo server / gql and sequelize as the…
jspru
  • 1,060
  • 1
  • 9
  • 17
8
votes
1 answer

Is it possible to have partially federated gateway?

I'd like to federate services, but let the federation gateway also hold own schema and logic that would proxy REST API endpoints for simplicity. Now it looks like I need to have federation gateway service, federated graphql service(s) and the…
Ville
  • 464
  • 4
  • 14
8
votes
2 answers

Alias types in GraphQL Schema Definition Language

I have the following graphql schema definition in production today: type BasketPrice { amount: Int! currency: String! } type BasketItem { id: ID! price: BasketPrice! } type Basket { id: ID! items: [BasketItem!]! total:…
Richard Scarrott
  • 6,638
  • 1
  • 35
  • 46
8
votes
0 answers

Are there any advantages to using Apollo Server's dataSources config option?

Following the Apollo Server docs on dataSources, one would assume that the best way to access data in a GraphQL resolver would be through the dataSources option on the server config. However, the app I'm working on has requirements that result in…
dukeluke
  • 646
  • 7
  • 22
8
votes
1 answer

What's the best way to call another resolver in Apollo Server?

Say you wanted to call the createdAt resolver from the updatedAt resolver. For example this doesn't work: { Review: { createdAt: review => review._id.getTimestamp(), updatedAt: review => review.updatedAt || this.createdAt(review) }, } I…
Loren
  • 13,903
  • 8
  • 48
  • 79
8
votes
3 answers

How to remove authentication for introspection query in Graphql

so may be this is very basic question so please bear with me. Let me explain what I am doing and what I really need. EXPLANATION I have created a graphql server by using ApolloGraphql (apollo-server-express npm module). Here is the code snippet to…
Ankur Verma
  • 5,793
  • 12
  • 57
  • 93
8
votes
1 answer

handling GraphQL field arguments using Dataloader?

I'm wondering if there's any consensus out there with regard to how best to handle GraphQL field arguments when using Dataloader. The batchFn batch function that Dataloader needs expects to receive Array and returns an Array, and…
diekunstderfuge
  • 521
  • 1
  • 7
  • 15