


apollo extensions to navigate anywhere in your project's file tree. The sourceRoot of your entire repository, which contains both your Xcode project and your Swift Scripting project.įrom sourceRoot you should be able to use FileManager APIs or their.gitignore file, since it's going to contain a ton of JS that can be redownloaded locally very easily, and will otherwise bloat your repo. NOTE: This location should be added to your.
#JAVASCRIPT TO SWIFT CONVERTER CODE#
This is what (currently) does the actual generation of code and fetching of schemas.

apollo extension methods provided by ApolloCodegenLib to find parent or child files and folders. It uses FileFinder to find the directory that the file containing the code lives in, and then you can use either standard FileManager APIs or. This structure exists to simplify accessing your local filesystem without needing to pass any URLs through as environment variables. There are two files: main.swift and FileStructure.swift. This section will walk you through the already-set up code in the template project. Note that these instructions are updated along with newer versions of the library - if you're seeing something that doesn't compile, please check that you're on the most recent version of the SDK both in your app and in your Codegen project. If you're using the default target structure for an Xcode project, your project's file structure will look essentially like this in Finder: When you unzip the downloaded repo, you'll see that there's a folder called ApolloCodgen. You can download the current version of the template from this repo: This allows you to customize while still using Swift as much as possible and bash as little as possible, to preserve both type safety and readability.

This project is provided as a template for an executable rather than a compiled executable to allow you to make changes to the executable relevant to your setup. We've created a template of a Swift Package Manager Executable to speed things along. The rest of this guide will help you set up a Swift Package Manager executable that will live alongside your main xcodeproj and which can be used either from your main xcodeproj or on its own to download a schema, generate code, or both. If all operations are valid, codegen generates Swift code that gives you end-to-end type safety for each operation. If an operation isn't valid, the whole process errors out. A subscription, which allows you to listen for changes to a particular object or type of objectĬode generation takes your operations and compares them to the schema to confirm that they're valid.A mutation, which changes data on the server and then receives updated data back.A query, which is a one-time request for specific data.Each operation you define can be one of the following:
