apollo-server

Apollo Server Express: Request entity too large

风格不统一 提交于 2021-02-10 14:25:48
问题 I need to POST a large payload in a GraphQL mutation. How do I increase the body size limit of Apollo Server? I'm using apollo-server-express version 2.9.3. My code (simplified): const myGraphQLSchema = new GraphQLSchema({ query: new GraphQLObjectType({ name: 'Query', fields: { user: UserQuery, }, }), mutation: new GraphQLObjectType({ name: 'Mutation', fields: () => ({ ...UserMutations, }), }), }); const apolloServer = new ApolloServer(schema: myGraphQLSchema); const app = express(); app.use

`Extensions` field not shown in apollo graphql response data

我们两清 提交于 2021-02-10 13:20:30
问题 Here is a reproducible example. Run app.js and navigate the playground at http://localhost:4000/graphql You can run queries like: query RecipeQuery{ recipe(title:"Recipe 2"){ description } } Problem: I need debugging information from the extensions field in the response data. I'm talking about this extensions field: "data":{....}, "extensions": { "tracing": {} "cacheControl":{} } But in reality, I'm only getting the data field: "data":{....} I have already enabled tracing and cacheControl in

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

北战南征 提交于 2021-02-07 12:19:56
问题 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! ): Picture! } type Picture { name: String! picture: String! } ` Resolver: const { combineResolvers } = require('graphql-resolvers') const isAuthenticated = require('./auth') const { uploadPhoto } = require('../services/picture') module.exports = { Mutation: {

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

空扰寡人 提交于 2021-02-07 12:19:01
问题 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! ): Picture! } type Picture { name: String! picture: String! } ` Resolver: const { combineResolvers } = require('graphql-resolvers') const isAuthenticated = require('./auth') const { uploadPhoto } = require('../services/picture') module.exports = { Mutation: {

graphql, how to design input type when there are “add” and “update” mutation?

喜夏-厌秋 提交于 2021-02-07 05:18:37
问题 Here are my requirements: "add" mutation, every field(or called scalar) of BookInput input type should have additional type modifiers "!" to validate the non-null value. Which means when I add a book, the argument must have title and author field, like {title: "angular", author: "novaline"} "update" mutation, I want to update a part of fields of the book, don't want to update whole book(MongoDB document, And, I don't want front-end to pass graphql server a whole big book mutation argument for

Convert snake_case to camelCase field names in apollo-server-express

孤街醉人 提交于 2021-02-04 19:01:47
问题 I'm new to GraphQL and Apollo Server, though I have scoured the documentation and Google for an answer. I'm using apollo-server-express to fetch data from a 3rd-party REST API. The REST API uses snake_case for its fields. Is there a simple way or Apollo Server canonical way to convert all resolved field names to camelCase? I'd like to define my types using camel case like: type SomeType { id: ID! createdTime: String updatedTime: String } but the REST API returns object like: { "id": "1234"

Solving relationships in Mongoose and GraphQL

↘锁芯ラ 提交于 2021-01-29 09:55:47
问题 So, I have this app that I'm starting and I'm going with MERNG stack using Apollo. I was doing research by reading blog posts and watching videos in order to have a better understanding of how GraphQL works (never actually worked with it). At some point, I started to see examples of relationships between db models such as "posts from a user". For example: import { model, Schema } from 'mongoose'; const postSchema = new Schema( { title: String, createdBy { type: Schema.Types.ObjectId, ref:

Jest mock method of base ES6 class (super method) when testing extended class

梦想的初衷 提交于 2021-01-29 06:44:42
问题 I am having issues when testing that the original method (from the base class), is called with some parameters, when testing an extended class. The class that I want to test is: // ApiDataSource.js import { RESTDataSource } from "apollo-datasource-rest"; export default class ApiDataSource extends RESTDataSource { constructor() { super(); this.baseURL = 'test'; } //We add the authorization params to the get method async get(path, params = {}, init = {}) { return super.get( path, { ...params,

Documentation at the top level of a GraphQL schema

℡╲_俬逩灬. 提交于 2021-01-28 19:20:57
问题 I'm documenting all my types, fields and parameters in my schema (SDL), including Query and Mutation at the top - but I can't work out how to add a single piece of documentation for the top-level of the whole schema. I'm not sure if it's the spec or the tooling - Apollo for example allows me to write schema { } , but not to put anything inside it, or documentation before it. And there are no examples of it in the docs, particularly at https://graphql.github.io/graphql-spec/June2018/#sec

How to upload images to fastify + graphql backend with axios?

做~自己de王妃 提交于 2021-01-28 13:35:50
问题 When sending images via axios I found I have to use formdata. I add my images here but when sending the formdata my entire backend just freezes, just says "pending". Ive been following this And my attempt so far: backend: Apollo: import { ApolloServer, makeExecutableSchema } from 'apollo-server-fastify'; const schema = makeExecutableSchema({ typeDefs, resolvers }); const apolloServer = new ApolloServer({ schema, uploads: { maxFileSize: 10000000, maxFiles: 5, }, }); (async function() { app