micimize / major

One of these days I'll stop working on graphql code generation. But unfortunately, today is not that day

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

major_graphql

Unmaintained

I no longer use this project and have not maintained it in a while, thus I am archiving the repo. Anyone is free to fork – contact me if you want publishing permissions for the packages.

major_graphql uses the dart build system and gql to generate built_value classes, primarily for use in client side applications.

Packages

There is also an example major_todo_app which is livecoded on youtube.

Usage

build.yaml:

targets:
  $default:
    builders:
      major_graphql_generator|builder:
        enabled: true
        options:
          schema: major_graphql_example|lib/graphql/schema.graphql

pubspec.yaml:

dependencies:
  major_graphql: ^0.0.3
  # or major_graphql_flutter: ^0.0.1 for flutter

dev_dependencies:
  major_graphql_generator: ^0.0.3
  build_runner: ^1.7.4

dev notes

  • These libraries are highly experimental, and the generator is currently quite slow.
  • custom scalar usage & configuration
  • unions appear to be broken
  • There are currently numerous smaller limitations and caveats
  • irreducibleTypes are types for which selection sets should not be generated. You can supply your own type for them as well by setting generate: false. They are still assumed to be built value types unless they are in the scalars map. Not that you need to refer to them in the config by their graphql type name.
  • replaceTypes renames all references to a given type
  • mixins can be added conditionally:
mixins:
  - name: Entity
    when:
      fields:
      - entityId
      - validFrom
      - validUntil
      # disable mixin for these classes
      nameNot:
        - MySpecialEntity
        - MyOtherSpecialEntity
  • userland code can be injected via imports and exports (and needs to be to use scalars and mixins):
schema:
  path: savvy_app|lib/graphql/schema.graphql
  imports:
    - package:savvy_app/graphql/base.dart
    - package:built_value/json_object.dart
  exports:
    - package:savvy_app/graphql/base.dart
    - package:built_value/json_object.dart

About

One of these days I'll stop working on graphql code generation. But unfortunately, today is not that day


Languages

Language:Dart 96.4%Language:Ruby 1.8%Language:HTML 0.7%Language:Shell 0.4%Language:Objective-C 0.3%Language:Swift 0.2%Language:Java 0.2%Language:Kotlin 0.1%