relay icon indicating copy to clipboard operation
relay copied to clipboard

optional field in array is generated as not undefined but nullable

Open shibukazu opened this issue 5 months ago • 0 comments

Hi maintainers,

When I designate optional field in array on graphql like below,

import { graphql } from 'relay-runtime';

export const getDataQuery = graphql`
  query GetDataQuery() {
    data() {
      users {
        id // String!
        name // String
      }
      flag // Boolean
    }
  }
`;

generated type of it is not undefined but nullable.

On the other hand, when I designate optional field not in array, generated type is optional like below.

export type GetDataQuery$data = {
  readonly data: {
    readonly users?: ReadonlyArray<{
      readonly id: string;
      readonly name: string | null;
    }>;
    readonly flag?: boolean;
  };

Is this by design or bug?

shibukazu avatar Jan 20 '24 16:01 shibukazu