Skip to content

Extending adding field to query #1578

@tobias-f

Description

@tobias-f

Hello.

I am currently try to modify the schema generated from a SDL programatically by adding addition types, directives and so on. Without going too much into detail, I am able to get a reference to the generated schema (GraphQLSchema). Adding directives and types is no problem. However, I want to add also some additional queries to the Query type. I tried the following, but it fails with an exception:

val schema = bean.schema
val extendedQuery = schema.queryType.transform {
  it.field(... adding a field ...)
}

val extendedSchema = schema.transform {
   it.query(extendedQuery)
}                                                        

Caused by: graphql.AssertException: All types within a GraphQL schema must have unique names. No two provided types may have the same name. No provided type may have a name which conflicts with any built in types (including Scalar and Introspection types). You have redefined the type 'Query' from being a 'GraphQLObjectType' to a 'GraphQLObjectType'

Any ideas how I can add additional queries to my schema programmatically?

Thanks a lot.

Cheers,

Tobias

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions