@@ -20,15 +20,15 @@ Install or add following line to your dependencies:
20
20
21
21
** Make sure that ` GraphQLAPIKit ` is added as a package dependency to your project**
22
22
23
- #### 1. Create ` GraphQLAPI ` folder at your ` ProjectName.xcodeproj ` level
23
+ #### 1. Create ` GraphQLGenerated ` folder at your ` ProjectName.xcodeproj ` level
24
24
25
25
#### 2. Add Apollo configuration file
26
26
27
- Add ` apollo-codegen-config.json ` file and add it to ` GraphQLAPI ` folder.
27
+ Add ` apollo-codegen-config.json ` file and add it to ` GraphQLGenerated ` folder.
28
28
Copy and paste json configuration to the newly created file:
29
29
``` json
30
30
{
31
- "schemaName" : " GraphQLAPI " ,
31
+ "schemaName" : " GraphQLGenerated " ,
32
32
"input" : {
33
33
"operationSearchPaths" : [
34
34
" **/*.graphql"
@@ -49,17 +49,17 @@ Copy and paste json configuration to the newly created file:
49
49
},
50
50
"testMocks" : {
51
51
"swiftPackage" : {
52
- "targetName" : " GraphQLAPIMocks "
52
+ "targetName" : " GraphQLGeneratedMocks "
53
53
}
54
54
}
55
55
}
56
56
}
57
57
```
58
58
#### 3. Add schema file
59
- Add GraphQL JSON schema to the ` GraphQLAPI ` folder and name it ` schema.json ` .
59
+ Add GraphQL JSON schema to the ` GraphQLGenerated ` folder and name it ` schema.json ` .
60
60
61
61
#### 4. Add Queries And Mutations Folders
62
- Add ` Queries ` and ` Mutations ` folders to ` GraphQLAPI ` folder.
62
+ Add ` Queries ` and ` Mutations ` folders to ` GraphQLGenerated ` folder.
63
63
64
64
#### 5. Define Your first GraphQL Query Or Mutation
65
65
Add your first Query or Mutation and save it with ` .graphql ` extension to ` Queries ` or ` Mutations ` folders.
@@ -72,43 +72,43 @@ Add script:
72
72
SDKROOT=$( /usr/bin/xcrun --sdk macosx --show-sdk-path)
73
73
SWIFT_PACKAGES=" ${BUILD_DIR%/ Build/* } /SourcePackages/checkouts"
74
74
75
- ${SWIFT_PACKAGES} /GraphQLAPIKit/Resources/apollo-ios-cli generate --path ./GraphQLAPI /apollo-codegen-config.json
75
+ ${SWIFT_PACKAGES} /GraphQLAPIKit/Resources/apollo-ios-cli generate --path ./GraphQLGenerated /apollo-codegen-config.json
76
76
```
77
77
78
78
#### 7. Disable User Script Sandboxing
79
79
Go to your application main target's Build Settings and set ` User Script Sandboxing ` to ` NO `
80
80
81
81
#### 8. Build your main target
82
82
83
- #### 9. Add GraphQLAPI local package
83
+ #### 9. Add GraphQLGenerated local package
84
84
- Go to Xcode -> File -> Add Package Dependencies..
85
85
- Choose ` Add Local... `
86
- - Add ` GraphQLAPI ` as local Swift Package.
87
- Make sure, that ` GraphQLAPI ` library was added to your main's target ` Frameworks, Libraries, and Embedded Content ` list.
88
- For your project's test target add ` GraphQLAPIMocks ` library if necessary.
86
+ - Add ` GraphQLGenerated ` as local Swift Package.
87
+ Make sure, that ` GraphQLGenerated ` library was added to your main's target ` Frameworks, Libraries, and Embedded Content ` list.
88
+ For your project's test target add ` GraphQLGeneratedMocks ` library if necessary.
89
89
90
90
#### 10. Update ` .gitignore ` file
91
91
Add ` *.graphql.swift ` to your repository's git ignore file to ignore Apollo generated code.
92
92
93
93
** Content of generated ` Schema ` folder has to be commited to the repository**
94
94
95
- #### 11. Exclude ` GraphQLAPI ` folder from your linter's rule if necessary
95
+ #### 11. Exclude ` GraphQLGenerated ` folder from your linter's rule if necessary
96
96
97
97
## Usage
98
98
99
99
### Defining Query or Mutation
100
100
``` swift
101
- import GraphQLAPI
102
101
import GraphQLAPIKit
102
+ import GraphQLGenerated
103
103
104
104
let query = MyExampleQuery ()
105
105
let mutation = MyExampleMutation ()
106
106
```
107
107
108
108
### Fetching the query/perform mutation
109
109
``` swift
110
- import GraphQLAPI
111
110
import GraphQLAPIKit
111
+ import GraphQLGenerated
112
112
113
113
let apiAdapter = GraphQLAPIAdapter (url : URL (string : " https://MyAPIUrl.com" )! )
114
114
let queryResult = await apiAdapter.fetch (query : query)
0 commit comments