Skip to content

Commit

Permalink
Avoid all sub-package imports from graphql package.
Browse files Browse the repository at this point in the history
Since we don't control the contents of this package, and nested
subdirectories within the graphql package do not have their own
package.json files with "main" and "module" entry points (like our
`@apollo/client/*` sub-packages do), it is unfortunately not safe to reach
into the package to import specific items, as demonstrated by apollographql#7184.

This could cause a bundle size regression for bundlers that do not perform
any tree-shaking, but it's the responsibility of the graphql package
maintainers to support selective sub-package imports if they want to.
Until that happens, @apollo/client must import from the graphql package in
the only supported way: directly from the top-level package.
  • Loading branch information
benjamn committed Oct 19, 2020
1 parent 8cfd62f commit 8a334f7
Show file tree
Hide file tree
Showing 15 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/local-state/export.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import gql from 'graphql-tag';
import { print } from 'graphql/language/printer';
import { print } from 'graphql';

import { Observable } from '../../utilities';
import { itAsync } from '../../testing';
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/local-state/general.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import gql from 'graphql-tag';
import { DocumentNode, GraphQLError } from 'graphql';
import { getIntrospectionQuery } from 'graphql/utilities';
import { DocumentNode, GraphQLError, getIntrospectionQuery } from 'graphql';

import { Observable } from '../../utilities';
import { ApolloLink } from '../../link/core';
Expand Down
2 changes: 1 addition & 1 deletion src/cache/inmemory/policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
FragmentDefinitionNode,
SelectionSetNode,
FieldNode,
} from "graphql";
} from 'graphql';

import { KeyTrie } from 'optimism';
import { invariant, InvariantError } from 'ts-invariant';
Expand Down
3 changes: 2 additions & 1 deletion src/core/LocalState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import {
FragmentDefinitionNode,
FieldNode,
ASTNode,
visit,
BREAK,
} from 'graphql';
import { visit, BREAK } from 'graphql/language/visitor';
import { invariant } from 'ts-invariant';

import { ApolloCache } from '../cache';
Expand Down
2 changes: 1 addition & 1 deletion src/link/batch/__tests__/batchLink.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import gql from 'graphql-tag';
import { print } from 'graphql/language/printer';
import { print } from 'graphql';

import { ApolloLink } from '../../core/ApolloLink';
import { execute } from '../../core/execute';
Expand Down
2 changes: 1 addition & 1 deletion src/link/core/__tests__/ApolloLink.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import gql from 'graphql-tag';
import { print } from 'graphql/language/printer';
import { print } from 'graphql';

import { Observable } from '../../../utilities/observables/Observable';
import { FetchResult, Operation, NextLink, GraphQLRequest } from '../types';
Expand Down
3 changes: 1 addition & 2 deletions src/link/core/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { DocumentNode } from 'graphql/language/ast';
import { ExecutionResult } from 'graphql/execution/execute';
import { DocumentNode, ExecutionResult } from 'graphql';
export { DocumentNode };

import { Observable } from '../../utilities';
Expand Down
2 changes: 1 addition & 1 deletion src/link/http/selectHttpOptionsAndBody.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { print } from 'graphql/language/printer';
import { print } from 'graphql';

import { Operation } from '../core';

Expand Down
2 changes: 1 addition & 1 deletion src/link/persisted-queries/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { print } from 'graphql/language/printer';
import { print } from 'graphql';
import {
DocumentNode,
ExecutionResult,
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/graphql/__tests__/fragments.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { print } from 'graphql/language/printer';
import { print } from 'graphql';
import gql from 'graphql-tag';
import { disableFragmentWarnings } from 'graphql-tag';

Expand Down
2 changes: 1 addition & 1 deletion src/utilities/graphql/__tests__/getFromAST.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { print } from 'graphql/language/printer';
import { print } from 'graphql';
import gql from 'graphql-tag';
import { FragmentDefinitionNode, OperationDefinitionNode } from 'graphql';

Expand Down
2 changes: 1 addition & 1 deletion src/utilities/graphql/__tests__/transform.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { print } from 'graphql/language/printer';
import { print } from 'graphql';
import gql from 'graphql-tag';
import { disableFragmentWarnings } from 'graphql-tag';

Expand Down
3 changes: 1 addition & 2 deletions src/utilities/graphql/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import {
ArgumentNode,
ValueNode,
ASTNode,
visit,
} from 'graphql';

import { visit } from 'graphql/language/visitor';

import { invariant } from 'ts-invariant';

export type DirectiveInfo = {
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/graphql/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
FragmentSpreadNode,
VariableDefinitionNode,
VariableNode,
visit,
} from 'graphql';
import { visit } from 'graphql/language/visitor';
import { invariant } from 'ts-invariant';

import {
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/testing/mocking/mockLink.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { print } from 'graphql/language/printer';
import { print } from 'graphql';
import { equal } from '@wry/equality';
import { invariant } from 'ts-invariant';

Expand Down

0 comments on commit 8a334f7

Please sign in to comment.