Generate sub types for graphql-codegen

Viewed 43

I'm using the typescript-operations from graphql-codegen library. But I'm coming from the Apollo deprecated codegen and was loving how they exported types.

for a query like this

query MyData {
  viewer {
    id
    username
  }
}

I would get this from the apollo-tooling codegen:

export type MyDataQuery_viewer = {
  __typename: 'Viewer';
  id: number;
  username: string;
}
export type MyDataQuery = {
  __typename: 'Query',
  viewer?: MyDataQuery_viewer;
}

but in graphql-codegen I'm getting this instead:

export type MyDataQuery = {
  __typename: 'Query',
  viewer?: {
    __typename: 'Viewer';
    id: number;
    username: string;
  };
}

Does there exist any configuration to graphql-codegen that would give me a type of all nested objects instead of having everything defined in a single type?

0 Answers
Related