GithubHelp home page GithubHelp logo

namek / graphql2elm Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 337 KB

:computer: Generate Elm code based on GraphQL query and schema

Home Page: https://namek.github.io/graphql2elm/

License: MIT License

Kotlin 91.14% HTML 0.26% Elm 8.60%

graphql2elm's Introduction

GraphQL to Elm

Generate Elm code based on GraphQL query and schema. Generated code uses jamesmacaulay/elm-graphql library.

See online web generator. Also see Examples.

Status

Feature list consists of:

  • generate record aliases (type alias) and enums which are used in given query
  • return type of whole query is being shortened to the first field that consists of more than one subfields
  • config: known types - so it won't generate new ones but import the existing ones
  • config: map backend types to front-end types - like Boolean -> Bool between Elixir and Elm
  • config: decoders for known types
  • config: support nullable fields by using Maybe

This stuff is available on web generator.

I have no plans for further development since I found another tool with a more interesting approach. It generates code for a whole GraphQL API + generates a decent API for writing queries. It's https://github.com/dillonkearns/elm-graphql - check it out.

Roadmap (deprecated)

  • field arguments (basics done)
  • input variables (basics done)
  • fragments (?)
  • extend configuration of online web generator for known types

Dev experience

  • Whole parsing + generation logic is implemented with Kotlin. Because it's nice. And it transpiles to JavaScript.
  • Parsing of GraphQL queries is done with custom parser. Previously, I started with ANTLR but decided to try and write parser by hand instead of generating it and I'm actually pretty satisfied with it.
  • Schema is a JSON which comes from a result of GraphQL introspection query (__schema). There's also a parser for it (well, it should be called Interpreter because it's just a JSON).
  • The web generator is done with Elm 0.19 bootstrapped by code written in Kotlin, later transpiled to JS.

Build

Build web generator by calling gradle assembleWeb from the root directory. You'll find the result in build/web.

graphql2elm's People

Contributors

namek avatar

Stargazers

Kuba Wolanin avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.