Skip to content

Cache results not changing even with fetch policy set to network-only or no-cache? #154

@jean182

Description

@jean182

I'm having an issue using this library that whenever I change something in my backend, the next js app does not update with the new results(when refreshing the page) even if the fetch policy is network-only o no-cache, any ideas why this is happening, or is there some documentation on how to accomplish that.

import {ssrGetRanking, PageGetRankingComp} from 'generated/page'

import {GetServerSidePropsContext} from 'next'
import React from 'react'

import {withApollo} from 'withApollo'

const RankingPage: PageGetRankingComp = ({data, error}) => {
  // Comp logic goes here
}

export async function getServerSideProps(ctx: GetServerSidePropsContext) {
  return await ssrGetRanking.getServerPage({fetchPolicy: 'network-only'}, ctx)
}

export default withApollo(ssrGetRanking.withPage(() => ({}))(RankingPage))

I also try to add the fetch policy in the HOC wrap but then I notice that the component was having a delay with the data values because it displays undefined and after that the data is valid.

import {ssrGetRanking, PageGetRankingComp} from 'generated/page'

import {GetServerSidePropsContext} from 'next'
import React from 'react'

import {withApollo} from 'withApollo'

const RankingPage: PageGetRankingComp = ({data, error}) => {
  // Comp logic goes here
}

export async function getServerSideProps(ctx: GetServerSidePropsContext) {
  return await ssrGetRanking.getServerPage({fetchPolicy: 'network-only'}, ctx)
}

export default withApollo(
  ssrGetRanking.withPage(() => ({fetchPolicy: 'network-only'}))(RankingPage),
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions