Skip to content

Generate one file per .graphql file #468

@TLadd

Description

@TLadd

Specifically interesting in the flow/typescript targets, but may make sense for the other targets as well. Currently when using apollo codegen:generate, I can either output types to a single file/directory by specifying an output path, or I can use the default behavior where it generates a file per-operation next to the queries.graphql file.

While I like having the generated types next to the queries file, I would prefer all of the types generated from a queries.graphql file going into a single file rather than having one file per-operation. The main reason is just standardization and to reduce file clutter. When looking at a directory, I know that my queries are defined in queries.graphql, and my types for those queries are defined in queryTypes.js/ts (or whatever the default filename would be for this use case)

So given a queries.graphql file like

query GetList(
  $first: Int!
  $after: String
) {
  list(
    first: $first
    after: $after
  ) {
    pageInfo {
      totalCount
    }
  }
}

mutation DeleteItem($input: DeleteItemInput!) {
  deleteItem(input: $input) {
    success
  }
} 

I would like a way for apollo codegen:generate to output a single queryTypes.js/ts in the same directory as queries.graphql with types for both the GetList query and the DeleteItem mutation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🎉 featureNew addition or enhancement to existing solutions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions