This is a step by step instructions on how to add GraphQL API of Finnish public transportation information to a Swift project in Xcode. This is mostly for my own future reference and collected from more verbose post in Medium Using GraphQL in iOS with Swift - Better Programming - Medium.
(as of writing instructions are valid for Swift 5.1 and Xcode 11)
Install apollo npm toolchain for generating the schema file npm install -g npm
Nothing special here.
All in detail at Apollo documentation Installation - Client (iOS) - Apollo GraphQL Docs
Run the apollo tool you installed in step 0 to generate the schema.json to be used for generating the datatypes
apollo schema:download –endpoint=api.digitransit.fi/routing/v…
Nothing weird here
As documented here: Installation - Client (iOS) - Apollo GraphQL Docs
Next step is to add .graphql file to your project. Digitransit has an excellent documentation and a sandbox for trying things out
Digitransit documentation for stop arrival information Stops | Digitransit has convenient links to sandbox for testing the API out
Finally, one runs the build to generate the API.swift file that contains the types of the queries you created. Everytime you add a new type, rerun the build to generate new API.swift