Questions tagged [graphql-tools]

A set of utilities to build your JavaScript GraphQL schema in a concise and powerful way.

GraphQL Tools is an npm package and an opinionated structure for how to build a GraphQL schema and resolvers in JavaScript, following the GraphQL-first development workflow.

Documentation

Repository

115 questions
3
votes
1 answer

What is the difference between GraphQLJSON and GraphQLJSONObject exported by graphql-type-json?

From the official package documentation: GraphQLJSON can represent any JSON-serializable value, including scalars, arrays, and objects. GraphQLJSONObject represents specifically JSON objects, which covers many practical use cases for JSON…
shet_tayyy
  • 5,366
  • 11
  • 44
  • 82
3
votes
1 answer

Graphql federation vs schema stitching. When to pick one over the other

I'm new to both concepts so excuse me if it's opinion-based. Currently, I'm looking at Apollo Federation and schema stitching provided by the graphql-tools package, though I guess it applies to similar packages. Could something like a table be…
ZenVentzi
  • 3,945
  • 3
  • 33
  • 48
3
votes
1 answer

How to trigger visitInputObject method on custom directive?

I'm building a custom directive in which I'm hoping to validate entire input objects. I'm using the INPUT_OBJECT type with the visitInputObject method on SchemaDirectiveVisitor extended class. Every time I run a mutation using the input type then…
3
votes
0 answers

Missing selection set for object of type X returned for query field Y

I'm relatively new to GraphQL. I have a query like so: query messages ($assetId: ID!) { messages (assetId: $assetId, offset: 0, limit: 3) { id text time sender { ...on Asset { id name …
Alex McMillan
  • 17,096
  • 12
  • 55
  • 88
3
votes
2 answers

"GraphQLError: field not found in type: 'query_root'" after merge schema

I have stitched two graphql endpoint using graphql-tools. with one endpoint schema it is working fine but with another schema it's throwing this error "GraphQLError: field not found in type: 'query_root'". Even if I can see all the schema while…
Kundan Kumar
  • 343
  • 1
  • 3
  • 11
3
votes
1 answer

How do I add union type in Apollo graphql

I created this question in case anyone was curious on how to add union / Polymorphic types in Apollo. Hopefully this will make it easier for them. In this example I wanted the response to either be a Worksheet or ApiError // typedefs.js export…
Kenneth Truong
  • 3,882
  • 3
  • 28
  • 47
3
votes
1 answer

graphql-tools, how can I use mockServer to mock a "Mutation"?

I try to use mockServer of graphql-tools to mock an Mutation. here is my unit test: it('should update user name correctly', () => { mockserver .query( `{ Mutation { updateUserName(id: 1, name: "du") { id …
Lin Du
  • 88,126
  • 95
  • 281
  • 483
3
votes
1 answer

Enumerating all fields from a GraphQL query

Given a GraphQL schema and resolvers for Apollo Server, and a GraphQL query, is there a way to create a collection of all requested fields (in an Object or a Map) in the resolver function? For a simple query, it's easy to recreate this collection…
Sljux
  • 534
  • 10
  • 28
2
votes
0 answers

How to merge a type whose fields come from two different GraphQL subschemas?

I'm running a gateway with apollo-server v2 with graphql-tools v7 and have the following services and subschemas, which I've set up as a (contrived) proof-of-concept: Service 1: Query { getUser(input: GetUserInput!): User } input GetUserInput { …
2
votes
0 answers

Access context from Apollo GraphQL mutation field directive

I have an input type like this: input PetGiraffe { name: String @addUserLastName } Inside the directive, I need access to the request's context, so that I can add the user's last name to the giraffe's name. Here's the relevant part of what I've…
Zevgon
  • 556
  • 4
  • 13
2
votes
0 answers

delegateToSchema is not using my executor

I want to delegate a field from my graphql service to a remote service. I tried to follow the docs, but I'm missing something. const {wrapSchema, introspectSchema} = require('@graphql-tools/wrap'); const got = require('got'); const {print} =…
Tim Scott
  • 15,106
  • 9
  • 65
  • 79
2
votes
1 answer

how graphql tools addSchemaLevelResolver function works

As I understood addSchemaLevelResolver function add a root level resolver on schema and cut off the all other resolvers. And I tried that method like in the below. if (process.env.DEV === true) { schema = addSchemaLevelResolver(schema, () => { …
Adam
  • 437
  • 1
  • 4
  • 12
2
votes
1 answer

Are fields with list types forbidden in GraphQL schema stitching selection sets?

I have an array of entities that look like this: const aEntities = [ { id: 1, name: 'Test', oneToManyRelation: [ { id: 2 }, { id: 3 } …
2
votes
0 answers

How to use mergeSchemas for remote schemas with Apollo Server

I have some problems with merging remote schemas. As a base I've taken the Apollo GraphQL package referenced in the tutorial (https://www.apollographql.com/docs/tutorial/introduction/). I want to prototype the following architecture: 2 services 1…
David Bulczak
  • 443
  • 1
  • 4
  • 13
2
votes
0 answers

How can i upload an image with graphql-upload

I tried uploading a file to a graphql server that has graphql-tool. I have set up the request multipart specification and I use Altair graphql client to make a request to the graphql endpoint. I get the error SyntaxError: Unexpected token - in JSON…