Skip to content

Commit

Permalink
Merge pull request #5425 from apollographql/remove-default-export
Browse files Browse the repository at this point in the history
Remove the `ApolloClient` default export
  • Loading branch information
hwillson authored Oct 10, 2019
2 parents 5132af5 + 764b1b0 commit 3b95a15
Show file tree
Hide file tree
Showing 34 changed files with 49 additions and 50 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
- `QueryManager#startQuery`
- `ObservableQuery#currentResult`

- `ApolloClient` is now only available as a named export. The default
`ApolloClient` export has been removed.

## Apollo Client (2.6.4)

### Apollo Client (2.6.4)
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/ApolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export type ApolloClientOptions<TCacheShape> = {
* receive results from the server and cache the results in a store. It also delivers updates
* to GraphQL queries through {@link Observable} instances.
*/
export default class ApolloClient<TCacheShape> implements DataProxy {
export class ApolloClient<TCacheShape> implements DataProxy {
public link: ApolloLink;
public store: DataStore<TCacheShape>;
public cache: ApolloCache<TCacheShape>;
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/ApolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { HttpLink } from '../link/http';
import { InMemoryCache, makeReference } from '../cache/inmemory';
import { stripSymbols } from '../utilities';
import { withWarning } from '../util/wrap';
import ApolloClient from '../';
import { ApolloClient } from '../';
import { DefaultOptions } from '../ApolloClient';
import { FetchPolicy, QueryOptions } from '../core/watchQueryOptions';

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { InMemoryCache, PossibleTypesMap } from '../cache/inmemory';
import { stripSymbols } from '../utilities';
import { WatchQueryOptions, FetchPolicy } from '../core/watchQueryOptions';
import { ApolloError } from '../errors/ApolloError';
import ApolloClient from '..';
import { ApolloClient } from '..';
import subscribeAndCount from '../util/subscribeAndCount';
import { withWarning } from '../util/wrap';
import { mockSingleLink } from '../__mocks__/mockLinks';

describe('client', () => {
it('can be loaded via require', () => {
/* tslint:disable */
const ApolloClientRequire = require('../').default;
const ApolloClientRequire = require('../').ApolloClient;
/* tslint:enable */

const client = new ApolloClientRequire({
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/fetchMore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import gql from 'graphql-tag';

import { mockSingleLink } from '../__mocks__/mockLinks';
import { InMemoryCache } from '../cache/inmemory';
import ApolloClient, { NetworkStatus, ObservableQuery } from '../';
import { ApolloClient, NetworkStatus, ObservableQuery } from '../';

describe('updateQuery on a simple query', () => {
const query = gql`
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/graphqlSubscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import gql from 'graphql-tag';

import { mockObservableLink, MockedSubscription } from '../__mocks__/mockLinks';
import { InMemoryCache } from '../cache/inmemory';
import ApolloClient from '../';
import { ApolloClient } from '../';
import { QueryManager } from '../core/QueryManager';
import { DataStore } from '../data/store';

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/local-state/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { print } from 'graphql/language/printer';

import { Observable } from '../../util/Observable';
import { ApolloLink } from '../../link/core';
import ApolloClient from '../..';
import { ApolloClient } from '../..';
import { InMemoryCache } from '../../cache/inmemory';

describe('@client @export tests', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/local-state/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { introspectionQuery } from 'graphql/utilities';

import { Observable } from '../../util/Observable';
import { ApolloLink, Operation } from '../../link/core';
import ApolloClient from '../..';
import { ApolloClient } from '../..';
import { ApolloCache } from '../../cache/core';
import { InMemoryCache } from '../../cache/inmemory';
import { hasDirectives } from '../../utilities';
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/local-state/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { assign } from 'lodash';

import { Observable } from '../../util/Observable';
import { ApolloLink } from '../../link/core';
import ApolloClient from '../..';
import { ApolloClient } from '../..';
import mockQueryManager from '../../__mocks__/mockQueryManager';
import { Observer } from '../../util/Observable';
import wrap from '../../util/wrap';
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/local-state/subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import gql from 'graphql-tag';

import { Observable } from '../../util/Observable';
import { ApolloLink } from '../../link/core';
import ApolloClient from '../..';
import { ApolloClient } from '../..';
import { InMemoryCache } from '../../cache/inmemory';

describe('Basic functionality', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/mutationResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import gql from 'graphql-tag';
import { Observable } from '../util/Observable';
import { ApolloLink } from '../link/core';
import { mockSingleLink } from '../__mocks__/mockLinks';
import ApolloClient from '..';
import { ApolloClient } from '..';
import { InMemoryCache } from '../cache/inmemory';
import { Subscription } from '../util/Observable';
import { withWarning } from '../util/wrap';
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/optimistic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import gql from 'graphql-tag';
import { mockSingleLink } from '../__mocks__/mockLinks';
import { MutationQueryReducersMap } from '../core/types';
import { Subscription } from '../util/Observable';
import ApolloClient from '../';
import { ApolloClient } from '../';
import { addTypenameToDocument, stripSymbols } from '../utilities';
import { InMemoryCache, makeReference } from '../cache/inmemory';

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/subscribeToMore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DocumentNode, OperationDefinitionNode } from 'graphql';

import { ApolloLink, Operation } from '../link/core';
import { mockSingleLink, mockObservableLink } from '../__mocks__/mockLinks';
import ApolloClient from '../';
import { ApolloClient } from '../';
import { InMemoryCache } from '../cache/inmemory';
import { stripSymbols } from '../utilities';

Expand Down
2 changes: 1 addition & 1 deletion src/core/LocalState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
isField,
isInlineFragment,
} from '../utilities';
import ApolloClient from '../ApolloClient';
import { ApolloClient } from '../ApolloClient';
import { Resolvers, OperationVariables } from './types';
import { capitalizeFirstLetter } from '../util/capitalizeFirstLetter';

Expand Down
2 changes: 1 addition & 1 deletion src/core/__tests__/ObservableQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ObservableQuery } from '../ObservableQuery';
import { NetworkStatus } from '../networkStatus';
import { QueryManager } from '../QueryManager';
import { DataStore } from '../../data/store';
import ApolloClient from '../../';
import { ApolloClient } from '../../';

import wrap from '../../util/wrap';
import subscribeAndCount from '../../util/subscribeAndCount';
Expand Down
2 changes: 1 addition & 1 deletion src/core/__tests__/fetchPolicies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import gql from 'graphql-tag';
import { ApolloLink } from '../../link/core';
import { InMemoryCache } from '../../cache/inmemory';
import { stripSymbols } from '../../utilities';
import ApolloClient from '../..';
import { ApolloClient } from '../..';
import subscribeAndCount from '../../util/subscribeAndCount';
import { mockSingleLink } from '../../__mocks__/mockLinks';
import { NetworkStatus } from '../networkStatus';
Expand Down
16 changes: 6 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
export {
ApolloClient,
ApolloClientOptions,
DefaultOptions
} from './ApolloClient';

export {
ObservableQuery,
FetchMoreOptions,
Expand Down Expand Up @@ -30,16 +36,6 @@ export {

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

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

// Export the client as both default and named.
export { ApolloClient };
export default ApolloClient;

export * from './cache/core';
export * from './cache/inmemory';

Expand Down
2 changes: 1 addition & 1 deletion src/react/context/ApolloConsumer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { invariant } from 'ts-invariant';

import ApolloClient from '../../ApolloClient';
import { ApolloClient } from '../../ApolloClient';
import { getApolloContext } from './ApolloContext';

export interface ApolloConsumerProps {
Expand Down
2 changes: 1 addition & 1 deletion src/react/context/ApolloContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

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

export interface ApolloContextValue {
client?: ApolloClient<object>;
Expand Down
2 changes: 1 addition & 1 deletion src/react/context/ApolloProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { invariant } from 'ts-invariant';

import ApolloClient from '../../ApolloClient';
import { ApolloClient } from '../../ApolloClient';
import { getApolloContext } from './ApolloContext';

export interface ApolloProviderProps<TCache> {
Expand Down
2 changes: 1 addition & 1 deletion src/react/context/__tests__/ApolloConsumer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { render, cleanup } from '@testing-library/react';

import { ApolloLink } from '../../../link/core';
import ApolloClient from '../../../ApolloClient';
import { ApolloClient } from '../../../ApolloClient';
import { InMemoryCache as Cache } from '../../../cache/inmemory/inMemoryCache';
import { ApolloProvider } from '../ApolloProvider';
import { ApolloConsumer } from '../ApolloConsumer';
Expand Down
2 changes: 1 addition & 1 deletion src/react/context/__tests__/ApolloProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext } from 'react';
import { render, cleanup } from '@testing-library/react';

import { ApolloLink } from '../../../link/core';
import ApolloClient from '../../../ApolloClient';
import { ApolloClient } from '../../../ApolloClient';
import { InMemoryCache as Cache } from '../../../cache/inmemory/inMemoryCache';
import { ApolloProvider } from '../ApolloProvider';
import { getApolloContext } from '../ApolloContext';
Expand Down
2 changes: 1 addition & 1 deletion src/react/data/OperationData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DocumentNode } from 'graphql';
import { equal as isEqual } from '@wry/equality';
import { invariant } from 'ts-invariant';

import ApolloClient from '../../ApolloClient';
import { ApolloClient } from '../../ApolloClient';
import { DocumentType, parser, operationName } from '../parser/parser';
import { ApolloContextValue } from '../context/ApolloContext';
import { CommonOptions } from '../types/types';
Expand Down
2 changes: 1 addition & 1 deletion src/react/hooks/__tests__/useApolloClient.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { InvariantError } from 'ts-invariant';
import { ApolloLink } from '../../../link/core';
import { ApolloProvider } from '../../context/ApolloProvider';
import { resetApolloContext } from '../../context/ApolloContext';
import ApolloClient from '../../../ApolloClient';
import { ApolloClient } from '../../../ApolloClient';
import { InMemoryCache } from '../../../cache/inmemory/inMemoryCache';
import { useApolloClient } from '../useApolloClient';

Expand Down
2 changes: 1 addition & 1 deletion src/react/hooks/__tests__/useLazyQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import gql from 'graphql-tag';
import { render, wait } from '@testing-library/react';

import { MockedProvider } from '../../testing';
import ApolloClient from '../../../ApolloClient';
import { ApolloClient } from '../../../ApolloClient';
import { InMemoryCache } from '../../../cache/inmemory/inMemoryCache';
import { ApolloProvider } from '../../context/ApolloProvider';
import { useLazyQuery } from '../useLazyQuery';
Expand Down
2 changes: 1 addition & 1 deletion src/react/hooks/__tests__/useMutation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import gql from 'graphql-tag';
import { render, cleanup, wait } from '@testing-library/react';

import { MockedProvider, mockSingleLink } from '../../testing';
import ApolloClient from '../../../ApolloClient';
import { ApolloClient } from '../../../ApolloClient';
import { InMemoryCache } from '../../../cache/inmemory/inMemoryCache';
import { ApolloProvider } from '../../context/ApolloProvider';
import { useMutation } from '../useMutation';
Expand Down
2 changes: 1 addition & 1 deletion src/react/hooks/__tests__/useQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { render, cleanup, wait } from '@testing-library/react';
import { Observable } from '../../../util/Observable';
import { ApolloLink } from '../../../link/core';
import { MockedProvider, MockLink } from '../../testing';
import ApolloClient from '../../../ApolloClient';
import { ApolloClient } from '../../../ApolloClient';
import { InMemoryCache } from '../../../cache/inmemory/inMemoryCache';
import { ApolloProvider } from '../../context/ApolloProvider';
import { useQuery } from '../useQuery';
Expand Down
2 changes: 1 addition & 1 deletion src/react/hooks/__tests__/useSubscription.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { render, cleanup, wait } from '@testing-library/react';
import gql from 'graphql-tag';

import { MockSubscriptionLink } from '../../testing';
import ApolloClient from '../../../ApolloClient';
import { ApolloClient } from '../../../ApolloClient';
import { InMemoryCache as Cache } from '../../../cache/inmemory/inMemoryCache';
import { ApolloProvider } from '../../context/ApolloProvider';
import { useSubscription } from '../useSubscription';
Expand Down
2 changes: 1 addition & 1 deletion src/react/hooks/useApolloClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { invariant } from 'ts-invariant';

import ApolloClient from '../../ApolloClient';
import { ApolloClient } from '../../ApolloClient';
import { getApolloContext } from '../context/ApolloContext';

export function useApolloClient(): ApolloClient<object> {
Expand Down
2 changes: 1 addition & 1 deletion src/react/testing/mocks/MockedProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import ApolloClient from '../../../ApolloClient';
import { ApolloClient } from '../../../ApolloClient';
import { InMemoryCache as Cache } from '../../../cache/inmemory/inMemoryCache';
import { ApolloProvider } from '../../context/ApolloProvider';
import { MockLink } from './mockLink';
Expand Down
2 changes: 1 addition & 1 deletion src/react/testing/mocks/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApolloLink, GraphQLRequest, FetchResult } from '../../../link/core';
import ApolloClient, { DefaultOptions } from '../../../ApolloClient';
import { ApolloClient, DefaultOptions } from '../../../ApolloClient';
import { Resolvers } from '../../../core/types';
import { ApolloCache } from '../../../cache/core/cache';

Expand Down
2 changes: 1 addition & 1 deletion src/react/testing/utils/createClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DocumentNode } from 'graphql';

import ApolloClient from '../../../ApolloClient';
import { ApolloClient } from '../../../ApolloClient';
import { InMemoryCache } from '../../../cache/inmemory/inMemoryCache';
import { NormalizedCacheObject } from '../../../cache/inmemory/types';
import { mockSingleLink } from '../mocks/mockLink';
Expand Down
2 changes: 1 addition & 1 deletion src/react/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DocumentNode } from 'graphql';

import { Observable } from '../../util/Observable';
import { FetchResult } from '../../link/core';
import ApolloClient from '../../ApolloClient';
import { ApolloClient } from '../../ApolloClient';
import {
ApolloQueryResult,
PureQueryOptions,
Expand Down

0 comments on commit 3b95a15

Please sign in to comment.