Swiftpack.co - dashxhq/dashx-ios as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by dashxhq.
dashxhq/dashx-ios 1.0.4
DashX SDK for iOS
⭐️ 0
🕓 2 days ago
.package(url: "https://github.com/dashxhq/dashx-ios.git", from: "1.0.4")

iOS Native Module


Obtaining Graphql schema and generating Graphql operation

  • Make sure to install Apollo CLI via npm:
$ npm i -g apollo
  • In order to generate code, Apollo requires local copy of Graphql schema, to download that:
$ apollo schema:download --endpoint="https://api.dashx.com/graphql" schema.json

This will save a schama.json file in your ios directory.

  • Add Graphql request in graphql dir.

  • Regenerate API.swift using:

$ apollo client:codegen --target=swift --namespace=DashXGql --localSchemaFile=schema.json --includes="graphql/*.graphql" --passthroughCustomScalars API.swift

For example, if you want to generate code for FetchContent.

  • Download schema
$ apollo schema:download --endpoint="https://api.dashx.com/graphql" schema.json
  • Add request in graphql dir with following contents:
query FetchContent($input: FetchContentInput!) {
  fetchContent(input: $input)
  • Re-generate API.swift so it includes the FetchContent operation
$ apollo client:codegen --target=swift --namespace=DashXGql --localSchemaFile=schema.json --includes="graphql/*.graphql" --passthroughCustomScalars API.swift
  • Now you can use FetchContent operation like so:
let fetchContentInput  = DashXGql.FetchContentInput( // Note the DashXGql namespace
    contentType: contentType,
    content: content,
    preview: preview,
    language: language,
    fields: fields,
    include: include,
    exclude: exclude

DashXLog.d(tag: #function, "Calling fetchContent with \(fetchContentInput)")

let fetchContentQuery = DashXGql.FetchContentQuery(input: fetchContentInput)

Network.shared.apollo.fetch(query: fetchContentQuery, cachePolicy: .returnCacheDataElseFetch) { result in
  switch result {
  case .success(let graphQLResult):
    DashXLog.d(tag: #function, "Sent fetchContent with \(String(describing: graphQLResult))")
    let content = graphQLResult.data?.fetchContent
  case .failure(let error):
    DashXLog.d(tag: #function, "Encountered an error during fetchContent(): \(error)")
    reject("", error.localizedDescription, error)


  1. Bump up the version number in DashX.podspec
  2. Commit the version bump: Bump version to x.x.x
  3. Create a tag: git tag 'x.x.x'
  4. Push the tag: git push origin --tags

The GitHub Workflow will take care of the rest.


Stars: 0
Last commit: 2 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics