This is not a browser cache issue.
I have a typePolicies defined on the ApolloClient:
const client = new ApolloClient({
link: authLink.concat(httpLink),
cache: new InMemoryCache(
{
typePolicies: policyMap
}
),
});
These are implemented in a function that takes a field argument:
const Opening2 = (field) => {
const data = {
"rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1": {
eco: "B00",
moves: "1. e4",
name: "King's Pawn Game",
next: [
{
name: "King's Pawn Game",
moves: "1. e4 e5",
score: 0.43,
eco: "C20",
},
],
from: [],
aliases: ["King's Pawn", "King's Pawn"],
score: 0.44,
},
};
return {
read(_, { variables }) {
const variableString = Object.values(variables).join();
const dataForFen = data[variableString];
return dataForFen[field];
},
};
};
const policyMap = {
Opening2: {
fields: {
eco: Opening2("eco"),
name: Opening2("name"),
moves: Opening2("moves"),
next: Opening2("next"),
from: Opening2("from"),
aliases: Opening2("aliases"),
score: Opening2("score"),
},
},
};
From the documentation, I had the understanding that these field policies only get invoked if and @client directive was attached to the field(s):
const client = "@client"
const GET_OPENING = gql`
query getOpening($fen: String!) {
getOpeningForFenFull(fen: $fen) {
eco
name ${client}
moves ${client}
next {
name
moves
score
eco
}
from ${client} {
name
moves
}
aliases ${client}
score ${client}
}
}
`;
But it seems if I remove the client directives, the values from the policyMap still apply (I get local variables). Is this correct behavior?