@@ -4,6 +4,9 @@ title: Maven Plugin Client Usage
44sidebar_label : Generating Client
55---
66
7+ GraphQL Kotlin plugins can be used to generate a lightweight type-safe GraphQL HTTP clients. See examples below for more
8+ information about the client generating tasks.
9+
710## Downloading Schema SDL
811
912Download SDL Mojo requires target GraphQL server ` endpoint ` to be specified. Task can be executed directly from the
@@ -451,71 +454,3 @@ different endpoints.
451454 </executions >
452455</plugin >
453456```
454-
455- ## Generating SDL Example
456-
457- GraphQL schema can be generated directly from your source code using reflections. ` generate-sdl ` mojo will scan your
458- classpath looking for classes implementing ` Query ` , ` Mutation ` and ` Subscription ` marker interfaces and then generates the
459- corresponding GraphQL schema using ` graphql-kotlin-schema-generator ` and default ` NoopSchemaGeneratorHooks ` . In order to
460- limit the amount of packages to scan, this mojo requires users to provide a list of ` packages ` that can contain GraphQL
461- types.
462-
463- ``` xml
464- <plugin >
465- <groupId >com.expediagroup</groupId >
466- <artifactId >graphql-kotlin-maven-plugin</artifactId >
467- <version >${graphql-kotlin.version}</version >
468- <executions >
469- <execution >
470- <goals >
471- <goal >generate-sdl</goal >
472- </goals >
473- <configuration >
474- <packages >
475- <package >com.example</package >
476- </packages >
477- </configuration >
478- </execution >
479- </executions >
480- </plugin >
481- ```
482-
483- ## Generating SDL with Custom Hooks Provider Example
484-
485- Plugin will default to use ` NoopSchemaGeneratorHooks ` to generate target GraphQL schema. If your project uses custom hooks
486- or needs to generate the federated GraphQL schema, you will need to provide an instance of ` SchemaGeneratorHooksProvider `
487- service provider that will be used to create an instance of your custom hooks.
488-
489- ` generate-sdl ` mojo utilizes [ ServiceLoader] ( https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/ServiceLoader.html )
490- mechanism to dynamically load available ` SchemaGeneratorHooksProvider ` service providers from the classpath. Service provider
491- can be provided as part of your project, included in one of your project dependencies or through explicitly provided artifact.
492- See [ Schema Generator Hooks Provider] ( ./hooks-provider.mdx ) for additional details on how to create custom hooks service provider.
493- Configuration below shows how to configure GraphQL Kotlin plugin with explicitly provided artifact to generate federated
494- GraphQL schema.
495-
496- ``` xml
497- <plugin >
498- <groupId >com.expediagroup</groupId >
499- <artifactId >graphql-kotlin-maven-plugin</artifactId >
500- <version >${graphql-kotlin.version}</version >
501- <executions >
502- <execution >
503- <goals >
504- <goal >generate-sdl</goal >
505- </goals >
506- <configuration >
507- <packages >
508- <package >com.example</package >
509- </packages >
510- </configuration >
511- </execution >
512- </executions >
513- <dependencies >
514- <dependency >
515- <groupId >com.expediagroup</groupId >
516- <artifactId >graphql-kotlin-federated-hooks-provider</artifactId >
517- <version >${graphql-kotlin.version}</version >
518- </dependency >
519- </dependencies >
520- </plugin >
521- ```
0 commit comments