Skip to content

Commit e126d48

Browse files
authored
chore: run prettier on *.graphql (#59)
1 parent 268cd5d commit e126d48

File tree

31 files changed

+624
-557
lines changed

31 files changed

+624
-557
lines changed

dbquery/pagination/operations.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Page through customers from a database connection based pagination
2-
query Customers($first: Int!, $after: String = "") {
2+
query Customers($first: Int!, $after: String = "") {
33
customers(first: $first, after: $after) {
44
edges {
55
node {
Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# See preamble in README.md
22

33
type Document {
4-
docId: String
5-
content(id: String!): Content
6-
@materializer(query: "content", arguments:[{name: "id" argument:"id"}])
7-
author: Author
8-
lastUpdate: Date
4+
docId: String
5+
content(id: String!): Content
6+
@materializer(query: "content", arguments: [{ name: "id", argument: "id" }])
7+
author: Author
8+
lastUpdate: Date
99
}
1010

1111
type Content @mock {
@@ -15,36 +15,47 @@ type Content @mock {
1515
}
1616

1717
type Query {
18-
document: Document
19-
@rest(
20-
endpoint: "stepzen:empty"
21-
transforms: [{
22-
editor: """jq: {"author": { "name":"Roy Derks", "country":"Netherlands"}}"""
23-
}]
24-
)
25-
# Content is exposed here to keep the snippet self-contained, but would otherwise not be exposed as an operation
26-
content(id: String!): Content
27-
@connector(type:"echo")
18+
document: Document
19+
@rest(
20+
endpoint: "stepzen:empty"
21+
transforms: [
22+
{
23+
editor: """
24+
jq: {"author": { "name":"Roy Derks", "country":"Netherlands"}}
25+
"""
26+
}
27+
]
28+
)
29+
# Content is exposed here to keep the snippet self-contained, but would otherwise not be exposed as an operation
30+
content(id: String!): Content @connector(type: "echo")
2831
}
2932

3033
type Author {
31-
name: String!
32-
country: String
34+
name: String!
35+
country: String
3336
}
3437

3538
type Query {
3639
book: Book
3740
@rest(
38-
endpoint: "stepzen:empty"
39-
transforms: [{
40-
editor: """jq: {"refId": "27", "name": "Fullstack GraphQL"}"""
41-
}]
41+
endpoint: "stepzen:empty"
42+
transforms: [
43+
{
44+
editor: """
45+
jq: {"refId": "27", "name": "Fullstack GraphQL"}
46+
"""
47+
}
48+
]
4249
)
4350
}
4451

4552
type Book {
4653
refId: String!
4754
name: String
48-
author: Author @materializer (query: "document {author}")
49-
content: Content @materializer (query: "document {content}", arguments: {name: "id", field: "refId"})
50-
}
55+
author: Author @materializer(query: "document {author}")
56+
content: Content
57+
@materializer(
58+
query: "document {content}"
59+
arguments: { name: "id", field: "refId" }
60+
)
61+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
schema @sdl(files:[
2-
"api.graphql"
3-
]){query: Query}
1+
schema @sdl(files: ["api.graphql"]) {
2+
query: Query
3+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
schema @sdl(files:[
2-
"api.graphql"
3-
]){query: Query}
1+
schema @sdl(files: ["api.graphql"]) {
2+
query: Query
3+
}
Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
type Customer {
2-
name: String
3-
city: String
2+
name: String
3+
city: String
44
}
55
type Query {
6-
# An ecmascript generator of customer data.
7-
# Of course, in real life you will call an API or a database. You can do that by changing the `endpoint` argument on the `@rest` directive.
8-
# https://stepzen.com/docs/connecting-backends/how-to-connect-a-rest-service
9-
customer (id: ID): Customer
10-
@rest (endpoint: "stepzen:empty"
11-
ecmascript: """
12-
function transformREST(s) {
13-
var id = get('id')
14-
if (id==1)
15-
return (JSON.stringify({"name":"John Doe","city":"Miami"}))
16-
else
17-
return (JSON.stringify({"name":"Jane Smith","city":"Santa Clara"}))
18-
}
19-
"""
6+
# An ecmascript generator of customer data.
7+
# Of course, in real life you will call an API or a database. You can do that by changing the `endpoint` argument on the `@rest` directive.
8+
# https://stepzen.com/docs/connecting-backends/how-to-connect-a-rest-service
9+
customer(id: ID): Customer
10+
@rest(
11+
endpoint: "stepzen:empty"
12+
ecmascript: """
13+
function transformREST(s) {
14+
var id = get('id')
15+
if (id==1)
16+
return (JSON.stringify({"name":"John Doe","city":"Miami"}))
17+
else
18+
return (JSON.stringify({"name":"Jane Smith","city":"Santa Clara"}))
19+
}
20+
"""
2021
)
21-
customers: [Customer]
22-
@rest (endpoint: "stepzen:empty"
23-
ecmascript: """
24-
function transformREST(s) {
25-
return JSON.stringify([{"name":"John Doe","city":"Miami"},
26-
{"name":"Jane Smith","city":"Santa Clara"}])
27-
}
28-
"""
22+
customers: [Customer]
23+
@rest(
24+
endpoint: "stepzen:empty"
25+
ecmascript: """
26+
function transformREST(s) {
27+
return JSON.stringify([{"name":"John Doe","city":"Miami"},
28+
{"name":"Jane Smith","city":"Santa Clara"}])
29+
}
30+
"""
2931
)
30-
}
32+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
schema @sdl(files:[
2-
"api.graphql"
3-
]){query: Query}
1+
schema @sdl(files: ["api.graphql"]) {
2+
query: Query
3+
}

rest/morecomplexpost/api.graphql

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
# Here we create a `postbody` from the query argument
1+
# Here we create a `postbody` from the query argument
22
# using `GetJSON` which will return a JSON item associated
33
# with one of the inputs.
44
# `GetJSON` will return a null value if the city or name was not specified.
55
# `GetJSON` is preferred for an 'Accept' header with an `application/JSON` value.
66
# The syntax is `{{.GetJSON "name-of-the-argument"}}`
7-
#
7+
#
88
# You can also use `Get` which will return a string version
9-
# of the input--where possible--and is well suited for use in
9+
# of the input--where possible--and is well suited for use in
1010
# XML, forms, etc. However, `Get` gets more complicated
1111
# in terms of careful escaping. Wherever possible, use `GetJSON`.
1212

13-
1413
type Root {
1514
args: JSON
1615
data: String
@@ -26,17 +25,17 @@ type Root {
2625
# that uses Go language templates and the custom
2726
# stepzen function "Get" and "GetJSON".
2827
type Query {
29-
restquery(name:String!, city: String!): Root
30-
@rest (endpoint: "https://httpbingo.org/post",
31-
method: POST,
32-
postbody: """
33-
{"record": { "name": {{.GetJSON "name"}},
34-
"city": "{{.GetJSON "city"}}"} }
35-
"""
36-
headers: [
37-
{name: "Accept", value: "application/json"}
38-
{name: "Content-Type", value: "application/json"}
39-
]
28+
restquery(name: String!, city: String!): Root
29+
@rest(
30+
endpoint: "https://httpbingo.org/post"
31+
method: POST
32+
postbody: """
33+
{"record": { "name": {{.GetJSON "name"}},
34+
"city": "{{.GetJSON "city"}}"} }
35+
"""
36+
headers: [
37+
{ name: "Accept", value: "application/json" }
38+
{ name: "Content-Type", value: "application/json" }
39+
]
4040
)
4141
}
42-
Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""
22
Explore an rest API using JSON as the return value as in `restJSONquery` below, then see what the
33
REST API returned in context of how the StepZen services process the request.
4-
4+
55
Try issuing the following with name and/or city removed to see the effects.
66
```
77
curl https://ACCOUNTNAME.stepzen.net/api/miscellaneous/__graphql \
88
--header "Authorization: Apikey $(stepzen whoami --apikey)" \
99
--header "Content-Type: application/json" \
10-
--data '{"query": "{restJSONquery(name: \"Joe Smith\" city:\"New York\")}"}'
10+
--data '{"query": "{restJSONquery(name: \"Joe Smith\" city:\"New York\")}"}'
1111
```
1212
1313
StepZen services return diagnostics in the GraphQL response
@@ -17,21 +17,22 @@ curl https://ACCOUNTNAME.stepzen.net/api/miscellaneous/__graphql \
1717
--header "Authorization: Apikey $(stepzen whoami --adminkey)" \
1818
--header "Content-Type: application/json" \
1919
--header "StepZen-Debug-Level: 1" \
20-
--data '{"query": "{restJSONquery(name: \"Joe Smith\" city:\"New York\")}"}'
20+
--data '{"query": "{restJSONquery(name: \"Joe Smith\" city:\"New York\")}"}'
2121
```
2222
"""
2323
type Query {
24-
# Set a JSON query return type to avoid any type conflicts that you might have during testing.
25-
# You cannot subselect fields this way.
26-
restJSONquery(name:String, city: String): JSON
27-
@rest (endpoint: "https://httpbingo.org/post",
28-
method: POST,
29-
postbody: """
30-
{"record": { "name": {{.GetJSON "name"}}, "city": {{.GetJSON "city"}}} }
31-
"""
32-
headers: [
33-
{name: "Accept", value: "application/json"}
34-
{name: "Content-Type", value: "application/json"}
35-
],
24+
# Set a JSON query return type to avoid any type conflicts that you might have during testing.
25+
# You cannot subselect fields this way.
26+
restJSONquery(name: String, city: String): JSON
27+
@rest(
28+
endpoint: "https://httpbingo.org/post"
29+
method: POST
30+
postbody: """
31+
{"record": { "name": {{.GetJSON "name"}}, "city": {{.GetJSON "city"}}} }
32+
"""
33+
headers: [
34+
{ name: "Accept", value: "application/json" }
35+
{ name: "Content-Type", value: "application/json" }
36+
]
3637
)
37-
}
38+
}

rest/postbody/api.graphql

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type Root {
1313

1414
"""
1515
Since we used `application/x-www-form-urlencoded` as a value for our `Content-Type` header, StepZen will
16-
encode the postbody as form-encoded and the httpbingo.org/post will return
16+
encode the postbody as form-encoded and the httpbingo.org/post will return
1717
it in form. You'll see that `args` and `data` will be empty, and `json` will be null, when you run the following query.
1818
query MyQuery {
1919
restquery(name: "Joe Smith", city: "New York") {
@@ -26,21 +26,22 @@ query MyQuery {
2626
}
2727
"""
2828
type Query {
29-
restquery(name:String, city: String): Root
29+
restquery(name: String, city: String): Root
3030
# Set a JSON query return type to avoid any type conflicts that you might have during testing.
3131
# You cannot subselect fields this way.
3232
# restquery(name:String, city: String): JSON
33-
@rest (endpoint: "https://httpbingo.org/post",
34-
method: POST,
35-
headers: [{name: "Accept", value:"application/json"},
36-
{name: "Content-Type", value: "application/x-www-form-urlencoded"}],
37-
33+
@rest(
34+
endpoint: "https://httpbingo.org/post"
35+
method: POST
36+
headers: [
37+
{ name: "Accept", value: "application/json" }
38+
{ name: "Content-Type", value: "application/x-www-form-urlencoded" }
39+
]
3840
)
3941
}
4042

41-
4243
"""
43-
When the 'Accept' header is `application/json`, StepZen will automatically populate the body.
44+
When the 'Accept' header is `application/json`, StepZen will automatically populate the body.
4445
Note: if method POST is used, The default for `Content-Type` is `application/json`.
4546
4647
Using the sample GraphQL query, data will show the contents of the postbody and json as transformed to JSON.
@@ -57,14 +58,14 @@ query MyQuery {
5758
}
5859
}
5960
"""
60-
6161
type Query {
62-
restjsonbodyquery(name:String, city: String): Root
62+
restjsonbodyquery(name: String, city: String): Root
6363
# Set a JSON query return type to avoid any type conflicts that you might have during testing.
6464
# You cannot subselect fields this way.
6565
# restjsonbodyquery(name:String, city: String): JSON
66-
@rest (endpoint: "https://httpbingo.org/post",
67-
method: POST,
68-
headers: [{name: "Accept", value:"application/json"}]
66+
@rest(
67+
endpoint: "https://httpbingo.org/post"
68+
method: POST
69+
headers: [{ name: "Accept", value: "application/json" }]
6970
)
70-
}
71+
}

rest/postbody/index.graphql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
schema @sdl(files:[
2-
"api.graphql"
3-
]){query: Query}
1+
schema @sdl(files: ["api.graphql"]) {
2+
query: Query
3+
}

0 commit comments

Comments
 (0)