The Guild LogoThe Guild Monogram

Search docs

Search icon

Products by The Guild


Hive logoHive blurred logo


Schema Registry for your GraphQL Workflows

SwiftGraphQL Logo


GraphQL client and Code Generator.

Get Started

Generating SwiftGraphQL Code#

SwiftGraphQL comes with a ready to use command line utility that lets you generate code from the schema on a remote or local server.

Additionally, the library exports all the tools you need to fine grain the generation process or use it in a Swift Package.

Command Line Utility#

USAGE: swift-graphql <endpoint> [--config <config>] [--output <output>] ARGUMENTS: <endpoint> GraphQL server endpoint. OPTIONS: --config <config> Relative path from CWD to your YML config file. -o, --output <output> Relative path from CWD to the output file. -h, --help Show help information.

To run the generator, type swift-graphql. If you are using any custom scalars, you should create a configuration file called swiftgraphql.yml and put in data-type mappings as a key-value dictionary like this. Keys should be GraphQL types, and values should be SwiftGraphQL Codecs.

scalars: Date: DateTime Upload: Upload

You can also run swift-graphql --help to learn more about options and how it works.

Programatically generating the code#