Skip to content

Commit

Permalink
Define and expose ApolloClientOptions (#2292)
Browse files Browse the repository at this point in the history
It'd be helpful to UI integration libraries such as new angular-apollo, which will be released soon.
  • Loading branch information
kamilkisiela authored and James Baxley committed Oct 12, 2017
1 parent 4ef4a30 commit e4c61ad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/apollo-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Change log

### vNext
- Define and expose `ApolloClientOptions`, Type of an object that represents ApolloClient's constructor argument.

### 2.0.0-rc.3
- Only include `data` on subscriptionData when using `subscribeToMore`
Expand Down
20 changes: 11 additions & 9 deletions packages/apollo-client/src/ApolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ export interface DefaultOptions {

let hasSuggestedDevtools = false;

export type ApolloClientOptions<TCacheShape> = {
link: ApolloLink;
cache: ApolloCache<TCacheShape>;
ssrMode?: boolean;
ssrForceFetchDelay?: number;
connectToDevTools?: boolean;
queryDeduplication?: boolean;
defaultOptions?: DefaultOptions;
};

/**
* This is the primary Apollo Client class. It is used to send GraphQL documents (i.e. queries
* and mutations) to a GraphQL spec-compliant server over a {@link NetworkInterface} instance,
Expand Down Expand Up @@ -70,15 +80,7 @@ export default class ApolloClient<TCacheShape> implements DataProxy {
* @param fragmentMatcher A function to use for matching fragment conditions in GraphQL documents
*/

constructor(options: {
link: ApolloLink;
cache: ApolloCache<TCacheShape>;
ssrMode?: boolean;
ssrForceFetchDelay?: number;
connectToDevTools?: boolean;
queryDeduplication?: boolean;
defaultOptions?: DefaultOptions;
}) {
constructor(options: ApolloClientOptions<TCacheShape>) {
const {
link,
cache,
Expand Down
4 changes: 3 additions & 1 deletion packages/apollo-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export * from './core/types';

export { ApolloError } from './errors/ApolloError';

import ApolloClient from './ApolloClient';
import ApolloClient, { ApolloClientOptions } from './ApolloClient';

export { ApolloClientOptions };

// export the client as both default and named
export { ApolloClient };
Expand Down

0 comments on commit e4c61ad

Please sign in to comment.