Swiftpack.co - Package - highmobility/vss-graphql-client-swift

VSS GraphQL Client


NOTE: Currently works on iOS and macOS only.

Enables automatic decoding of VSS GraphQL query, by serializing the response into pre-defined types.
It's based on AutoGraph with a tiny wrapper and generated VSS types.


Example of a query composed and sent to VSS GraphQL endpoint:

let operation = VSSGraphQLOperation.vehicleQuery(selectionSet: [
    Object(name: "drivetrain", selectionSet: [
        Object(name: "batteryManagement", selectionSet: [
            Scalar(name: "batteryCapacity"),
            Scalar(name: "chargingInlet"),
            Scalar(name: "netCapacity")

let request = VSSGraphQLRequest<Vehicle>(operation: operation, rootKeyPath: "data.vehicle")
let url = URL(string: "http://localhost:4000")!

request.send(url: url) { result in



To compile the client from terminal, please follow the steps:

  1. navigate to the repository's directory
  2. execute swift build VSSGraphQLClient


To compile the client from Xcode, please follow the steps:

  1. open VSSGraphQL.xcodeproj
  2. choose VSSGraphQLClient as the active target (from top left) with the desired target platform
  3. run the project to compile the lib

Swift Package Manager

This is the recommended way to use the Client.

In order to use the Client as a dependency with SPM, there are 2 options:

  1. navigate to the root directory of your swift project
  2. open Package.swift
  3. add .package(url: "git@github.com:highmobility/vss-graphql-client-swift.git", .upToNextMinor(from: "M.m.p")), to dependencies
  4. add VSSGraphQL to your target's dependencies

or the dependency can be added in Xcode:

  1. open your Xcode project
  2. open your "master" project from the left navigation area
  3. choose your project above the targets (to edit the project settings)
  4. select Swift Packages from the top-center
  5. click the + button
  6. add git@github.com:highmobility/vss-graphql-client-swift.git as the package repository URL
  7. choose your version rules
  8. add the Client lib to your desired target


NOTE: Currently works on macOS only.

Code generator can be run from terminal or Xcode.

The program expects 2 arguments:

  • -i, --input -- path to the VSS GraphQL schema file
    • there's one included in the repo at Sources/CodeGenerator/Schema/vehicle.ts
  • -o, --output -- path to the models output folder
    • it's recommended to set it to Sources/Client/Models


To run the generator from terminal, please follow the steps:

  1. navigate to the directory of the executable
    • an executable can be created beforehand with Xcode or swift build
  2. execute {executable_path} -i {schema_path} -o {output_path}

or simply:

  1. navigate to repo's root directory
  2. execute swift run CodeGenerator -i Sources/CodeGenerator/Schema/vehicle.ts -o Sources/Client/Models


note: Xcode options might require absolute paths as input.

To run the generator from Xcode, there are 2 options, either:

  1. open VSSGraphQL.xcodeproj
  2. click Edit Scheme... from the target-selection menu from top left
  3. choose CodeGenerator as the target
  4. navigate to Run > Arguments
  5. add the 2 required arguments to Arguments Passed on Launch
    • schema file path as -i {schema_path}
    • output folder path as -o {output_path}


  1. open VSSGraphQL.xcodeproj
  2. navigate to Sources/CodeGenerator/main.swift
  3. on L34 replace the inputArg and outputArg with desired values
  4. comment out L23-26


NOTE: Currently works on macOS only.

Demo can be run against a known endpoint or a local server.
Configuration of the requested values (data points) can be done in Sources/Demo/main.swift.

Known endpoint

To run the demo against a working VSS GraphQL endpoint, please follow these steps:

  1. open VSSGraphQL.xcodeproj
  2. configure the URL at Sources/Demo/main.swift:L14
  3. choose Demo as the target from top left and run it

Local server

To run the demo against a local VSS GraphQL server, please follow these steps:

  1. get the VSS data server from GENIVI/vss-graphql
  2. follow a setup to run the VSS data server locally
  3. open VSSGraphQL.xcodeproj
  4. choose Demo as the target from top left and run it

or after step 2, execute swift run Demo in repo's root dir in terminal.


Stars: 0


Used By

Total: 0