Skip to content

Commit

Permalink
define fetch policies as union
Browse files Browse the repository at this point in the history
  • Loading branch information
helfer committed Mar 7, 2017
1 parent 0d4fe2c commit a1b3a36
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/core/watchQueryOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ import {
PureQueryOptions,
} from './types';

/**
* fetchPolicy determines where the client may return a result from. The options are:
* - cache-and-network: returns result from cache first (if it exists), then return network result once it's available
* - cache-first: return result from cache. Only fetch from network if cached result is not available.
* - network-first: return result from network, but if network request fails, use result from cache, if available.
* - cache-only: return result from cache if avaiable, fail otherwise.
* - network-only: return result from network, fail if network call doesn't succeed.
*/
export type FetchPolicy = 'cache-first' | 'cache-and-network' | 'network-first' | 'cache-only' | 'network-only';

/**
* We can change these options to an ObservableQuery
*/
Expand Down Expand Up @@ -46,14 +56,9 @@ export interface ModifiableWatchQueryOptions {
pollInterval?: number;

/**
* fetchPolicy determines where the client may return a result from. The options are:
* - cache-and-network: returns result from cache first (if it exists), then return network result once it's available
* - cache-first: return result from cache. Only fetch from network if cached result is not available.
* - network-first: return result from network, but if network request fails, use result from cache, if available.
* - cache-only: return result from cache if avaiable, fail otherwise.
* - network-only: return result from network, fail if network call doesn't succeed.
* Specifies the {@link FetchPolicy} to be used for this query
*/
// fetchPolicy?: string;
fetchPolicy?: FetchPolicy;

/**
* Whether or not updates to the network status should trigger next on the observer of this query
Expand Down

1 comment on commit a1b3a36

@qm3ster
Copy link

@qm3ster qm3ster commented on a1b3a36 May 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These links don't currently work, so the only way to learn about the policies is going to https://www.apollographql.com/docs/react/api/react-apollo#graphql-config-options-fetchPolicy

Please sign in to comment.