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
[plugins] new generate client Gradle task and Maven mojo (#688)
Introduces new functionality to generate GraphQL Kotlin client based on the specified queries.
NOTE: This is a final PR in a series to break down #595 into smaller more manageable pieces
// GraphQL server endpoint that will be used to for running introspection queries. Alternatively you can download schema directly from `sdlEndpoint`.
35
+
endpoint ="http://localhost:8080/graphql"
36
+
// GraphQL server SDL endpoint that will be used to download schema. Alternatively you can run introspection query against `endpoint`.
37
+
sdlEndpoint ="http://localhost:8080/sdl"
38
+
// Target package name to be used for generated classes.
39
+
packageName ="com.example.generated"
40
+
// Boolean flag indicating whether or not selection of deprecated fields is allowed.
41
+
allowDeprecatedFields =false
42
+
// Custom GraphQL scalar to converter mapping containing information about corresponding Java type and converter that should be used to serialize/deserialize values.
@@ -33,13 +56,45 @@ schema file as `schema.graphql` under build directory. In general, this task pro
33
56
and could be used as an alternative to `graphqlIntrospectSchema` to generate input for the subsequent
34
57
`graphqlGenerateClient` task.
35
58
59
+
**Properties**
60
+
61
+
| Property | Type | Required | Description |
62
+
| -------- | ---- | -------- | ----------- |
63
+
|`endpoint`| String | yes | Target GraphQL server SDL endpoint that will be used to download schema.<br/>**Command line property is**: `endpoint`. |
64
+
65
+
### graphqlGenerateClient
66
+
67
+
Task that generates GraphQL Kotlin client and corresponding data classes based on the provided GraphQL queries that are
68
+
evaluated against target Graphql schema. Individual clients with their specific data models are generated for each query
69
+
file and are placed under specified `packageName`.
70
+
71
+
**Properties**
72
+
73
+
| Property | Type | Required | Description |
74
+
| -------- | ---- | -------- | ----------- |
75
+
|`allowDeprecatedFields`| Boolean || Boolean flag indicating whether selection of deprecated fields is allowed or not.<br/>**Default value is:**`false`.<br/>**Command line property is**: `allowDeprecatedFields`. |
76
+
|`packageName`| String | yes | Target package name for generated code.<br/>**Command line property is**: `packageName`. |
77
+
|`queryFiles`| FileCollection || List of query files to be processed. Instead of a list of files to be processed you can specify `queryFileDirectory` directory instead. If this property is specified it will take precedence over the corresponding directory property. |
78
+
|`queryFileDirectory`| String || Directory file containing GraphQL queries. Instead of specifying a directory you can also specify list of query file by using `queryFiles` property instead.<br/>**Default value is:**`src/main/resources`.<br/>**Command line property is**: `queryFileDirectory`. |
79
+
|`scalarConverters`| Map<String, ScalarConverter> || Custom GraphQL scalar to converter mapping containing information about corresponding Java type and converter that should be used to serialize/deserialize values. |
80
+
|`schemaFile`| File |`schemaFileName` or `schemaFile` has to be provided | GraphQL schema file that will be used to generate client code. |
81
+
|`schemaFileName`| String |`schemaFileName` or `schemaFile` has to be provided | Path to GraphQL schema file that will be used to generate client code.<br/>**Command line property is**: `schemaFileName`. |
82
+
36
83
### graphqlIntrospectSchema
37
84
38
-
Executes GraphQL introspection query against specified endpoint and saves the underlying schema file as
85
+
Task that executes GraphQL introspection query against specified `endpoint` and saves the underlying schema file as
39
86
`schema.graphql` under build directory. In general, this task provides limited functionality by itself and instead
40
87
should be used to generate input for the subsequent `graphqlGenerateClient` task.
41
88
42
-
## Downloading Schema SDL
89
+
**Properties**
90
+
91
+
| Property | Type | Required | Description |
92
+
| -------- | ---- | -------- | ----------- |
93
+
|`endpoint`| String | yes | Target GraphQL server endpoint that will be used to execute introspection queries.<br/>**Command line property is**: `endpoint`. |
94
+
95
+
## Examples
96
+
97
+
### Downloading Schema SDL
43
98
44
99
GraphQL endpoints are often public and as such many servers might disable introspection queries in production environment.
45
100
Since GraphQL schema is needed to generate type safe clients, as alternative GraphQL servers might expose private
@@ -51,65 +106,136 @@ be executed directly from the command line by explicitly passing `endpoint` para
0 commit comments