-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Given I'm mocking a query like this:
const createTx: () => schema.Transaction = () => ({ value: 'txValue' })
mockRequestHandler.withResolvers({
Query: {
transactions: () => createTx()
}
})Then I'm reusing the createTx in my tests like this:
render(<Tx tx={createTx()}/>)
...userEvent, expect, etcBut there's an alias in my actual query:
transactions {
...Tx
}
fragment Tx on Transaction {
value: myValue
}So, while in the <Tx> component, I'm not getting myValue since createTx returns an object with value instead.
I am using graphql-codegen, so I have TxFragment type available, but I don't see how I can convert the raw type (schema.Transaction) into the fragment. What's the recommended approach?
Here's my workaround:
const createTx: () => schema.Transaction & Pick<TxFragment, 'myValue'> = () => ({ value: 'txValue', myValue: 'txValue' })Just hardcoding specific differences so that type casting works in both places. But it's a hack
Metadata
Metadata
Assignees
Labels
No labels