Open mo-tottenham opened 5 years ago
@mo-tottenham your result part of the mock seems incorrect. Please try to replace:
result: {
data: {
activeChart: {
with
result: {
data: {
setActiveChart: {
@trojanowski Ah ok I thought the result should match what the mutation returns which in my case was activeChart
.
I've applied your suggested changes but then got an error about missing field __typename
. So then I changed my mock mutation to this:
const SET_ACTIVE_CHART = gql`
mutation setActiveChart($activeSegment: String!, $type: String!) {
setActiveChart(activeSegment: $activeSegment, type: $type) @client {
activeSegment
type
}
}`
const mocks = [
{
request: {
query: SET_ACTIVE_CHART,
variables: {
__typename: 'ActiveChart',
activeSegment: 'Journal article',
type: 'ResearchOutput',
},
},
result: {
data: {
setActiveChart: {
activeSegment: 'Journal article',
type: 'ResearchOutput',
__typename: 'ActiveChart',
},
},
},
},
]
Which gives me the following error:
No more mocked responses for the query: mutation setActiveChart($activeSegment: String!, $type: String!) {
setActiveChart(activeSegment: $activeSegment, type: $type) @client {
activeSegment
__typename
}
}
, variables: {"activeSegment":"Journal article","type":"ResearchOutput"}
Note: I also think the fact I am using the client
directive as this mutation manages local state, could be an issue.
I also think the fact I am using the client directive as this mutation manages local state, could be an issue.
@mo-tottenham Yes, it could be the reason. Do you use Apollo Client 2.5? If so I think you should add your resolvers
to the ApolloClient
options.
I have a pie chart with a legend. When a legend label is clicked the corresponding pie slice gets a highlight color, and so does the legend label itself. This is the test for my
Legend.tsx
component.I am getting the following error:
Here is my test file: