I'm trying to configure caching and I'm getting this error:
Missing field 'Customer_ID' while computing key fields
I'm new to version two so I'm upgrading from version one (no caching) to v3. My understanding is that in the typePolicies, you have the type then its fields.
// Code not shown for simplicity
[..]
const options = {
typePolicies: {
Customer: { // type
keyFields: ['Customer_ID'] // field
}
}
}
const cache = new InMemoryCache(options)
[..]
And here's the type declaration:
type Customer {
Customer_ID: Int
[..]
}
Finally, my query, with fragments not shown but you do get the understanding:
const CustomerDetailsFragment = gql`
fragment CustomerDetailsFragment on Customer {
Customer_ID
[..]
}
`;
query GetActiveCustomer {
activeCustomer {
...CustomerDetailsFragment
[..] // other fields
}
}
${CustomerDetailsFragment}
[..] // other fragments
When I inspect the activeCustomer query, I see the Customer_ID so why do I get this error? Have I missed something? Thanks.