Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

MockedProvider does not return data when fetchPolicy is set to "cache-and-network" #779

Closed
eskimoblood opened this issue Jun 14, 2017 · 15 comments

Comments

@eskimoblood
Copy link

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.

Version

  • apollo-client@<1.1.2r>
  • react-apollo@<1.4.2>
@helfer
Copy link
Contributor

helfer commented Jun 14, 2017

Thanks for filing an issue @eskimoblood. Would you be able to provide a reproduction of this using the react-apollo-error-template?

@stale stale bot added the wontfix label Jul 5, 2017
@stale
Copy link

stale bot commented Jul 5, 2017

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!

@settings settings bot removed the wontfix label Jul 8, 2017
@derek-duncan
Copy link

Same issue. Try mounting a graphql component with fetchPolicy: 'cache-and-network wrapped in a <MockedProvider>.

@stale
Copy link

stale bot commented Aug 12, 2017

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!

@carlows
Copy link
Contributor

carlows commented Aug 16, 2017

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.

@stubailo
Copy link
Contributor

Can you provide a reproduction we can run please?

@stale
Copy link

stale bot commented Sep 6, 2017

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!

@stale stale bot closed this as completed Sep 20, 2017
@stale
Copy link

stale bot commented Sep 20, 2017

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!

@jbreckel
Copy link

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: {...},
}

@polmann
Copy link

polmann commented Nov 1, 2017

@stubailo @helfer using what @jbreckel provided above were you able to reproduce this issue?

@flpStrri
Copy link

Any update on this issue?

@vctormb
Copy link

vctormb commented Dec 11, 2018

I'm having this problem too when trying to update the cache with a MockedProvider.

@jozanza
Copy link
Contributor

jozanza commented Jan 16, 2019

I'm also running into this issue when using a Query component with a cache-only fetchPolicy.

@hashina
Copy link

hashina commented Feb 28, 2019

The same to me

@kpruden
Copy link

kpruden commented Mar 8, 2019

Any way to get this issue re-opened? I'm seeing it too when using fetchPolicy: cache-only

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests