Skip to content

Union Return Type Support #2

@naderhen

Description

@naderhen

Thanks so much for this library, it's been incredibly helpful for the project I'm building. I was wondering if the following was supported:

schema:

type Mutation {
  unionMethod(body: String): UnionType
}


type FieldError {
  field: String
}

type Errors {
  fieldErrors: [FieldError]
}

type MutationResponse {
  ok: Boolean
}

union UnionType = Errors | MutationResponse

documents:

mutation unionMethod {
  unionMethod(body: "test") {
    ...on Errors {
      fieldErrors {
        field
      }
    }

    ...on MutationResponse {
      ok
    }
  }
}

Currently, this throws an exception TypeError: Cannot create property 'source' on string 'unhandled GraphQLOutputType in unwrap' which appears to be coming from an unhandled case in https://github.com/bearbytes/apollo-hooks-codegen/blob/master/src/transform.ts#L381 .

Are there plans to support this use case, or suggestions for the best way to handle it moving forward? Happy to provide a PR if you have a sense of what we might need.

Thanks!

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions