0

I'm using graphql-codegen with apollo to consume graphql api from typescript. Right now I have to duplicate a lot of graphql operations exactly 1:1 to have some code generated. Example:

mutation CreateAccount($name: String!, $email: String!, $password: String!) {
  signUp(name: $name, email: $email, password: $password, initialAdminAccount: $initialAdminAccount) {
    ...UserProfile
  }
}

So is it possible to somehow invoke signUp directly instead of wrapping it in custom mutation? I know graphql requires me to specify fields I want in return but codegen could automatically put all known fields there.

Krever
  • 1,371
  • 1
  • 13
  • 32

1 Answers1

0

Codegen is not doing that. Mostly because it can't guess what fields, nesting level and arguments. GraphQL is all about specifying your selection set and optimize your data fetching. If you just want to pull everything, you can write your own tool to build selectio-sets according to your needs. Or, well, use a different API framework...

Dotan Simha
  • 742
  • 1
  • 5
  • 12