apollographql / apollographql/apollo-tooling
codegen:generate - queries to local storage
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
Hey!
I have a small question how to generate types for queries that are not in `schema.graphql` because they are local to `InMemoryCache`.
Here is my script that generates types:
```json
{
"apollo:schema": "apollo client:download-schema --endpoint=http://localhost:8080/ schema.graphql",
"apollo:gen": "apollo codegen:generate --localSchemaFile=schema.graphql --target=typescript --includes='src/**' --tagName=gql _types_"
}
```
And I have a request that will be directed to the local storage and it is **naturally** not in the scheme.
```js
export const ADD_PRODUCT_TO_CART = gql`
mutation AddProductToCart($id: String!) {
addToCart(id: $id) @client
}
`
```
And when I try to generate types for **local** requests I get an error (is this probably ok?)
At the moment I only see one solution. Most likely I should separate files with local requests from requests from the `schema.graphql`.
In other words, change `--includes` which will only look at external requests.
Or do you know other ways? ...thank you in advance!
Contributor guide
Research direction
Start with the provided apollo codegen:generate command and its handling of --localSchemaFile, --includes, and the @client directive. Reproduce the error using the AddProductToCart query, then determine whether local-storage queries should be supported or excluded; done requires a documented, agreed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100