apollo-feature-requests icon indicating copy to clipboard operation
apollo-feature-requests copied to clipboard

Refactoring of fetch policy types in apollo-client to exported constants to reduce error possibility

Open U-4-E-A opened this issue 5 years ago • 0 comments

Instead of of having to use this option as a string: -

fetchPolicy: 'cache-first'

It would be better for error reduction if the FetchPolicy was refactored to use constants and these constants could also be used in application code: -

export declare type FetchPolicy = 'cache-first' | 'network-only' | 'cache-only' | 'no-cache' | 'standby';

export const FETCH_POLICY_CACHE_FIRST = "cache-first"
export const FETCH_POLICY_CACHE_ONLY = "cache-only"
export const FETCH_POLICY_NETWORK_ONLY = "network-only"
export const FETCH_POLICY_NO_CACHE = "no-cache"
export const FETCH_POLICY_STANDBY = "standby"

export declare type FetchPolicy = typeof FETCH_POLICY_CACHE_FIRST | typeof FETCH_POLICY_CACHE_ONLY | typeof FETCH_POLICY_NETWORK_ONLY | typeof FETCH_POLICY_NO_CACHE | typeof FETCH_POLICY_STANDBY
Import { FETCH_POLICY_CACHE_FIRST } from 'apollo-client'

... fetchPolicy: FETCH_POLICY_CACHE_FIRST

U-4-E-A avatar Oct 02 '20 13:10 U-4-E-A