99designs / 99designs/gqlgen

Query on polymorphic types

Open
#2,444 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
10.8k
Forks
1.3k
Avg merge
2d 36m
Merged PRs (30d)
26

Description

Hi, I have a situation like this:

```
type Query {
GetData: AbstractDataResponse
}

type AbstractDataResponse {
field1: String!
field2: String!
}

type DataResponseTypeA implements AbstractDataResponse {
field3a: String!
}

type DataResponseTypeB implements AbstractDataResponse {
field3:b String!
}
```

I run a query by:

```
{
GetData {
field3a
}
}
```

The resolver, in such situation, returns an instance of `DataResponseTypeA`.

I get the error:

```
Validation error (FieldUndefined@[GetData/field3a]) : Field 'field3a' in type 'AbstractDataResponse' is undefined
```

How could I fix it?

Thank you so much!
Antonio

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.