How do I implement variables? #57
Answered
by
niieani
nareshbhatia
asked this question in
Q&A
-
I am trying to implement this graphql operation: account(accountId: ID!): Account How do I pass in the variable? Here's my interceptor code so far: laika.intercept({ operationName: 'Account' }).mockResult({
result: {
data: {
account: mockAccounts.find((account) => account.id === id),
} as AccountQuery,
},
}); |
Beta Was this translation helpful? Give feedback.
Answered by
niieani
Jul 6, 2023
Replies: 1 comment 1 reply
-
Hi @nareshbhatia! Use a result function instead of mocking with an object directly. For example: laika.intercept({ operationName: 'Account' }).mockResult((operation) => ({
result: {
data: {
account: mockAccounts.find((account) => account.id === operation.variables.id),
} as AccountQuery,
},
})); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
nareshbhatia
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @nareshbhatia!
Use a result function instead of mocking with an object directly. For example: