Raw response type of `@semanticNonNull` field is different when selected in a type refinement with `@throwOnFieldError`
- Dominant language
- Rust
- Stars
- 19k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
Consider the following schema:
```graphql
type Query {
blogPageBySlug(slug: String!): BlogPage
node(id: ID!): Node
}
type BlogPage implements Node {
id: ID!
title: String @semanticNonNull
}
interface Node {
id: ID!
}
```
And the following query:
```graphql
query somethingSomethingQuery
@throwOnFieldError
@raw_response_type {
node(id: "test-id") {
... on BlogPage {
title
}
}
blogPageBySlug(slug: "test-slug") {
title
}
}
```
Those would currently generate this raw response type:
```typescript
export type somethingSomethingQuery$rawResponse = {
readonly blogPageBySlug: {
readonly id: string;
readonly title: string;
} | null | undefined;
readonly node: {
readonly __typename: "BlogPage";
readonly id: string;
readonly title: string | null | undefined;
} | {
readonly __typename: string;
readonly id: string;
} | null | undefined;
};
```
It seems like the `@throwOnFieldError` isn't properly considered in the case of a type refinement on a field returning an abstract type, since the `title` is typed as nullable below the `node` field and non-null on the field directly returning the object type.
We use `@raw_response_type` a lot to write typed mocked data for component demos and tests, so this makes it a lot harder to write accurate mock data for our developers.
Contributor guide
Assessment
This issue has not been assessed yet.