apollographql / apollographql/apollo-tooling
how to ignore @rest directives from apollo codegen
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
Need help or want to talk all things Apollo Tooling? Issues here are reserved for bugs or feature requests, but you ask for help in our Spectrum community:
I'm using `@rest` directive to request some data from REST API, but when I use the command `apollo client:codegen` this thrown an error like so:
```shell
Cannot query field "acceptanceToken" on type "Query"
```
This error points to this `@rest` query.
## Query that thrown the error
```typescript
export const wompiAcceptanceTokenQuery = gql`
query WompiAcceptanceToken {
acceptanceToken
@rest(
type: "WompiAcceptanceToken"
path: "some/api/endpoint"
) {
data
}
}
`
```
There is a way to ignore this directives from npm `client:codegen` script?
## Current NPM script
```shell
"typegenerate": "apollo client:codegen --target=typescript types --globalTypesFile=src/types/globalTypes.ts && rm -rf types",
```
Contributor guide
Research direction
Start by reproducing the failure with the shown TypeScript query and the `apollo client:codegen` command from the npm script. Trace how the codegen command validates the `@rest` query and determine the intended handling for that directive. Done means the command completes successfully for this query with appropriate generated types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100