jcward / haxe-graphql

Utilities for working with Haxe and GraphQL.
MIT License
23 stars 6 forks source link

GQL union to Haxe enum with fragment support #46

Open skilgoreT opened 1 month ago

skilgoreT commented 1 month ago

Issue #43 introduced support of mapping GQL union types to Haxe algebraic enum. This issue is tracking adding support for __typename type queries in the presence of fragments in named operations.

This GQL should generate correct code

fragment ContentModuleFragment on ContentModule {
  __typename
  ...on PollModule {
    poll_id
    content_type
  }
  ...on TaskListModule {
    tasklist_id
    content_type
  }
}

type Query
{
  content_module_by_id(id: ID!): ContentModule!
}

query GetContentModuleByIdWithFrag($id: ID!) {
 content_module_by_id(id: $id) {
    ...ContentModuleFragment
  }
}