Apollo-tooling: Cannot generate types using `--clientSchema` and `--schema`

Created on 16 Jul 2018  路  3Comments  路  Source: apollographql/apollo-tooling


Hi, I am trying to use apollo codegen:generate to produce TypeScript definition files. I have a mixture of server- and client-side schema, and I'm not sure how to use the codegen tool in this case.

I have tried making each schema "standalone", defining schema, Query and Mutation types, but this leads to errors like Type "Query" already exists in the schema. It cannot also be defined in this type definition. (in this case, because Query is in both the client and the server schema).

I have created a minimal repo to illustrate the issue https://github.com/fenech/apollo-cli-example

has-reproduction

Most helpful comment

Hi! When writing a client-side schema that adds additional fields (to the Query type for example), you'll need to use extend type. For example:

extend type Query {
  myClientSideField: String
}

All 3 comments

Hi! When writing a client-side schema that adds additional fields (to the Query type for example), you'll need to use extend type. For example:

extend type Query {
  myClientSideField: String
}

That was the key, thanks! I updated my repo to show it working.

I guess it would be useful to document this, but I'm not sure where...

This took me forever to find, thank you @shadaj .

Was this page helpful?
0 / 5 - 0 ratings