Skip to content

Commit cba343a

Browse files
committed
Update README.md
1 parent 2fbbb56 commit cba343a

File tree

1 file changed

+2
-121
lines changed

1 file changed

+2
-121
lines changed

README.md

Lines changed: 2 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -13,135 +13,16 @@ Looking for help? Find resources [from the community](http://graphql.org/communi
1313

1414
## Graphiti
1515

16-
This repo contains the core GraphQL implementation. For a better experience when creating your types use [Graphiti](https://github.com/GraphQLSwift/Graphiti).
16+
This repo only contains the core GraphQL implementation. For a better experience when creating your types use [Graphiti](https://github.com/GraphQLSwift/Graphiti).
1717

1818
**Graphiti** is a Swift library for building GraphQL schemas/types fast, safely and easily.
1919

2020

21-
## Getting Started
22-
23-
An overview of GraphQL in general is available in the
24-
[README](https://github.com/facebook/graphql/blob/master/README.md) for the
25-
[Specification for GraphQL](https://github.com/facebook/graphql). That overview
26-
describes a simple set of GraphQL examples that exist as [tests](Tests/GraphQLTests/StarWarsTests/)
27-
in this repository. A good way to get started with this repository is to walk
28-
through that README and the corresponding tests in parallel.
29-
30-
### Using GraphQL
31-
32-
Add GraphQL to your `Package.swift`
33-
34-
```swift
35-
// swift-tools-version:4.0
36-
import PackageDescription
37-
38-
let package = Package(
39-
dependencies: [
40-
.package(url: "https://github.com/GraphQLSwift/GraphQL.git", from: "0.10.0"),
41-
]
42-
)
43-
```
44-
45-
GraphQL provides two important capabilities: building a type schema, and
46-
serving queries against that type schema.
47-
48-
First, build a GraphQL type schema which maps to your code base.
49-
50-
```swift
51-
import GraphQL
52-
53-
let schema = try GraphQLSchema(
54-
query: GraphQLObjectType(
55-
name: "RootQueryType",
56-
fields: [
57-
"hello": GraphQLField(
58-
type: GraphQLString,
59-
resolve: { _, _, _, _ in
60-
"world"
61-
}
62-
)
63-
]
64-
)
65-
)
66-
```
67-
68-
This defines a simple schema with one type and one field, that resolves
69-
to a fixed value. More complex examples are included in the [Tests](Tests/GraphQLTests/) directory.
70-
71-
Then, serve the result of a query against that type schema.
72-
73-
```swift
74-
let query = "{ hello }"
75-
let result = try graphql(schema: schema, request: query)
76-
print(result)
77-
```
78-
79-
Output:
80-
81-
```json
82-
{
83-
"data": {
84-
"hello": "world"
85-
}
86-
}
87-
```
88-
89-
This runs a query fetching the one field defined. The `graphql` function will
90-
first ensure the query is syntactically and semantically valid before executing
91-
it, reporting errors otherwise.
92-
93-
```swift
94-
let query = "{ boyhowdy }"
95-
let result = try graphql(schema: schema, request: query)
96-
print(result)
97-
```
98-
99-
Output:
100-
101-
```json
102-
{
103-
"errors": [
104-
{
105-
"locations": [
106-
{
107-
"line": 1,
108-
"column": 3
109-
}
110-
],
111-
"message": "Cannot query field \"boyhowdy\" on type \"RootQueryType\"."
112-
}
113-
]
114-
}
115-
```
116-
117-
### Field Execution Strategies
118-
119-
Depending on your needs you can alter the field execution strategies used for field value resolution.
120-
121-
By default the `SerialFieldExecutionStrategy` is used for all operation types (`query`, `mutation`, `subscription`).
122-
123-
To use a different strategy simply provide it to the `graphql` function:
124-
125-
```swift
126-
try graphql(
127-
queryStrategy: ConcurrentDispatchFieldExecutionStrategy(),
128-
schema: schema,
129-
request: query
130-
)
131-
```
132-
133-
The following strategies are available:
134-
135-
* `SerialFieldExecutionStrategy`
136-
* `ConcurrentDispatchFieldExecutionStrategy`
137-
138-
**Please note:** Not all strategies are applicable for all operation types.
139-
14021
## License
14122

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

144-
[swift-badge]: https://img.shields.io/badge/Swift-4-orange.svg?style=flat
25+
[swift-badge]: https://img.shields.io/badge/Swift-5.1-orange.svg?style=flat
14526
[swift-url]: https://swift.org
14627
[mit-badge]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat
14728
[mit-url]: https://tldrlegal.com/license/mit-license

0 commit comments

Comments
 (0)