Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation to clarify schema download format and filename #2160

Merged
merged 2 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Here's an example file structure:
| - your_project_folder
| your_project.xcodeproj
| - your_target_folder
| schema.json
| schema.json or schema.graphqls
| AppDelegate.swift
| ViewController.swift
| etc...
Expand Down
54 changes: 27 additions & 27 deletions docs/source/swift-scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,22 @@ When you unzip the downloaded repo, you'll see that there's a folder called **`A
If you're using the default target structure for an Xcode project, your project's file structure will look essentially like this in Finder:

```txt:title=Sample%20Project%20Structure
📂 MyProject // Source root
┃ 📄 MyProject.xcodeproj
┣ 📁 MyProject // Contains app target source files
┣ 📁 MyLibraryTarget // Contains lib target source files
┣ 📁 MyProjectTests // Contains test files
MyProject // Source root
├─ MyProject.xcodeproj
├─ MyProject/ // Contains app target source files
├─ MyLibraryTarget/ // Contains lib target source files
├─ MyProjectTests/ // Contains test files
```

Drag the `ApolloCodegen` folder in **at the same level as your other targets** (in Finder, not in Xcode):

```txt:title=Sample%20Project%20Structure
📂 MyProject // Source root
┃ 📄 MyProject.xcodeproj
┣ 📁 MyProject // Contains app target source files
┣ 📁 MyLibraryTarget // Contains lib target source files
┣ 📁 MyProjectTests // Contains test files
┣ 📁 ApolloCodegen // Contains the swift scripting files you just downloaded and dragged in
MyProject // Source root
├─ MyProject.xcodeproj
├─ MyProject/ // Contains app target source files
├─ MyLibraryTarget/ // Contains lib target source files
├─ MyProjectTests/ // Contains test files
├─ ApolloCodegen/ // Contains the swift scripting files you just downloaded and dragged in
```

Double-click `Package.swift` in the `ApolloCodegen` folder to open the executable's package in Xcode.
Expand Down Expand Up @@ -140,13 +140,13 @@ swift run ApolloCodegen downloadSchema
If you're using the template code and following the sample project structure, the schema should download here:

```txt:title=Sample%20Project%20Structure
📂 MyProject // SourceRoot
┃ 📄 MyProject.xcodeproj
┣ 📂 MyProject // Contains app target source files
┃ ┃ 📄 schema.json // <-- downloaded schema
┣ 📁 MyLibraryTarget // Contains lib target source files
┣ 📁 MyProjectTests // Contains test files
┣ 📁 ApolloCodegen // Contains Swift Scripting files
MyProject // SourceRoot
├─ MyProject.xcodeproj
├─ MyProject/ // Contains app target source files
│ └─ schema.graphqls
├─ MyLibraryTarget/ // Contains lib target source files
├─ MyProjectTests/ // Contains test files
├─ ApolloCodegen/ // Contains Swift Scripting files
```

Next, now that you have a schema, you need a GraphQL file with an operation in order to generate code.
Expand All @@ -155,17 +155,17 @@ Next, now that you have a schema, you need a GraphQL file with an operation in o

If you're not familiar with creating an operation in graphQL, please check out the [portion of our tutorial on executing your first query](https://www.apollographql.com/docs/ios/tutorial/tutorial-execute-query/). You can stop after the section about adding your query to Xcode.

Make sure you've added the operation file to the project files, ideally at or above the level of the `schema.json` (Otherwise, you'll need to manually pass the URL of your GraphQL files to your code generation step):
Make sure you've added the operation file to the project files, ideally at or above the level of the `schema.graphqls` (Otherwise, you'll need to manually pass the URL of your operation file to your code generation step):

```txt:title=Sample%20Project%20Structure
📂 MyProject // SourceRoot
┃ 📄 MyProject.xcodeproj
┣ 📂 MyProject // Contains app target source files
┃ ┃ 📄 schema.json
┃ ┃ 📄 LaunchList.graphql
┣ 📁 MyLibraryTarget // Contains lib target source files
┣ 📁 MyProjectTests // Contains test files
┣ 📁 ApolloCodegen // Contains Swift Scripting files
MyProject // SourceRoot
├─ MyProject.xcodeproj
├─ MyProject/ // Contains app target source files
│ ├─ schema.graphqls
│ └─ LaunchList.graphql
├─ MyLibraryTarget/ // Contains lib target source files
├─ MyProjectTests/ // Contains test files
├─ ApolloCodegen/ // Contains Swift Scripting files
```

Here, for example, is what this looks like in a file for one of the queries in our [tutorial application](./tutorial/tutorial-introduction):
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/source/tutorial/tutorial-execute-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Now that your query is fetching the right data, head back to Xcode.

<img src="images/empty_file_template.png" class="screenshot" alt="Empty file template"/>

2. Click **Next** and name the file `LaunchList.graphql`. Make sure it's saved at the same level as your `schema.json` file. As previously, don't add it to any target.
2. Click **Next** and name the file `LaunchList.graphql`. Make sure it's saved at the same level as your `schema.graphqls` file. As previously, don't add it to any target.

3. Copy your final operation from Sandbox Explorer by selecting the three dot (aka "meatball") menu to the right of your operation name and selecting "Copy Operation":

Expand All @@ -107,7 +107,7 @@ You're now ready to generate code from the combination of your saved query and s

2. _Uncomment_ the line you previously commented out (that includes `codegen:generate`).

3. Build your project. When the build completes, an `API.swift` file appears in the same folder as `schema.json`.
3. Build your project. When the build completes, an `API.swift` file appears in the same folder as `schema.graphqls`.

4. Drag the `API.swift` file into Xcode. This time, **do** check the **Add to target** box for the `RocketReserver` app. You include this file in your application's bundle to enable you to execute the query you defined.

Expand Down
10 changes: 3 additions & 7 deletions docs/source/tutorial/tutorial-obtain-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,17 @@ To use the Apollo CLI from Xcode, add a **Run Script** build phase to your app:

<img src="images/rename_run_script.png" alt="UI for renaming" class="screenshot"/>

6. Expand the Apollo phase. Paste the **Swift Package Manager Run Script** from [Add a code generation build step](/installation/#5-add-a-code-generation-build-step) into the text area. This script uses your schema to generate the code that the Apollo iOS SDK uses to interact with your server.
6. Expand the Apollo phase. Paste the **Swift Package Manager Run Script** from [Add a code generation build step](../installation/#5-add-a-code-generation-build-step) into the text area. This script uses your schema to generate the code that the Apollo iOS SDK uses to interact with your server.

7. Before the script can generate code, it needs a local copy of your GraphQL server's schema. For now, using a `#`, **comment out the last line** of the script you pasted and add the following line below it:

```
"${SCRIPT_PATH}"/run-bundled-codegen.sh schema:download --endpoint="https://apollo-fullstack-tutorial.herokuapp.com/graphql"
```

This line runs the Apollo CLI's `schema:download` command, which downloads the schema to a `schema.json` file at the same level of your project as the `AppDelegate.swift` file.
This line runs the Apollo CLI's `schema:download` command, which downloads the schema to a `schema.graphqls` file at the same level of your project as the `AppDelegate.swift` file.

8. Build your project to execute the script. In Finder, navigate to the folder that contains your `AppDelegate.swift` file. The folder should now include the downloaded `schema.json` file. Drag this file from Finder into Xcode:

<img src="images/drag_schema_into_xcode.png" alt="Where to drag the schema file" class="screenshot" width="300"/>

When Xcode offers to add the schema file, make sure **all targets are unchecked** to reduce the size of your application bundle:
8. Build your project to execute the script. In Finder, navigate to the folder that contains your `AppDelegate.swift` file. The folder should now include the downloaded `schema.graphqls` file. Drag this file from Finder into Xcode. When Xcode offers to add the schema file, make sure **all targets are unchecked** to reduce the size of your application bundle:

<img src="images/dont_add_to_target.png" alt="All targets unchecked in dialog" class="screenshot"/>

Expand Down