graphql-code-generator-community
graphql-code-generator-community copied to clipboard
useFragment does not support variables or other base options
Is your feature request related to a problem? Please describe.
The useFragment hook generation only sets the fragment and from options, but does not include the other base options for variables, optimistic, and client.
Describe the solution you'd like
Add a second, options param to include any missing options from the base fragment options type.
useSomeDataFragment({ id: "1234" }, {
optimistic: true,
variables: { first: 10 },
client: customClient
});
Describe alternatives you've considered
Replacing the existing 'identifiers' param with a more traditional FragmentOptions that accepts the IDs and base options, although this would be a breaking change without duck-typing.
useSomeDataFragment({
identifiers: { id: "1234" },
optimistic: true,
variables: { first: 10 },
client: customClient
});
Additional context
Opened a PR here - https://github.com/dotansimha/graphql-code-generator-community/pull/742