MockedProvider does not return data when fetchPolicy is set to cache-and-network. When removing the fetchPolicy part from my graphql call, the test data are returned.
Thanks for filing an issue @eskimoblood. Would you be able to provide a reproduction of this using the react-apollo-error-template?
This issue has been automatically marked as stale becuase it has not had recent activity. It will be closed if not further activity occurs. Thank you for your contributions to React Apollo!
Same issue. Try mounting a graphql component with fetchPolicy: 'cache-and-network wrapped in a <MockedProvider>.
This issue has been automatically labled because it has not had recent activity. If you have not received a response from anyone, please mention the repository maintainer (most likely @jbaxleyiii). It will be closed if no further activity occurs. Thank you for your contributions to React Apollo!
I'm also having this issue, I get:
Network error: No more mocked responses for the query: query allPublications
When using 'cache-and-network' as fetchPolicy.
Can you provide a reproduction we can run please?
This issue has been automatically labled because it has not had recent activity. If you have not received a response from anyone, please mention the repository maintainer (most likely @jbaxleyiii). It will be closed if no further activity occurs. Thank you for your contributions to React Apollo!
This issue has been automatically closed because it has not had recent activity after being marked as no recent activyt. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to React Apollo!
not a complete reproduction, but cache-only is also not working with a mock:
graphql(gql`
query {
__schema {
types {
name
}
}
}`, {
options: () => ({
fetchPolicy: 'cache-only',
}),
props: ({ data }) => ({
data: console.log(data) || data,
}),
})
logs twice:
{
refetch: [Function: bound ],
fetchMore: [Function: bound ],
updateQuery: [Function: bound ],
startPolling: [Function: bound ],
stopPolling: [Function: bound ],
subscribeToMore: [Function: bound ],
loading: false,
networkStatus: 7,
error: [Getter],
}
when changing to:
graphql(gql`
query {
__schema {
types {
name
}
}
}`, {
options: () => ({}),
props: ({ data }) => ({
data: console.log(data) || data,
}),
})
it logs the second time:
{
refetch: [Function: bound ],
fetchMore: [Function: bound ],
updateQuery: [Function: bound ],
startPolling: [Function: bound ],
stopPolling: [Function: bound ],
subscribeToMore: [Function: bound ],
loading: false,
networkStatus: 7,
error: [Getter],
__schema: {...},
}
@stubailo @helfer using what @jbreckel provided above were you able to reproduce this issue?
Any update on this issue?
I'm having this problem too when trying to update the cache with a MockedProvider.
I'm also running into this issue when using a Query component with a cache-only fetchPolicy.
The same to me
Any way to get this issue re-opened? I'm seeing it too when using fetchPolicy: cache-only
Most helpful comment
Any way to get this issue re-opened? I'm seeing it too when using
fetchPolicy: cache-only