This repository has been archived by the owner on Apr 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathschema.graphql
357 lines (318 loc) · 7.29 KB
/
schema.graphql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
directive @ListFilterFirstN(n: Int!) on FIELD_DEFINITION
directive @StaticDataSource (
data: String
) on FIELD_DEFINITION
directive @PipelineDataSource (
"""
configFilePath is the path where the pipeline configuration file can be found
it needs to be in the json format according to the pipeline json schema
see this url for more info: https://github.com/jensneuse/pipeline
"""
configFilePath: String
"""
configString is a string to configure the pipeline
it needs to be in the json format according to the pipeline json schema
see this url for more info: https://github.com/jensneuse/pipeline
The PipelinDataSourcePlanner will always choose the configString over the configFilePath in case both are defined.
"""
configString: String
"""
inputJSON is the template to define a JSON object based on the request, parameters etc. which gets passed to the first pipeline step
"""
inputJSON: String!
) on FIELD_DEFINITION
directive @NatsDataSource (
addr: String!
topic: String!
) on FIELD_DEFINITION
directive @WasmDataSource (
input: String!
wasmFile: String!
) on FIELD_DEFINITION
directive @MQTTDataSource (
brokerAddr: String!
clientID: String!
topic: String!
) on FIELD_DEFINITION
directive @mapping(
mode: MAPPING_MODE! = PATH_SELECTOR
pathSelector: String
) on FIELD_DEFINITION
enum MAPPING_MODE {
NONE
PATH_SELECTOR
}
directive @HttpJsonDataSource (
host: String!
url: String!
method: HTTP_METHOD = GET
params: [Parameter]
body: String
headers: [Header]
) on FIELD_DEFINITION
input Header {
key: String!
value: String!
}
directive @GraphQLDataSource (
host: String!
url: String!
method: HTTP_METHOD = POST
field: String
params: [Parameter]
) on FIELD_DEFINITION
directive @HttpPollingStreamDataSource (
host: String!
url: String!
method: HTTP_METHOD = GET
delaySeconds: Int = 5
params: [Parameter]
) on FIELD_DEFINITION
enum HTTP_METHOD {
GET
POST
UPDATE
DELETE
}
input Parameter {
name: String!
sourceKind: PARAMETER_SOURCE!
sourceName: String!
variableType: String!
}
enum PARAMETER_SOURCE {
CONTEXT_VARIABLE
OBJECT_VARIABLE_ARGUMENT
FIELD_ARGUMENTS
}
schema {
query: Query
mutation: Mutation
subscription: Subscription
}
type Foo {
bar: String!
}
type Headers {
userAgent: String! @mapping(pathSelector: "User-Agent")
host: String! @mapping(pathSelector: "Host")
acceptEncoding: String @mapping(pathSelector: "Accept-Encoding")
Authorization: String
}
type HttpBinGet {
headers: Headers!
}
type JSONPlaceholderPost {
userId: Int!
id: Int!
title: String!
body: String!
comments: [JSONPlaceholderComment]
@HttpJsonDataSource(
host: "jsonplaceholder.typicode.com"
url: "/comments?postId={{ .postId }}"
params: [
{
name: "postId"
sourceKind: OBJECT_VARIABLE_ARGUMENT
sourceName: "id"
variableType: "String"
}
]
)
@mapping(mode: NONE)
}
type JSONPlaceholderComment {
postId: Int!
id: Int!
name: String!
email: String!
body: String!
}
type Observation {
description: String
skyDescription: String
temperature: Float
temperatureDesc: String
highTemperature: Float
lowTemperature: Float
}
type Location {
country: String
state: String
city: String
observation: [Observation]
@ListFilterFirstN(n: 1)
}
type Observations {
location: [Location]
@ListFilterFirstN(n: 1)
}
type Weather {
observations: Observations
}
type Coordinates {
lat: Float
lon: Float
}
type Country {
code: String
name: String
native: String
phone: String
continent: Continent
currency: String
languages: [Language]
emoji: String
emojiU: String
coordinates: [Coordinates]
@HttpJsonDataSource(
host: "locationiq.com"
url: "/v1/search_sandbox.php?format=json&q={{ .object.name }}&accept-language=en"
)
@mapping(mode: NONE)
}
type Continent {
code: String
name: String
countries: [Country]
}
type Language {
code: String
name: String
native: String
rtl: Int
}
"The query type, represents all of the entry points into our object graph"
type Query {
hello: String!
@StaticDataSource(
data: "World!"
)
@mapping(mode: NONE)
staticBoolean: Boolean!
@StaticDataSource(
data: "true"
)
@mapping(mode: NONE)
nonNullInt: Int!
@StaticDataSource(
data: "1"
)
@mapping(mode: NONE)
nullableInt: Int
@StaticDataSource(
data: null
)
@mapping(mode: NONE)
foo: Foo!
@StaticDataSource(
data: "{\"bar\": \"baz\"}"
)
@mapping(mode: NONE)
httpBinGet: HttpBinGet
@HttpJsonDataSource(
host: "httpbin.org"
url: "/get"
headers: [
{
key: "Authorization"
value: "{{ .request.headers.Authorization }}"
}
]
)
@mapping(mode: NONE)
post(id: Int!): JSONPlaceholderPost
@HttpJsonDataSource(
host: "jsonplaceholder.typicode.com"
url: "/posts/{{ .arguments.id }}"
)
@mapping(mode: NONE)
country(code: String!): Country
@GraphQLDataSource(
host: "countries.trevorblades.com"
url: "/"
field: "country"
params: [
{
name: "code"
sourceKind: FIELD_ARGUMENTS
sourceName: "code"
variableType: "String!"
}
]
)
person(id: String!): Person
@WasmDataSource(
wasmFile: "./person.wasm"
input: "{\"id\":\"{{ .arguments.id }}\"}"
)
@mapping(mode: NONE)
httpBinPipeline: String
@PipelineDataSource(
configFilePath: "./httpbin_pipeline.json"
inputJSON: """
{
"url": "https://httpbin.org/get",
"method": "GET"
}
"""
)
@mapping(mode: NONE)
__schema: __Schema!
__type(name: String!): __Type
}
type Person {
id: String!
name: String
age: Int
}
type Subscription {
localTime: LocalTime
@HttpPollingStreamDataSource(
host: "http://localhost:9111"
url: "/time"
)
@mapping(mode: NONE)
natsTime: TimeObject
@NatsDataSource(
addr: "nats://0.0.0.0:4222"
topic: "time"
)
@mapping(mode: NONE)
mqttTime: TimeObject
@MQTTDataSource(
brokerAddr: "tcp://localhost:1883"
clientID: "graphql"
topic: "time"
)
@mapping(mode: NONE)
}
type TimeObject {
time: String! @mapping(pathSelector: "Time")
}
type LocalTime {
datetime: String
timezone: String
abbreviation: String
}
type Mutation {
httpBinPost(input: HttpBinPostInput): HttpBinPostResponse
@HttpJsonDataSource(
host: "httpbin.org"
url: "/post"
method: POST
body: "{{ .arguments.input }}"
)
@mapping(mode: NONE)
}
input HttpBinPostInput {
foo: String!
}
type HttpBinPostResponse {
headers: Headers
data: HttpBinPostResponseData @mapping(pathSelector: "json")
}
type HttpBinPostResponseData {
foo: String
}