Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codegen does not automatically append "Query" or "Mutation" to the generated type #1366

Open
faahmad opened this issue Jun 27, 2019 · 1 comment
Labels
🤖 component - codegen related to the codegen core packages

Comments

@faahmad
Copy link

faahmad commented Jun 27, 2019

Hi 👋

In the docs, I came across this section:

Given this query:

query Characters {
  characters(episode: NEW_HOPE) {
    name
    ... on Human {
      homePlanet
    }
    ... on Droid {
      primaryFunction
    }
  }
}

Apollo Codegen will generate a union type for Character.

export type CharactersQuery = {
  characters: Array<
    | {
        __typename: "Human",
        name: string,
        homePlanet: ?string
      }
    | {
        __typename: "Droid",
        name: string,
        primaryFunction: ?string
      }
  >
};

When I run this command, I do not get "Query" or "Mutation" appended to the generated type. Instead mine is just type Characters. Can I solve this without having to rename all my queries and mutations?

What am I doing wrong? Do I need to configure something? Or does my schema.json file need to have a certain key? Any help would be appreciated!

@JakeDawkins JakeDawkins added the 🤖 component - codegen related to the codegen core packages label Jul 9, 2019
@ignacioureta
Copy link

I think this is probably due to a bug or either a change on specs that wasn't transfered to the docs.

Either way, I'd like to use this so that I can differentiate between the query/mutation types and the other interfaces that codegen generates. Can I submit a PR for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 component - codegen related to the codegen core packages
Projects
None yet
Development

No branches or pull requests

3 participants