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] allow specifying custom headers for introspection/downloadSDL tasks (#728)
* [plugins] allow specifying custom headers for introspection/downloadSDL tasks
Update introspection and downloadSDL tasks/mojos to accept list of headers. See updated plugin documentation for details.
Resolves: #722
* remove commented out build config
Copy file name to clipboardExpand all lines: docs/plugins/gradle-plugin.md
+54-3Lines changed: 54 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,10 +38,14 @@ graphql {
38
38
sdlEndpoint ="http://localhost:8080/sdl"
39
39
// Target package name to be used for generated classes.
40
40
packageName ="com.example.generated"
41
+
// Optional HTTP headers to be specified on an introspection query or SDL request.
42
+
headers["X-Custom-Header"] ="Custom-Header-Value"
41
43
// Boolean flag indicating whether or not selection of deprecated fields is allowed.
42
44
allowDeprecatedFields =false
43
45
// Custom GraphQL scalar to converter mapping containing information about corresponding Java type and converter that should be used to serialize/deserialize values.
@@ -63,6 +67,7 @@ and could be used as an alternative to `graphqlIntrospectSchema` to generate inp
63
67
| Property | Type | Required | Description |
64
68
| -------- | ---- | -------- | ----------- |
65
69
|`endpoint`| String | yes | Target GraphQL server SDL endpoint that will be used to download schema.<br/>**Command line property is**: `endpoint`. |
70
+
|`headers`| Map<String, Any> || Optional HTTP headers to be specified on a SDL request. |
66
71
67
72
### graphqlGenerateClient
68
73
@@ -115,6 +120,7 @@ should be used to generate input for the subsequent `graphqlGenerateClient` task
115
120
| Property | Type | Required | Description |
116
121
| -------- | ---- | -------- | ----------- |
117
122
|`endpoint`| String | yes | Target GraphQL server endpoint that will be used to execute introspection queries.<br/>**Command line property is**: `endpoint`. |
123
+
|`headers`| Map<String, Any> || Optional HTTP headers to be specified on an introspection query. |
118
124
119
125
## Examples
120
126
@@ -193,7 +199,7 @@ val graphqlGenerateClient by tasks.getting(GraphQLGenerateClientTask::class) {
193
199
This will process all GraphQL queries located under `src/main/resources` and generate corresponding GraphQL Kotlin clients.
194
200
Generated classes will be automatically added to the project compile sources.
195
201
196
-
### Generating client with Custom Scalars
202
+
### Generating Client with Custom Scalars
197
203
198
204
By default, all custom GraphQL scalars will be serialized as Strings. You can override this default behavior by specifying
Copy file name to clipboardExpand all lines: docs/plugins/maven-plugin.md
+47-1Lines changed: 47 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,7 @@ goal provides limited functionality by itself and instead should be used to gene
28
28
| Property | Type | Required | Description |
29
29
| -------- | ---- | -------- | ----------- |
30
30
|`endpoint`| String | yes | Target GraphQL server SDL endpoint that will be used to download schema.<br/>**User property is**: `graphql.endpoint`. |
31
+
| `headers` | Map<String, Any> | | Optional HTTP headers to be specified on a SDL request.
31
32
32
33
### generate-client
33
34
@@ -122,6 +123,7 @@ should be used to generate input for the subsequent `generate-client` goal.
122
123
| Property | Type | Required | Description |
123
124
| -------- | ---- | -------- | ----------- |
124
125
| `endpoint` | String | yes | Target GraphQL server endpoint that will be used to execute introspection queries.<br/>**User property is**: `graphql.endpoint`. |
126
+
| `headers` | Map<String, Any> | | Optional HTTP headers to be specified on an introspection query. |
125
127
126
128
## Examples
127
129
@@ -320,7 +322,7 @@ Generated classes will be automatically added to the project test compile source
320
322
>NOTE: You might need to explicitly add generated test clients to your project test sources for your IDE to recognize them.
321
323
>See [build-helper-maven-plugin](https://www.mojohaus.org/build-helper-maven-plugin/) for details.
322
324
323
-
### Complete Configuration Example
325
+
### Complete Minimal Configuration Example
324
326
325
327
Following is the minimal configuration that runs introspection query against a target GraphQL server and generates a corresponding schema.
326
328
This generated schema is subsequently used to generate GraphQL client code based on the queries provided under `src/main/resources` directory.
@@ -349,3 +351,47 @@ This generated schema is subsequently used to generate GraphQL client code based
349
351
>NOTE: Both `introspect-schema` and `generate-client` goals are bound to the same `generate-sources` Maven lifecycle phase.
350
352
>As opposed to Gradle, Maven does not support explicit ordering of different goals bound to the same build phase. Maven
351
353
>Mojos will be executed in the order they are defined in your `pom.xml` build file.
354
+
355
+
### Complete Configuration Example
356
+
357
+
Following is a configuration example that downloads schema SDL from a target GraphQL server that is then used to generate
358
+
the GraphQL client code based on the provided query.
Copy file name to clipboardExpand all lines: plugins/graphql-kotlin-gradle-plugin/README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,7 @@ and could be used as an alternative to `graphqlIntrospectSchema` to generate inp
46
46
| Property | Type | Required | Description |
47
47
| -------- | ---- | -------- | ----------- |
48
48
|`endpoint`| String | yes | Target GraphQL server SDL endpoint that will be used to download schema.<br/>**Command line property is**: `endpoint`. |
49
+
|`headers`| Map<String, Any> || Optional HTTP headers to be specified on a SDL request. |
49
50
50
51
### graphqlGenerateClient
51
52
@@ -98,6 +99,7 @@ should be used to generate input for the subsequent `graphqlGenerateClient` task
98
99
| Property | Type | Required | Description |
99
100
| -------- | ---- | -------- | ----------- |
100
101
|`endpoint`| String | yes | Target GraphQL server endpoint that will be used to execute introspection queries.<br/>**Command line property is**: `endpoint`. |
102
+
|`headers`| Map<String, Any> || Optional HTTP headers to be specified on an introspection query. |
Copy file name to clipboardExpand all lines: plugins/graphql-kotlin-gradle-plugin/src/main/kotlin/com/expediagroup/graphql/plugin/gradle/GraphQLGradlePlugin.kt
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -66,11 +66,13 @@ class GraphQLGradlePlugin : Plugin<Project> {
66
66
if (extension.clientExtension.endpoint !=null) {
67
67
val introspectSchemaTask = project.tasks.named(INTROSPECT_SCHEMA_TASK_NAME, GraphQLIntrospectSchemaTask::class.java).get()
Copy file name to clipboardExpand all lines: plugins/graphql-kotlin-gradle-plugin/src/main/kotlin/com/expediagroup/graphql/plugin/gradle/GraphQLPluginExtension.kt
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,8 @@ open class GraphQLPluginClientExtension {
46
46
var sdlEndpoint:String?=null
47
47
/** Target package name to be used for generated classes. */
48
48
var packageName:String?=null
49
+
/** Optional HTTP headers to be specified on an introspection query or SDL request. */
50
+
var headers:MutableMap<String, Any> =mutableMapOf()
49
51
/** Boolean flag indicating whether or not selection of deprecated fields is allowed. */
50
52
var allowDeprecatedFields:Boolean=false
51
53
/** Custom GraphQL scalar to converter mapping containing information about corresponding Java type and converter that should be used to serialize/deserialize values. */
0 commit comments