Comments (4)
Happy to work on the PR for this, though it might take me a bit 🙏
from graphql-code-generator-community.
Will keep the WIP here -> https://github.com/dotansimha/graphql-code-generator-community/compare/main...fforres:graphql-code-generator-community:fforres/use_background_query?expand=1
from graphql-code-generator-community.
great let me know once you are ready for review @fforres assigned you this issue. Thank you
from graphql-code-generator-community.
Will keep the WIP here -> https://github.com/dotansimha/graphql-code-generator-community/compare/main...fforres:graphql-code-generator-community:fforres/use_background_query?expand=1
I corrected your generator code and it works.
// BackgroundQuery Hook
const backgroundOperationName: string =
this.convertName(nodeName, {
suffix: pascalCase('BackgroundQuery'),
useTypesPrefix: false,
}) + this.config.hooksSuffix;
hookFns.push(
`export function use${backgroundOperationName}(baseOptions?: ${this.getApolloReactHooksIdentifier()}.BackgroundQueryHookOptions<${operationResultType}, ${operationVariablesTypes}>) {
const options = {...defaultOptions, ...baseOptions}
return ${this.getApolloReactHooksIdentifier()}.useBackgroundQuery<${operationResultType}, ${operationVariablesTypes}>(${this.getDocumentNodeVariable(
node,
documentVariableName,
)}, options);
}`,
);
hookResults.push(
`export type ${backgroundOperationName}HookResult = ReturnType<typeof use${backgroundOperationName}>;`,
);
// ReadQuery Hook
const readOperationName: string =
this.convertName(nodeName, {
suffix: pascalCase('ReadQuery'),
useTypesPrefix: false,
}) + this.config.hooksSuffix;
hookFns.push(
`export function use${readOperationName}(backgroundQueryRef: ${this.getApolloReactHooksIdentifier()}.QueryReference<${operationResultType}>) {
return ${this.getApolloReactHooksIdentifier()}.useReadQuery<${operationResultType}>(backgroundQueryRef);
}`,
);
hookResults.push(
`export type ${readOperationName}HookResult = ReturnType<typeof use${readOperationName}>;`,
);
from graphql-code-generator-community.
Related Issues (20)
- Fetcher: graphql-request, got error "Type error: Cannot find module 'graphql-request/dist/types.dom' or its corresponding type declarations." HOT 71
- `typed-document-node` doesn't create export statement for all document fragments HOT 10
- Add support to AWS Amplify GraphQL request
- [typescript-react-query]: Allow customizing the `querykey` for generated hooks
- [graphql-request] Pass variables to wrapper function HOT 1
- Can't import `ReactApolloRawPluginConfig` under `"moduleResolution": "node16"` HOT 2
- typescript-react-query Generated queries should reference a type that has common query keys/method (getKey, fetcher, callable)
- [typescript react-query] vue-query not compatible since 6.0.0 and tanstack v5 HOT 1
- Typescript React Query v5 wrong type infinite query HOT 2
- Incorrect description generation for mutation arguments
- Add NestJS plugin
- Generated defaultWrapper includes an unused parameter not prefixed with `_`
- msw plugin does not allow to pass `RequestHandlerOptions` on generated mocks HOT 2
- [react-apollo]: `documentMode: external` does not apply naming parameters
- typescript-react-query: expose `useQuery` `queryClient` parameter with v5 HOT 1
- typescript-urql-graphcache: Property '__typename' is missing in type 'DataFields' HOT 2
- Generated useInfiniteQuery hook code has typescript error with spread operator being applied on `metadata.pageParams` (`unknown` type) HOT 2
- Feature Request: expose queryOptions of react-query v5
- Feature request: [java & kotlin] Generate types as interfaces
- Dotnet code gen does not work on the website HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-code-generator-community.