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
12
votes
2 answers

GraphQL endpoint for file download

Is it possible to trigger a file download in a browser from the GraphQL endpoint on an apollo-server-express application? I have the endpoint written in a standard express app.get function (see below) but I would like to make use of the GraphQL…
jasonmerino
  • 3,220
  • 1
  • 21
  • 38
12
votes
1 answer

How to implement auto refresh token in graphql for jwt based authentication?

I am trying to figure out this scenario for my JWT based authentication in Apollo based graphql server (2.0) . Basically after login a user gets accessToken and refreshToken from server. AccessToken gets expired after certain period of time and…
WitVault
  • 23,445
  • 19
  • 103
  • 133
12
votes
2 answers

Context vs RootValue in Apollo GraphQL

In graphQLOptions, what is the difference between context and rootvalue? When should I use one, and when should I use the other? At the moment I'm attaching connectors and other sensitive data to the context, is this safe? Can the user read the…
Mascarpone
  • 2,516
  • 4
  • 25
  • 46
11
votes
1 answer

Graphql apollo server resolvers arguments types

Type script is showing error not mentioning argument type for each arguments: Mutation: { createUser: (parent, args, context, info) =>{ } I can solve by using any type, but what are the correct types? Mutation: { createUser:…
Rafiq
  • 8,987
  • 4
  • 35
  • 35
11
votes
3 answers

Getting NextAuth.js user session in Apollo Server context

My web app is using: NextJS NextAuth.js Apollo Server I have a NextAuth set up in my app, and I am able to log in just fine. The problem is coming from trying to get access to the user's session in the Apollo context. I want to pass my user's…
Nolan P
  • 147
  • 1
  • 4
11
votes
1 answer

$lastName of type String used in position expecting type String

this may code Schema import { gql } from 'apollo-server-express'; export default gql` extend type Mutation { signUp( lastName: String! ): String! } `; Resolvers { Query: {}, Mutation: { signUp: async ( _, {…
Edgar
  • 6,022
  • 8
  • 33
  • 66
11
votes
3 answers

How to handle cookies inside apollo-server-lambda

set cookies inside a lambda serverless with apollo-server-lambda I am migrating from apollo-server to the serverless version. Is there a way I can access the response object or another way to set cookies? context: ({ event, context }) => ({ …
Popa Alex
  • 325
  • 2
  • 8
11
votes
0 answers

ApolloGraphQL: Non web socket subscriptions?

We have an app that implements essentially this guide exactly: https://www.apollographql.com/docs/apollo-server/features/subscriptions/ It's been great. We've had great success and the app has been doing great. What we have started running into…
sauce
  • 592
  • 4
  • 9
  • 25
11
votes
1 answer

How to use 'Decimal' as a field type in GraphQL schema?

I want to use Decimal as a type for latitude & longitude field in my GraphGL schema. But GraphQL provides only Float and Int. Is there is any package to solve this?
Debotos Das
  • 519
  • 1
  • 6
  • 17
11
votes
2 answers

Apollo Server Slow Performance when resolving large data

When resolving large data I notice a very slow performance, from the moment of returning the result from my resolver to the client. I assume apollo-server iterates over my result and checks the types... either way, the operation takes too long. In…
sergelerner
  • 499
  • 1
  • 4
  • 15
11
votes
1 answer

Apollo Server - GraphQL Error: There can be only one type named "Query"

I am new to GraphQL. I am following several guides on Internet in order to "create" a small app that uses Apollo Server + Express + GraphQL + MongoDB. I have tried to replicate this YT guide (he creates root.js file on typeDefs folder). This one…
Maramal
  • 3,145
  • 9
  • 46
  • 90
11
votes
3 answers

Apollo Server: dataSources vs context to use it with database

After see this documentation I'm not sure if to use a simple context, as I has done other times, or if it is better to use dataSources to handle the database. DataSource is the correct way to comunicate with the database or it is better use it only…
alexojegu
  • 754
  • 7
  • 21
11
votes
2 answers

Subscription not connecting using ApolloServer

I am trying to get a subscription up and running with ApolloServer (v 2.2.2). I had a setup that all-of-a-sudden just stopped working. When I try to connect to the subscription in graphiql/PlaygroundI get the error: { "error": "Could not connect…
Max Gordon
  • 5,367
  • 2
  • 44
  • 70
11
votes
3 answers

Custom Error Object with Apollo Server

I'm trying to use a custom error with apollo-server and it seems that my custom error has a property (code) that isn't available from within formatError. import ExtendableError from 'es6-error' export default class MyError extends ExtendableError…
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
10
votes
0 answers

Apollo v3 unable to reach server

I am trying to deploy my basic apollo server to aws ec2 instance but i am facing with "Unable to reach server Network requests from Studio on HTTPS to your HTTP endpoint are not secure, so we cannot introspect your endpoint." So what should i do ?