Replies: 2 comments 2 replies
-
This gets me half-way: val executableSchema = schemaParser.makeExecutableSchema()
val oldFruitTypeResolver =
executableSchema.codeRegistry.getTypeResolver(GraphQLInterfaceType.newInterface().name("Fruit").build())
val fruitTypeResolver = TypeResolver { env ->
when {
env.getObject<Any>() is Orange -> env.schema.getObjectType("Banana")
else -> oldFruitTypeResolver.getType(env)
}
}
val schemaObjects = schemaParser.parseSchemaObjects()
return GraphQLSchema.newSchema()
.description(schemaObjects.description)
.query(schemaObjects.query)
.mutation(schemaObjects.mutation)
.subscription(schemaObjects.subscription)
.additionalTypes(schemaObjects.dictionary)
.additionalDirectives(schemaObjects.directives)
.codeRegistry(
schemaObjects.codeRegistryBuilder
.typeResolver("Fruit", fruitTypeResolver)
.build()
)
.build() but then I end up building a schema which does not have the correct data fetchers |
Beta Was this translation helpful? Give feedback.
0 replies
-
@oryan-block do you if there is an easy solution with the current graphql-java-tools for this? I am even considering departing graphql-java-tools and using pure graphql-java for this type of issue, but this is substantial work on my end and I loose out on all of the niceties of auto-wiring. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If you use the automatic wiring for types, is there a way to override the wiring/type resolution for a single type but keep the rest?
I have a GraphQL interface
Fruit
which has subtypesApple
andBanana
. There exists a corresponding java interfaceFruit
and java classesApple
andBanana
.How do I introduce a new class only on the java side, lets say called
Orange
, which on the java side implementsFruit
, but I want it to resolve toBanana
on the GraphQL side (so I do not have to introduce another GraphQL type in the schema).Beta Was this translation helpful? Give feedback.
All reactions