Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1
Artifact/module for enabling graphql support in Javalin
License
javalin/javalin-graphql
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
- ❤️ Sponsor Javalin
- The main project webpage isjavalin.io
- Chat on Discord:https://discord.gg/sgak4e5NKv
- License summary:https://tldrlegal.com/license/apache-license-2.0-(apache-2.0)
This plugin allows implementing theGraphQL specificationwith some easy steps.
Add the dependencies:
Gradle setup for Javalin 5.x
repositories { maven { url"https://maven.reposilite.com/releases" }}dependencies { implementation"io.javalin.community.graphql:javalin-graphql:5.0.1"}
Maven setup for Javalin 5.x
<project> <repositories> <repository> <id>reposilite-repository</id> <url>https://maven.reposilite.com/releases</url> </repository> </repositories> <dependencies> <dependency> <groupId>io.javalin.community.graphql</groupId> <artifactId>javalin-graphql</artifactId> <version>5.0.1</version> </dependency> </dependencies></project>
Register the plugin:
val app=Javalin.create {val graphQLOption=GraphQLOptions("/graphql",ContextExample()) .addPackage("io.javalin.examples") .register(QueryExample(message)) .register(MutationExample(message)) .register(SubscriptionExample()) .context() it.registerPlugin(GraphQLPlugin(graphQLOption))}app.start()
The GraphQL is now available under the/graphql
endpoint.
This section contains an overview of all the available to create queries.
@GraphQLDescription("Query Example")classQueryExample :QueryGraphql {funhello():String="Hello world"fundemoData(@GraphQLDescription("awesome input")data:DemoData):DemoData= data}
After creating this class is necessary to register the class at the start of the plugin.
This section contains an overview of all the available to create commands.
@GraphQLDescription("Command Example")classCommandExample :CommandGraphql {funhello():String="Hello world"fundemoData(@GraphQLDescription("awesome input")data:DemoData):DemoData= data}
After creating this class is necessary to register the class at the start of the plugin.
This section contains an overview of all the available to create a subscription.
@GraphQLDescription("Subscription Example")classSubscriptionExample:SubscriptionGraphql {funcounter():Flux<Int>=Flux.interval(Duration.ofMillis(100)).map {1 }}
After creating this class is necessary to register the class at the start of the plugin.
Sometimes it is necessary to pass the context in the method. You can create this context with this class.
classContextExample {val globalEnvironment="globalEnvironment"}
After creating this class is necessary to register the class at the start of the plugin.
Then is possible to access this context with this annotation @GraphQLContext.
classQueryExample() : QueryGraphql {funcontext(@GraphQLContextcontext:ContextExample):ContextExample {return context }}
About
Artifact/module for enabling graphql support in Javalin
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.