graphql-code-generator
graphql-code-generator copied to clipboard
Generate and export react-apollo query components props
Is your feature request related to a problem? Please describe. When we want to extend a generated query component with composition we have to generate its props type by ourselves.
For instance:
export const AddToCartComponent = (
props: Omit<
Omit<
ReactApollo.MutationProps<AddToCartMutation, AddToCartMutationVariables>,
'mutation'
>,
'variables'
> & { variables?: AddToCartMutationVariables }
) => (
<ReactApollo.Mutation<AddToCartMutation, AddToCartMutationVariables>
mutation={AddToCartDocument}
{...props}
/>
);
If i want to wrap it in my own component i have to re-create the props types.
function MyAddToCartComponent(props: Omit<
Omit<
ReactApollo.MutationProps<AddToCartMutation, AddToCartMutationVariables>,
'mutation'
>,
'variables'
> & { variables?: AddToCartMutationVariables }) {
<AddToCartComponent
{...props}
{// some pre-filled stuff}
>
{(addToCart, data) => children(addToCart, data)}
</AddToCartComponent>
}
Describe the solution you'd like Export the generated props.
@ardatan Can you please take a look? Maybe we can export it in a different way from react-apollo plugin in order to support this use-case.
Available in 1.2.0.