Skip to content

Commit 990e60b

Browse files
committed
update README
1 parent 47e7aaa commit 990e60b

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

README.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ let schema = try GraphQLSchema(
4747
query: GraphQLObjectType(
4848
name: "RootQueryType",
4949
fields: [
50-
"hello": GraphQLFieldConfig(
50+
"hello": GraphQLField(
5151
type: GraphQLString,
5252
resolve: { _ in "world" }
5353
)
@@ -64,25 +64,47 @@ Then, serve the result of a query against that type schema.
6464
```swift
6565
let query = "{ hello }"
6666
let result = try graphql(schema: schema, request: query)
67-
68-
// Prints
69-
// {"data":{"hello":"world"}}
7067
print(result)
7168
```
7269

70+
Output:
71+
72+
```json
73+
{
74+
"data": {
75+
"hello": "world"
76+
}
77+
}
78+
```
79+
7380
This runs a query fetching the one field defined. The `graphql` function will
7481
first ensure the query is syntactically and semantically valid before executing
7582
it, reporting errors otherwise.
7683

7784
```swift
7885
let query = "{ boyhowdy }"
7986
let result = try graphql(schema: schema, request: query)
80-
81-
// Prints
82-
// {"errors":[{"message":"Cannot query field "boyhowdy" on type "RootQueryType"."}]}
8387
print(result)
8488
```
8589

90+
Output:
91+
92+
```json
93+
{
94+
"errors": [
95+
{
96+
"locations": [
97+
{
98+
"column": 3,
99+
"line": 1
100+
}
101+
],
102+
"message": "Cannot query field \"boyhowdy\" on type \"RootQueryType\"."
103+
}
104+
]
105+
}
106+
```
107+
86108
## License
87109

88110
This project is released under the MIT license. See [LICENSE](LICENSE) for details.

0 commit comments

Comments
 (0)