Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 3 additions & 8 deletions packages/apollo-fragment-react/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,18 @@
"react-scripts": "1.0.16"
},
"dependencies": {
"apollo-cache-inmemory": "^1.0.0",
"apollo-client": "^2.3.1",
"@apollo/client": "^3.5.6",
"apollo-fragment-react": "^0.1.0",
"apollo-link": "^1.0.0",
"apollo-link-state": "^0.4.1",
"apollo-link-state-fragment": "^0.1.0",
Comment on lines 12 to 13
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Jury is still out on what to do with these deps. Will circle back after having a conversation

"graphql": "^0.11.7",
"graphql-tag": "^2.5.0",
"graphql": "16.0.1",
"react": "^16.0.0",
"react-apollo": "^2.1.4",
"react-dom": "^16.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"deploy":
"PUBLIC_URL=/react-apollo-error-template/$(git symbolic-ref --short HEAD) npm run build && gh-pages-clean && gh-pages -d build --dest $(git symbolic-ref --short HEAD) --remote"
"deploy": "PUBLIC_URL=/react-apollo-error-template/$(git symbolic-ref --short HEAD) npm run build && gh-pages-clean && gh-pages -d build --dest $(git symbolic-ref --short HEAD) --remote"
}
}
4 changes: 2 additions & 2 deletions packages/apollo-fragment-react/example/src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from '@apollo/client';
import graphql from 'graphql';
import React, { Component } from 'react';
import { graphql } from 'react-apollo';
import gql from 'graphql-tag';
import { ApolloFragment } from 'apollo-fragment-react';

const fragment = `
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-fragment-react/example/src/graphql/link.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApolloLink, Observable } from '@apollo/client';
import { graphql, print } from 'graphql';
import { ApolloLink, Observable } from 'apollo-link';
import { schema } from './schema';

export const link = new ApolloLink(operation => {
Expand Down
10 changes: 6 additions & 4 deletions packages/apollo-fragment-react/example/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import './index.css';

import React from 'react';
import { render } from 'react-dom';
import { ApolloLink } from 'apollo-link';
import { ApolloClient } from 'apollo-client';
import { ApolloProvider } from 'react-apollo';
import { InMemoryCache } from 'apollo-cache-inmemory';
import {
ApolloClient,
ApolloProvider,
InMemoryCache,
ApolloLink,
} from '@apollo/client';
import {
fragmentCacheRedirect,
fragmentLinkState,
Expand Down
21 changes: 8 additions & 13 deletions packages/apollo-fragment-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@
"threshold": "1 Kb"
}
],
"dependencies": {
"@apollo/client": "^3.5.6",
"apollo-fragment-utils": "^0.2.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll need to bump the version of apollo-fragment-utils once it gets published with the changes. Wondering if there's a better way to do that with lerna... or if this has to be a two step operation

"compose-tiny": "^1.1.3"
},
"peerDependencies": {
"@apollo/client": "^3.5.6"
},
"devDependencies": {
"@types/graphql": "0.11.5",
"@types/jest": "22.1.x",
"apollo-cache-inmemory": "^1.1.5",
"@apollo/client": "^3.5.6",
"apollo-link": "^1.0.0",
"browserify": "14.5.0",
"bundlesize": "0.15.3",
"codecov": "3.0.0",
"bundlesize": "^0.18.1",
"codecov": "^3.8.2",
"danger": "1.2.0",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"graphql": "0.11.7",
"graphql-tag": "2.5.0",
"graphql": "16.0.1",
"jest": "21.2.1",
"lint-staged": "4.3.0",
"pre-commit": "1.2.2",
Expand Down Expand Up @@ -89,11 +89,6 @@
"<rootDir>/src/mocks/enzymeAdapter.ts"
]
},
"dependencies": {
"apollo-fragment-utils": "^0.2.1",
"apollo-utilities": "^1.0.12",
"compose-tiny": "^1.1.3"
},
"lint-staged": {
"*.ts*": [
"prettier --trailing-comma all --single-quote --write",
Expand Down
9 changes: 2 additions & 7 deletions packages/apollo-fragment-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,12 @@
}
],
"devDependencies": {
"@types/graphql": "0.11.5",
"@types/jest": "22.1.x",
"apollo-cache-inmemory": "^1.1.5",
"apollo-client": "^2.2.0",
"apollo-link": "^1.0.0",
"browserify": "14.5.0",
"bundlesize": "0.15.3",
"codecov": "3.0.0",
"danger": "1.2.0",
"graphql": "0.11.7",
"graphql-tag": "2.5.0",
"graphql": "16.0.1",
"jest": "21.2.1",
"lint-staged": "4.3.0",
"pre-commit": "1.2.2",
Expand All @@ -67,7 +62,7 @@
"uglify-js": "3.1.5"
},
"dependencies": {
"apollo-utilities": "^1.0.12"
"@apollo/client": "^3.5.6"
},
"jest": {
"mapCoverage": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-fragment-utils/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import gql from 'graphql-tag';
import { gql } from '@apollo/client/core';
import { getFragmentInfo, buildFragmentQuery } from '../';

describe('getFragmentInfo', () => {
Expand Down
33 changes: 22 additions & 11 deletions packages/apollo-fragment-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
import gql from 'graphql-tag';
import { DocumentNode } from 'graphql';
import { gql } from '@apollo/client/core';
import { DocumentNode, Kind } from 'graphql';

export function getFragmentInfo(fragment: string | DocumentNode) {
const fragmentAST = typeof fragment === `string` ? gql(fragment) : fragment;
const fragmentDefinitions =
fragmentAST.definitions && fragmentAST.definitions[0];
const fragmentName = fragmentDefinitions && fragmentDefinitions.name.value;
const fragmentTypeName =
fragmentDefinitions && fragmentDefinitions.typeCondition.name.value;
// ensure we are working with the right kind of definition, otherwise throw warning
if (
fragmentAST.definitions &&
fragmentAST.definitions[0] &&
fragmentAST.definitions[0].kind === Kind.FRAGMENT_DEFINITION
) {
Comment on lines +7 to +11
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to make some updates here for TS to compile.

Would appreciate feedback on the console.warn usage here

const fragmentDefinitions =
fragmentAST.definitions && fragmentAST.definitions[0];
const fragmentName = fragmentDefinitions && fragmentDefinitions.name.value;
const fragmentTypeName =
fragmentDefinitions && fragmentDefinitions.typeCondition.name.value;

return {
fragmentName,
fragmentTypeName,
};
return {
fragmentName,
fragmentTypeName,
};
} else {
console.warn(
`Received fragment with definition kind: ${fragmentAST.definitions[0].kind} but ${Kind.FRAGMENT_DEFINITION} is required`,
);
}
}

export type buildFragmentQueryType = {
Expand Down
10 changes: 2 additions & 8 deletions packages/apollo-link-state-fragment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,12 @@
"apollo-link-state": "0.4.1"
},
"devDependencies": {
"@types/graphql": "0.11.5",
"@types/jest": "22.1.x",
"apollo-cache-inmemory": "^1.1.5",
"apollo-client": "^2.2.0",
"apollo-link": "^1.0.0",
"apollo-link-state": "^0.4.1",
"browserify": "14.5.0",
"bundlesize": "0.15.3",
"codecov": "3.0.0",
"danger": "1.2.0",
"graphql": "0.11.7",
"graphql-tag": "2.5.0",
"graphql": "16.0.1",
"jest": "21.2.1",
"lint-staged": "4.3.0",
"pre-commit": "1.2.2",
Expand Down Expand Up @@ -84,7 +78,7 @@
]
},
"dependencies": {
"apollo-utilities": "^1.0.12"
"@apollo/client": "^3.5.6"
},
"lint-staged": {
"*.ts*": [
Expand Down
12 changes: 8 additions & 4 deletions packages/apollo-link-state-fragment/src/__tests__/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import gql from 'graphql-tag';
import { ApolloLink, execute, Observable } from 'apollo-link';
import { ApolloClient } from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import {
ApolloClient,
InMemoryCache,
ApolloLink,
execute,
Observable,
gql,
} from '@apollo/client';
import mockLink from '../mocks/mockLink';
import { fragmentCacheRedirect, fragmentLinkState } from '../';

Expand Down
14 changes: 8 additions & 6 deletions packages/apollo-link-state-fragment/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { toIdValue, IdValue } from 'apollo-utilities';
import { ApolloLink } from 'apollo-link';
import { withClientState } from 'apollo-link-state';
import { ApolloCache } from 'apollo-cache';
import { defaultDataIdFromObject } from 'apollo-cache-inmemory';
import {
defaultDataIdFromObject,
ApolloLink,
ApolloCache,
ApolloClient,
} from '@apollo/client';
import { toIdValue, IdValue } from '@apollo/client/utilities';

type GetFragmentType = {
__typename: string;
Expand All @@ -20,7 +22,7 @@ export function fragmentCacheRedirect(
}

export function fragmentLinkState(apolloCache: ApolloCache<any>): ApolloLink {
return withClientState({
return new ApolloClient({
cache: apolloCache,
resolvers: {
Query: {
Expand Down
7 changes: 3 additions & 4 deletions packages/apollo-link-state-fragment/src/mocks/mockLink.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { graphql, print } from 'graphql';
import {
Operation,
GraphQLRequest,
ApolloLink,
FetchResult,
FetchResult, // Observer,
Observable,
// Observer,
} from 'apollo-link';
} from '@apollo/client';
import { graphql, print } from 'graphql';
import { schema } from './mockSchema';

export default new ApolloLink(operation => {
Expand Down