Introducing GraphQL Generator build plugin

The GraphQLSwift organization is excited to release graphql-generator, a build plugin package that generates server-side GraphQL API code from GraphQL schema files, inspired by GraphQL Tools' makeExecutableSchema and Swift's OpenAPI Generator!

The goal is to simplify using Swift as a backend language for GraphQL. The standard GraphQL package is based on the JavaScript reference implementation and doesn’t take advantage of Swift’s type system, which can make using it error prone and awkward. The answer historically has been to use Graphiti, which provides a type-safe DSL for building GraphQL schemas in Swift. This works great for pure Swift projects, but can sometimes make it difficult to interoperate in the wider GraphQL ecosystem, where many tools are based on GraphQL schema definition documents. The new graphql-generator package offers a schema-first approach by ingesting a schema definition file directly and generating the required code stubs. This guarantees conformance to the GraphQL schema definition while still making full use of Swift’s type system.

Check out the graphql-generator repo to find a “Getting Started” introduction, documentation, and full working examples. We’d love to hear your feedback!

7 Likes