You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
Kobby generates resolver functions for all fields in root GraphQL types (Query, Mutation and Subscription). For
other GraphQL types, Kobby generates resolver functions only for fields with arguments. For example, for the Country type, Kobby generates the CinemaCountryResolver interface with one films method, but
for the Film type, it does not generate a resolver at all.
But sometimes we have to resolve fields without arguments. For example, we have to resolve the country field in
the Film type. You can ask Kobby to generate a resolver for this field using the @resolve directive. Let's modify
our schema:
Together with the resolver interfaces, Kobby generates the client DSL. If you don't need it, you can disable client
generation by means of kobby extension:
The kobby extension also provides additional settings for resolver generation:
kobby {
kotlin {
// Configuration of resolver interfaces generation
resolver {
// Is resolver interfaces generation enabled// By default `true` if `com.graphql-java-kickstart:graphql-java-tools`// artifact is in the project dependencies
enabled =null// Boolean// Is wrap subscription resolver functions result in `org.reactivestreams.Publisher`// By default `true` if `org.reactivestreams:reactive-streams`// artifact is in the project dependencies
publisherEnabled =null// Boolean// Package name for resolver interfaces relative to root package name
packageName ="resolver"// Prefix for resolver interfaces// By default is capitalized context name
prefix =null// String// Postfix for resolver interfaces
postfix ="Resolver"// Name for parent object argument// By default is de-capitalized name of parent object type
argument =null// String// If not null, Kobby will generate default implementation for// functions in resolver interfaces that looks like:// TODO("$toDoMessage")
toDoMessage =null// String
}
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
You can generate Kotlin resolver interfaces and DTO classes by GraphQL schema by means of Kobby Plugin.
Put your GraphQL schema file in the project resources with
graphqls
extension. For example, let definecinema.graphqls
schema file:Add Kobby plugin to your
build.gradle.kts
, to generate Kotlin DSL (Maven plugin is also available):Run
gradle clean build
, and Kobby will generate resolver interfaces and DTO classes for you:Kobby generates resolver functions for all fields in root GraphQL types (
Query
,Mutation
andSubscription
). Forother GraphQL types, Kobby generates resolver functions only for fields with arguments. For example, for the
Country
type, Kobby generates theCinemaCountryResolver
interface with onefilms
method, butfor the
Film
type, it does not generate a resolver at all.But sometimes we have to resolve fields without arguments. For example, we have to resolve the
country
field inthe
Film
type. You can ask Kobby to generate a resolver for this field using the@resolve
directive. Let's modifyour schema:
And Kobby will generate resolver interface for the
Film
type:Together with the resolver interfaces, Kobby generates the client DSL. If you don't need it, you can disable client
generation by means of
kobby
extension:The
kobby
extension also provides additional settings for resolver generation:Beta Was this translation helpful? Give feedback.
All reactions