dotansimha / dotansimha/graphql-code-generator-community
Ability to use the core API in `typescript-react-apollo`
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
Hi! Is there any way in `@graphql-codegen/typescript-react-apollo` to generate functions that use the [core API](https://www.apollographql.com/docs/react/api/core/ApolloClient/#query) `ApolloClient.query(...)` instead of hooks?
Current implementation with `withHook: true` flag:
```js
export function useGetPetQuery(baseOptions?: Apollo.QueryHookOptions) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery(GetPetDocument, options);
}
```
### Describe the solution you'd like
- A flag to use the core API instead.
- Ability to use both enabled flags together in the config for backwards compatibility.
Example of the generated function:
```js
export function getPetQuery(baseOptions?: ApolloClient.QueryOptions) {
const options = {...defaultOptions, ...baseOptions}
return ApolloCore.query(GetPetDocument, options);
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the @graphql-codegen/typescript-react-apollo plugin and its existing withHook configuration, then trace how generated useGetPetQuery functions are produced. Done means a separate core-API option generates getPetQuery using ApolloClient.query while allowing both options together without changing existing hook output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, react, typescript
- Domain
- api, frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100