Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Elm
  3. elm-graphql

elm-graphql

BSD-3-ClauseElm

Autogenerate type-safe Elm code from any GraphQL schema for guaranteed valid queries and seamless decoders.

Visit WebsiteGitHubGitHub
788 stars107 forks0 contributors

What is elm-graphql?

dillonkearns/elm-graphql is a tool that autogenerates type-safe Elm code from a GraphQL schema. It allows developers to write GraphQL queries in Elm that are guaranteed to be valid at compile time and automatically handles JSON decoding for API responses. This solves the problem of manual decoder writing and runtime errors when interacting with GraphQL APIs.

Target Audience

Elm developers building frontend applications that consume GraphQL APIs, particularly those who value type safety and want to eliminate runtime errors in their data fetching logic.

Value Proposition

Developers choose elm-graphql because it is the only Elm GraphQL library that provides full type safety across the entire schema, generates decoders automatically, and integrates GraphQL concepts naturally into Elm's functional paradigm. Its compile-time guarantees reduce bugs and improve developer confidence.

Overview

Autogenerate type-safe GraphQL queries in Elm.

Use Cases

Best For

  • Building Elm frontends with type-safe GraphQL API integration
  • Eliminating manual JSON decoder writing for GraphQL responses
  • Ensuring GraphQL query validity at compile time in Elm projects
  • Creating real-time applications using GraphQL Subscriptions in Elm
  • Teams adopting GraphQL who want strong static typing in their Elm codebase
  • Converting GraphQL schemas into reusable, composable Elm modules

Not Ideal For

  • Projects that require dynamic GraphQL query construction at runtime based on user input
  • Teams unwilling to integrate a Node.js CLI tool and code generation step into their build process
  • Applications needing GraphQL Subscriptions with zero manual JavaScript or WebSocket configuration

Pros & Cons

Pros

Compile-Time Query Validation

Generates Elm code that ensures all GraphQL queries are valid according to the schema at compile time, eliminating runtime errors from malformed queries as emphasized in the README.

Automatic JSON Decoders

Seamlessly creates decoders for API responses without manual coding, reducing boilerplate and potential bugs, as demonstrated in the example code snippets.

Native Elm Constructs

Replaces GraphQL variables and fragments with standard Elm functions and constants, providing a simpler, more idiomatic developer experience within Elm's functional paradigm.

Subscriptions Code Generation

Generates ready-to-use Elm code for GraphQL Subscriptions, facilitating real-time updates when combined with WebSocket ports, as shown in the live demo and examples.

Cons

Manual Subscription Wiring

Requires custom JavaScript code and Elm ports to handle WebSocket connections for subscriptions, as the library does not manage low-level transport details, adding complexity.

Code Generation Overhead

Adds a build step with the CLI tool that must be run whenever the GraphQL schema changes, increasing setup and maintenance effort compared to runtime GraphQL clients.

Static Query Building

Queries are constructed statically in Elm code, making it difficult to dynamically generate or modify queries at runtime, which can limit flexibility for interactive applications.

Frequently Asked Questions

Quick Stats

Stars788
Forks107
Contributors0
Open Issues19
Last commit8 months ago
CreatedSince 2017

Tags

#elm-package#schema-first#static-typing#graphql#api-client#type-safe#elm#json-decoder#code-generation

Built With

E
Elm
N
Node.js
n
npm

Links & Resources

Website

Included in

GraphQL15.0kElm3.7k
Auto-fetched 1 day ago

Related Projects

OpenApi GeneratorOpenApi Generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)

Stars26,816
Forks7,726
Last commit1 day ago
QuicktypeQuicktype

Generate types and converters from JSON, Schema, and GraphQL

Stars13,893
Forks1,194
Last commit1 day ago
Elm TypeScript InteropElm TypeScript Interop

Generate TypeScript declaration files for your elm ports!

Stars165
Forks12
Last commit5 years ago
Elm CodeGenElm CodeGen

Elm CodeGen is a tool designed to simplify the process of generating Elm code programmatically. It provides a structured API and CLI to create maintainable code generators, replacing error-prone string templates. ## Key Features - **Automatic Imports** — Import declarations are automatically calculated based on the generated code. - **Built-in Type Inference** — Types for generated code are inferred, allowing generated functions and values to determine their own type signatures. - **Package Integration** — The CLI can generate helper code for using existing Elm packages (like elm-ui) within generators. - **Elm and CLI Support** — Available both as an Elm package for writing generators in Elm and as a CLI tool for running them. ## Philosophy Elm CodeGen aims to make code generation easier to write and more maintainable than manual string concatenation, leveraging Elm's type system for reliability.

Stars144
Forks18
Last commit6 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub