Skip to content

Giant schema codegen when using Relay GraphQL Global Object Identification Specification (Node interface) #2967

@jimisaacs

Description

@jimisaacs

Summary

Apologies if this was addressed somehow but I can't seem to find an issue. It was most likely something raised off GitHub, not something addressed that I can find.

The issue which continues to plague us is that our supergraph uses the Relay "GraphQL Global Object Identification Specification". Because of this, our schema generated code is becoming less and less manageable by the day. Every new type that adheres to the Node interface, which is basically every entity type in the federation spec, gets generated schema types in the client, regardless of whether they are actually used in an operation/fragment.

Version

1.0.7

Steps to reproduce the behavior

Make a query to a graph that utilizes the Relay GraphQL Global Object Identification Specification, i.e. GetSomeTypeThatImplementsNode.graphql:

query GetSomeTypeThatImplementsNode($id: ID!) {
	node(id: $id) {
		id
		... on SomeTypeThatImplementsNode {
			someField
		}
	}
}

The expectation is that only the types needed to fulfill this query, i.e. Query and SomeTypeThatImplementsNode, should be generated. Not every type in the graph that implements Node. To make this work you'll need a schema that looks something like this, schema.graphqls:

interface Node {
	id: ID!
}

type Foo implements Node {
	id: ID!
}

type Bar implements Node {
	id: ID!
}

type SomeTypeThatImplementsNode implements Node {
	id: ID!
	someField: String
}

type Query {
	node(id: ID!): Node
}

So as you can see, considering the above query, I would NOT expect there to be anything generated for Foo and Bar, but I would expect types to be generated for SomeTypeThatImplementsNode.

Logs

No response

Anything else?

See the files I've included in the attached ReducedCase.zip archive
ReducedCase.zip

Metadata

Metadata

Assignees

Labels

bugGenerally incorrect behaviorcodegenIssues related to or arising from code generation

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions