Skip to content

[near-operation-file] Option to generate files based on operation name, not component name #1280

@eddeee888

Description

@eddeee888

Is your feature request related to a problem? Please describe.

Some tools such as Apollo Tooling generate files based on operation name.

Describe the solution you'd like

To make it easier to migrate from Apollo Tooling to Codegen, we could have an option to generate file name based on operation names.

Examples

// GraphQL Codegen detects gql in a React component:
------- ReactComponent.ts
...
const GET_FOO_QUERY = gql`
  query GetFoo($id: String) {
    ...
  }
`;
...
=========

// BEFORE: the generated filename is always based on the React component's filename:
------- ./__generated__/ReactComponent.ts
...
export type GetFooVariables = ...

export type GetFoo = ...
...
========

// AFTER: add a configuration option so the generated filename is based on the operation name (Query, Mutation, or Fragment):
------- ./__generated__/GetFoo.ts
...
export type GetFooVariables = ...

export type GetFoo = ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions