Tag: apollo-server
-
How To Throw Errors In Apollo Server v4?
0 thanks for looking into this. So I am trying to migrate my Apollo Server from V3 to V4, I have a resolver that type checks for an Access Token and returns it like so export class LoginResolver { @Mutation(() => AccessToken) async login( @Arg("email") email: string, @Arg("password") password: string, @Ctx() { prisma, res }:…
-
How to import gql to create typedefs in apollo server v4?
0 In the version 3 of apollo server, we could use import {gql} from "apollo-server-express" to create typedefs and schemas. But in v4 of apollo server, apollo-server-express and apollo-server-core are depreciated and will be removed. So, instead of importing gql from apollo-server-express, how can we import gql I tried import gql from new @apollo/server and…
-
How to load a .graphql file using `apollo-server`?
35 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): CourseType courseTypes: [CourseType]! } ` module.exports = schema Then using it for the apollo-server: index.js const { ApolloServer,…
-
How Can I Pass the Auth Middleware to the Apollo GraphQL Server
1 My App.js const mongoose = require(‘mongoose’); const dotenv = require(‘dotenv’); const { ApolloServer } = require(‘apollo-server’); const { startStandaloneServer } = require(‘@apollo/server/standalone’); const typeDefs = require(‘./apolloGraphql/schema’); const resolvers = require(‘./apolloGraphql/resolvers’); const auth = require(‘./Middleware/Auth’); dotenv.config({ path: ‘./config/.env’ }); const server = new ApolloServer({ typeDefs, resolvers, }); mongoose .connect(process.env.MONGOURI) .then((result) => { return server.listen(process.env.PORT, (req,…
-
Apollo server return protected field when performing login mutation
0 I have a problem with returning protected fields from PersonType in the login mutation. The idea is to set the cookie or session, and then return the user with some protected fields. Server: const server = new ApolloServer({ schema, context: async ({ req, res }: { req: Request; res: Response }) => { const…
-
How to check to which service is being queried by Apollo Gateway
0 I have two services in my Apollo Gateway configuration. I can only connect to one of them with a VPN. I would like to check this using the X-Forwarded-For header. public makeGateway = (): ApolloGateway => { const gateway = new ApolloGateway({ debug: this.config.DEBUG, supergraphSdl: new IntrospectAndCompose({ subgraphs: this.config.services, }), buildService: this.buildService, serviceHealthCheck: true,…
-
Use of enum in apollo server 4
0 I am learning to build a GraphQL API, and I’d like to usethe type enum In my database, the data looks like this : const missions = [ { id: "1", name: "Mission 1", status: "in progress", }, ]; And and my schema and resolvers like this : const typeDefs = gql` enum Status…
-
Apollo server 4 with or without express : standaloneServer vs expressMiddleware
0 I am new to graphql and I would like to build my first API, using mongoose and MongoDB. So far, I’ve built some API’s using Express, mongoose and MongoDB (in MERN apps). I’d like to use Apollo/server , and I realise there are two options to build a server, using startStandaloneServer , therefore not…