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

94 questions
26
votes
2 answers

Stitching secure subscriptions using makeRemoteExecutableSchema

We have implemented schema stitching where GraphQL server fetches schema from two remote servers and stitches them together. Everything was working fine when we were only working with Query and Mutations, but now we have a use-case where we even…
10
votes
1 answer

How to return a GraphQL error in graphql-tools addMockFunctionsToSchema?

I'd like to mock an error response in graphql-tools/addMockFunctionsToSchema mock resolver following this pattern: const mocks = { ..., Mutation: () => ({ getToken: (_, { password }) => { if (password === 'password') { return {…
tgk
  • 2,972
  • 1
  • 17
  • 35
7
votes
2 answers

Schema Stitching resolve conflict by adding prefix

So I have this two schemas Schema1 type Permission { relation: Relation } enum Relation { ONE TWO THREE } Schema2 type Permission { relation: Relation } enum Relation { FOUR FIVE SIX } The expect result is…
acrogenesis
  • 876
  • 8
  • 18
6
votes
1 answer

How to pass query arguments in graphql-tool?

I am using graphql-tool to mock up data for testing. I hope to simulate when I select a user, it opens a detail page and shows the user company info. Query const query = ` query User($id: ID!) { user(id: $id) { id company } …
Hongbo Miao
  • 31,551
  • 46
  • 124
  • 206
5
votes
1 answer

Share common fields between Input and Type in GraphQL

I was wondering if there's a way to share the common fields between Input and Type in GraphQL so that I don't have to define the same set of fields in multiple places. Example: input PersonInput { id: String! name: String address:…
wei
  • 2,782
  • 3
  • 20
  • 31
4
votes
3 answers

graphql-tools difference between mergeSchemas and makeExecutableSchema

So the reason I am asking this question is because I can get both of these to return a working result with just replacing one or the other. So which is the right one to use and why? What are their purposes in regards to schemas? import {…
Taylor Austin
  • 3,438
  • 8
  • 38
  • 82
4
votes
1 answer

GraphQL nested query returning null

When attempting to run the following query I get this error: "Cannot return null for non-nullable field User.first_name.". I am not expecting a null result. Query: { site(site_reference: 123456789) { site_name site_managers { _id …
4
votes
1 answer

Graphql: completely change field type in schema

I need to completely change field type. Situation: I have a gateway that combines multiple services. It fetches their schemas with introspection, transforms them by adding namespaces to types (with apollo graphql-tools) and putting them in nested…
Terion
  • 2,024
  • 2
  • 23
  • 39
4
votes
3 answers

How to limit query introspection

I have a node.js project powered by apollo-server. I use custom @admin directive that does permission checking on queries, mutations and object fields. For queries and mutation this directive throws errors, for fields it returns null instead of real…
3
votes
3 answers

Trouble migrating from graphql-import to just graphql-tools with ApolloServer, directives cease to work

My plight began as a simple desire to expand my graphql schema from a single .graphql file to multiple files so i can better organize the schema and so it wouldn;t grow to one huge file out of control. My original layout was very straight forward…
xunux
  • 985
  • 1
  • 12
  • 23
3
votes
2 answers

`Cannot use e "__Schema" from another module or realm.` and `Duplicate "graphql" modules` using ApolloClient

I have a React application with ApolloClient with Apollo-Link-Schema. The application works fine locally but in our staging environment (using GOCD), we get the following error: Uncaught Error: Cannot use e "__Schema" from another module or…
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
  • 13,847
  • 6
  • 47
  • 76
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…
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 …
slideshowp2
  • 38,463
  • 29
  • 127
  • 255
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
  • 524
  • 9
  • 28
1
2 3 4 5 6 7