graphql-code-generator-community icon indicating copy to clipboard operation
graphql-code-generator-community copied to clipboard

useFragment does not support variables or other base options

Open bembleton opened this issue 1 year ago • 1 comments

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

bembleton avatar May 10 '24 18:05 bembleton

Opened a PR here - https://github.com/dotansimha/graphql-code-generator-community/pull/742

rohit-gohri avatar Jun 09 '24 21:06 rohit-gohri