Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merging schema results in infinite loop in v4. (RangeError: Maximum call stack size exceeded at mergeDeep (/Users/*/node_modules/@graphql-tools/utils/cjs/mergeDeep.js:5:19)) #1276

Open
alnorris opened this issue Aug 11, 2024 · 0 comments

Comments

@alnorris
Copy link

Using mergeSchemas from @graphql-tools/schema@10.0.4 results in an infinite loop when using @pothos/core@4.2.0, while using 3.41.2 it works fine. This looks like its likely due to pothos creating the schema incorrectly?

Remove type: [obj1] and returning just a Boolean for example from obj2 seems to results in it working fine.

/**
 * First schema...
 */
const firstBuilder = new SchemaBuilder<{
  Scalars: {
    HashId2: { Input: string; Output: string }
  }
}>({ plugins: [AddGraphQLPlugin] })

firstBuilder.queryType({})
firstBuilder.mutationType({})

const obj1 =
  firstBuilder.objectRef<{ id: string, name: string}>('Object1')
  
  obj1.implement({
    fields: (t) => ({
      id: t.expose('id', { type: 'String' }),
      name: t.expose('name', { type: 'String', nullable: false }),
    }),
  })

const obj2 = firstBuilder.objectRef<{ id: string, field: { id: string, name: string } }>('Object2')

obj2.implement({
  fields: (t) => ({
    id: t.expose('id', { type: 'String' }),
    field: t.field({
      nullable: true,
      type: [obj1],
      resolve: async (parent) => {
        return null
      },
    }),
  })
})

const firstSchema = firstBuilder.toSchema()


/**
 * Second schema...
 */
const secondBuilder = new SchemaBuilder<{}>({
  plugins: [AddGraphQLPlugin],
})

const obj1Ref = secondBuilder.addGraphQLObject(
  firstSchema.getType('Object1') as GraphQLObjectType
)
const obj2Ref = secondBuilder.addGraphQLObject(
  firstSchema.getType('Object2') as GraphQLObjectType,
)
secondBuilder.queryType({})
secondBuilder.mutationType({})

const secondSchema = secondBuilder.toSchema()

mergeSchemas({
  schemas: [
    firstSchema,
    secondSchema,
  ],
})

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant