Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add QueryOptions and QueryBaseOptions interfaces #3569

Merged
merged 4 commits into from
Jun 11, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
DRY things up using multiple interface inheritance / merging
  • Loading branch information
hwillson committed Jun 11, 2018
commit efaaa9b9a5935b29050a78536b967bfbb4f26859
53 changes: 18 additions & 35 deletions packages/apollo-client/src/core/watchQueryOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,32 +60,16 @@ export interface QueryBaseOptions<TVariables = OperationVariables> {
}

/**
* We can change these options to an ObservableQuery
* Query options.
*/
export interface ModifiableWatchQueryOptions<TVariables = OperationVariables>
export interface QueryOptions<TVariables = OperationVariables>
extends QueryBaseOptions<TVariables> {
/**
* The time interval (in milliseconds) on which this query should be
* refetched from the server.
*/
pollInterval?: number;

/**
* Whether or not updates to the network status should trigger next on the observer of this query
*/
notifyOnNetworkStatusChange?: boolean;
}

/**
* Watched query options.
*/
export interface WatchQueryOptions<TVariables = OperationVariables>
extends ModifiableWatchQueryOptions<TVariables> {
/**
* A GraphQL document that consists of a single query to be sent down to the
* server.
*/
// TODO REFACTOR: rename this to document. Didn't do it yet because it's in a lot of tests.
// TODO REFACTOR: rename this to document. Didn't do it yet because it's in a
// lot of tests.
query: DocumentNode;

/**
Expand All @@ -101,30 +85,29 @@ export interface WatchQueryOptions<TVariables = OperationVariables>
}

/**
* Query options.
* We can change these options to an ObservableQuery
*/
export interface QueryOptions<TVariables = OperationVariables>
export interface ModifiableWatchQueryOptions<TVariables = OperationVariables>
extends QueryBaseOptions<TVariables> {
/**
* A GraphQL document that consists of a single query to be sent down to the
* server.
*/
// TODO REFACTOR: rename this to document. Didn't do it yet because it's in a
// lot of tests.
query: DocumentNode;

/**
* Arbitrary metadata stored in the store with this query. Designed for debugging,
* developer tools, etc.
* The time interval (in milliseconds) on which this query should be
* refetched from the server.
*/
metadata?: any;
pollInterval?: number;

/**
* Context to be passed to link execution chain
* Whether or not updates to the network status should trigger next on the observer of this query
*/
context?: any;
notifyOnNetworkStatusChange?: boolean;
}

/**
* Watched query options.
*/
export interface WatchQueryOptions<TVariables = OperationVariables>
extends QueryOptions<TVariables>,
ModifiableWatchQueryOptions<TVariables> {}

export interface FetchMoreQueryOptions<TVariables, K extends keyof TVariables> {
query?: DocumentNode;
variables?: Pick<TVariables, K>;
Expand Down