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
31
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…
30
votes
9 answers

Can't import the named export XXXX from non EcmaScript module (only default export is available)

I have a client-server setup, in which the client(create-react-app) runs on localhost:3000 and the server is an express server which is built on node and I'm attempting to build graphql schema-resolvers setup. I'm able to import .graphql files on…
Elroy Toscano
  • 362
  • 1
  • 4
  • 11
12
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
  • 3,312
  • 4
  • 23
  • 33
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
  • 3,857
  • 2
  • 27
  • 42
8
votes
2 answers

ApolloServer using mergeSchemas, Error: Apollo Server requires either an existing schema, modules or typeDefs

I think I am just using this module wrong and that is the reason I am getting an error. According to the documentation I can pass an array of resolvers and schemas to the mergeSchemas function from graphql-tools. But I am getting this error: Error:…
Taylor Austin
  • 5,407
  • 15
  • 58
  • 103
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
  • 937
  • 9
  • 21
6
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
  • 1,531
  • 5
  • 20
  • 33
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
  • 45,290
  • 60
  • 174
  • 267
5
votes
1 answer

Can't import IResolvers from graphql-tools

import { IResolvers } from "graphql-tools"; I was trying to import IResolvers from graphql-tools and got the message Module: '"../node_modules/graphql-tools"' has no exported member 'IResolvers'. My dependencies are:"apollo-server-express":…
goat 9009
  • 111
  • 1
  • 7
5
votes
7 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…
5
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…
4
votes
1 answer

Can't get Graphql-tools to read my schema.graphql file

I am using Apollo-server-express and Graphql-tools. I have been all over the Graphql-tools documentation and I can't get this to work. I'm trying to get my schema.graphql file to import as my typeDefs. It seems like Graphql-tools should be making…
BWayne
  • 161
  • 1
  • 2
  • 10
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
  • 5,407
  • 15
  • 58
  • 103
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,396
  • 3
  • 28
  • 42
1
2 3 4 5 6 7 8