Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Unused type definitions are not visible in introspection queries #420

Closed
code-wok opened this issue Jul 21, 2020 · 3 comments · Fixed by #445
Closed

Unused type definitions are not visible in introspection queries #420

code-wok opened this issue Jul 21, 2020 · 3 comments · Fixed by #445

Comments

@code-wok
Copy link

If we define a type that is unused in the schema file e.g

type User {
    ...
}

type Context {
    ...
}

type Query {
    user(id: ID!): User
}
  • The Query and User types are returned from introspection queries but not Context. Is this by design?
  • If it is by design, is there a way for the type to appear in introspection queries? I can see they appear in SchemaParser.getUnusedDefinitions() but is there a way to wire that in so that they are visible in introspection queries?
@vojtapol
Copy link
Member

I don't believe the schema introspection should be returning unused types. Can you find specs or some other projects that do return unused types?

@williamboman-pp
Copy link

My use case to include unused types is for federation:

class QueryResolver : GraphQLQueryResolver {}

val schema = """
type User @key(fields: "uuid") @extends {
  uuid: ID! @external
  hasCompletedKyc: Boolean!
}

type Query {}
"""

var schema = SchemaParser.newParser()
  .schemaString(schema)
  .resolvers(QueryResolver())
  .build()
  .makeExecutableSchema()

schema = Federation.transform(schema)
  .resolveEntityType(...)
  .fetchEntities(...) // this will resolve the external User type we're extending
  .build()

println(SchemaPrinter().print(schema))

@seanscal
Copy link

@vojtapol @oliemansm could we get some eyes on these PRs? 🙂 - federation compatibility is critical in my company's framework evaluation, the library looks great - would be great to see this feature working

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

Successfully merging a pull request may close this issue.

4 participants