graphql js - Apollo client cache - Network error: Cannot read property ‘appStateOfUI’ of undefined at resolver

The code is like this. I was following apollo-link-state example.const defaultState = { "appStateOfUI": { __typename: "appStateOfUI", first: "John", last: "Doe" }};we warm up the client with these defaults like this:const stateLink = withClientState({ cache, defaults: defaultState, resolvers: { Mutation: { updateAppState: ... } }});And initialized my client like this.const client = new ApolloClient({ link: ApolloLink.from([ stateLink, new HttpLink({...}) ]), ...Read more

apollo - How to set ApolloError.extraInfo in an Error thrown by a GraphQL Server resolver?

I have a resolver that is called from execute (graphql package), and when the backend needs to report an error it throws an internal type (AuthError, etc.) that includes an error code that the front-end depends on to respond accordingly. However, I have run into an issue where the result from execute is wrapping this error in a GraphQLError, which includes the original error as originalError, but this portion is not getting propagated up to the client.Here is the Server Side after the error is thrown and before sending the result to the client:...Read more

aws appsync - How to Subscribe to All GraphQL Mutations in AWS-Amplify Vue Components?

I am trying to subscribe to changes on delete, create and update mutations.In my GraphQL schema, I created a subscription field that listens to all those mutations with type Subscription { onAll: Task @aws_subscribe(mutations: ["createTask","updateTask","deleteTask"]) }Now when tried using amplify-vue components, in case of getting back a response :onSubscriptionMsg=SomeFunction(response) I am receiving old list of tasks from So how should I know which mutation was provoked and thus update the data.listOfTasks?Thanks ...Read more

apollo server - GraphQL.js Subscription response error when nested queries/resolvers

I have the following subscription query that works fine:subscription{ streamShipmentOrder{ id }}But the following sends an "Cannot read property 'ShipmentOrder' of undefined" errorsubscription{ streamShipmentOrder{ id logs{ comment } }}Here is my ShipmentOrder type definition, I'm using sequelize to talk to the databaseconst ShipmentOrderType = new GraphQLObjectType({ name: 'ShipmentOrder', fields: () => ({ id: { type: GraphQLID }, logs: { type: new GraphQLList(LogType), resolve: async...Read more

graphql js - GraphQLError Schema validation while triggering a mutation

I am trying my hand at GraphQL and I seem to have run into a strange error. Here is my mutation const createNewTask = { name: "AddATask", description: "A mutation using which you can add a task to the todo list", type: taskType, args: { taskName: { type: new gql.GraphQLNonNull(gql.GraphQLString) }, authorId: { type: new gql.GraphQLNonNull(gql.GraphQLString) } }, async resolve(_, params) { try { const t...Read more

graphql js - fragment cannot be spread here as objects of type "Query"

Trying out relay with react and ran into this today. Here is what I've done so far.Root Query:query { tasks { id taskName taskStatus userId }}React component hierarchyApp ↳--TaskList (props: tasks) ↳--TaskListItem (props: task)Now due to the principle of colocation I know I have to write fragments in each component to describe their data needs.TaskListItem.jsconst TaskListItemContainer = createFragmentContainer( TaskListItem, graphql` fragment TaskListItem_task on task { id taskName ...Read more

graphql - When to use GraphQLID instead of GraphQLInt?

It is not clear when to use GraphQLID instead of GraphQLInt.Consider the following schema:type User { id: Int! firstName: String! lastName: String!}type Query { user (id: ID!): User}In case of Query.user, it seem to make no difference whether to use GraphQLID or GraphQLInt.In case of, using GraphQLID will cast the input to string. Using GraphQLInt will ensure that the input is an integer.This makes the query and type system inconsistent.The graphql-js spec simply says: A GraphQLScalarType that represents an ID.Is this an implement...Read more

Unexpected <EOF> while using graphql

Getting EOF error every time at same line, changed code many times and even degraded to previous versions of graphql but no positive results.My code is:const graphql = require('graphql')const _ = require('lodash') const { GraphQLObjectType, GraphQLString, GraphQLInt, GraphQLSchema } = graphqlconst users = [ {id: '1', firstName: 'Ansh', age: 20}, {id: '2', firstName: 'Ram', age: 21}, {id: '3', firstName: 'Sham', age: 20}] const UserType = new GraphQLObjectType({ name: 'User', fields: { id: {type: GraphQLSt...Read more

GraphQL [graphql js] circular dependencies: The type of * must be Output Type but got: [object Object]

EDITadded my solution as an answerORIGINAL QUESTIONi believe this issue has to do with circular dependencies. i spent the better half of last night and today trying everything i could find online but nothing seems to work.what i have tried:convert the fields prop to a function that returns a field objectconvert the relating fields (within the fields prop) into functions that return the typecombining the two approaches abovefinally ending with require statements in place of the fields that use the reference type (does not seem correct and the li...Read more

Duplicate "graphql" modules cannot be used

I have found that the graphql-js library does not allow dependencies to also use graphql. You would get the following error Duplicate "graphql" modules cannot be used at the same time since differentversions may have different capabilities and behavior. The data from oneversion used in the function from another could produce confusing andspurious results.from the following codeconst express = require('express');const graphqlHTTP = require('express-graphql');const { GraphQLSchema } = require('graphql'); // the module graphql-test-mod-obj-type' ...Read more

GraphQL schema from a single object JSON file in Gatsby

So I'd like to query a single JSON file which is not an array from Gatsby's GraphQL but I don't really know how to do it.As far as I understand gatsby-transformer-json docs - it only supports loading arrays and have them accessible via allFileNameJson schema.My gatsby-config plugins (only the necessary ones for this question):{ resolve: 'gatsby-source-filesystem', options: { name: 'data', path: `${__dirname}/src/data` }},'gatsby-transformer-json'And then let's say in src/data i have a something.json file, like this:{ "key": "value"}No...Read more

graphql js - Need help to debug this updateLink resolver

I need to implement an updateLink to my graphQL server, but it keeps throwing 'id is not defined' error. The server doesn't have a database yet, only an array for practice purpose. I have defined the schema for the mutation for update, also wrote the resolver, but it just didn't work.I have looked into the apollo document, it seems my resolver and schema are correct. The following is the resolver updateLink:(parent,args)=>{ const link = {, description:args.description, ...Read more