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

Switch to React Apollo 3 #1134

Merged
merged 7 commits into from
Aug 12, 2019
Merged
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: node_js
node_js:
- '10'
cache: yarn
dist: xenial
dist: bionic
os:
- linux
script:
Expand Down
4 changes: 3 additions & 1 deletion modules/chat/client-react/containers/ChatOperations.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react';
import PropTypes from 'prop-types';
import { compose, graphql } from 'react-apollo/index';
import { graphql } from 'react-apollo';
import update from 'immutability-helper';

import { compose } from '@gqlapp/core-common';
import { translate } from '@gqlapp/i18n-client-react';
import { withUser } from '@gqlapp/user-client-react';
import settings from '@gqlapp/config';
Expand Down
1 change: 1 addition & 0 deletions modules/core/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export { default as createApolloClient } from './createApolloClient';
export { default as createReduxStore } from './createReduxStore';
export * from './createReduxStore';
export * from './utils';
export { flowRight as compose } from 'lodash';
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,9 @@ interface CounterProps {

const ClientCounter = ({ t }: CounterProps) => (
<Query query={COUNTER_QUERY_CLIENT}>
{({
data: {
clientCounter: { amount }
}
}: any) => {
return (
<ClientCounterView text={t('text', { amount })}>
{({ data, loading }: any) => {
return loading ? null : (
<ClientCounterView text={t('text', { amount: data.clientCounter.amount })}>
<IncreaseButton t={t} counterAmount={1} />
</ClientCounterView>
);
Expand Down
8 changes: 4 additions & 4 deletions modules/pagination/client-react/containers/DataProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ const allEdges = generateEdgesArray(47);
export const useDataProvider = () => {
const [items, setItems] = useState(null);

useEffect(() => {
loadData(0, 'replace');
}, [loadData]);

const loadData = useCallback(
(offset, dataDelivery) => {
const newEdges = allEdges.slice(offset, offset + itemsNumber);
Expand All @@ -40,6 +36,10 @@ export const useDataProvider = () => {
[items]
);

useEffect(() => {
loadData(0, 'replace');
});

return { items, loadData };
};

Expand Down
4 changes: 2 additions & 2 deletions modules/post/client-react/containers/Post.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import PropTypes from 'prop-types';
import { graphql, compose } from 'react-apollo';
import { graphql } from 'react-apollo';
import update from 'immutability-helper';

import { PLATFORM } from '@gqlapp/core-common';
import { compose, PLATFORM } from '@gqlapp/core-common';
import settings from '@gqlapp/config';

import PostList from '../components/PostList';
Expand Down
4 changes: 2 additions & 2 deletions modules/post/client-react/containers/Post.web.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { graphql, compose } from 'react-apollo';
import { graphql } from 'react-apollo';
import update from 'immutability-helper';

import { PLATFORM } from '@gqlapp/core-common';
import { compose, PLATFORM } from '@gqlapp/core-common';
import settings from '@gqlapp/config';

import PostList from '../components/PostList';
Expand Down
4 changes: 3 additions & 1 deletion modules/post/client-react/containers/PostComments.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react';
import PropTypes from 'prop-types';
import { graphql, compose } from 'react-apollo';
import { graphql } from 'react-apollo';
import update from 'immutability-helper';

import { compose } from '@gqlapp/core-common';

import PostCommentsView from '../components/PostCommentsView';

import POST_QUERY from '../graphql/PostQuery.graphql';
Expand Down
4 changes: 3 additions & 1 deletion modules/post/client-react/containers/PostComments.web.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { graphql, compose } from 'react-apollo';
import { graphql } from 'react-apollo';
import update from 'immutability-helper';

import { compose } from '@gqlapp/core-common';

import PostCommentsView from '../components/PostCommentsView';

import POST_QUERY from '../graphql/PostQuery.graphql';
Expand Down
4 changes: 3 additions & 1 deletion modules/post/client-react/containers/PostEdit.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import { compose, graphql } from 'react-apollo';
import { graphql } from 'react-apollo';

import { compose } from '@gqlapp/core-common';

import PostEditView from '../components/PostEditView';

Expand Down
4 changes: 3 additions & 1 deletion modules/post/client-react/containers/PostEdit.web.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { compose, graphql } from 'react-apollo';
import { graphql } from 'react-apollo';

import { compose } from '@gqlapp/core-common';

import PostEditView from '../components/PostEditView';

Expand Down
5 changes: 4 additions & 1 deletion modules/upload/client-react/containers/Upload.native.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React from 'react';
import PropTypes from 'prop-types';
import { graphql, compose } from 'react-apollo';
import { graphql } from 'react-apollo';

import { compose } from '@gqlapp/core-common';
import { translate } from '@gqlapp/i18n-client-react';

import UploadView from '../components/UploadView';
import FILES_QUERY from '../graphql/FilesQuery.graphql';
import UPLOAD_FILES from '../graphql/UploadFiles.graphql';
Expand Down
5 changes: 4 additions & 1 deletion modules/upload/client-react/containers/Upload.web.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { graphql, compose } from 'react-apollo';
import { graphql } from 'react-apollo';

import { compose } from '@gqlapp/core-common';
import { translate } from '@gqlapp/i18n-client-react';

import UploadView from '../components/UploadView';
import FILES_QUERY from '../graphql/FilesQuery.graphql';
import UPLOAD_FILES from '../graphql/UploadFiles.graphql';
Expand Down
4 changes: 3 additions & 1 deletion modules/user/client-react/containers/ForgotPassword.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { compose, graphql } from 'react-apollo';
import { graphql } from 'react-apollo';

import { compose } from '@gqlapp/core-common';
import { translate } from '@gqlapp/i18n-client-react';
import { FormError } from '@gqlapp/forms-client-react';

import ForgotPasswordView from '../components/ForgotPasswordView';

import FORGOT_PASSWORD from '../graphql/ForgotPassword.graphql';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import { graphql, compose } from 'react-apollo';
import { graphql } from 'react-apollo';

import { compose } from '@gqlapp/core-common';
import { translate } from '@gqlapp/i18n-client-react';
import { FormError } from '@gqlapp/forms-client-react';

import ForgotPasswordView from '../components/ForgotPasswordView';

import FORGOT_PASSWORD from '../graphql/ForgotPassword.graphql';
Expand Down
5 changes: 3 additions & 2 deletions modules/user/client-react/containers/Login.native.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import PropTypes from 'prop-types';
import { graphql, compose, withApollo } from 'react-apollo';
import { graphql, withApollo } from 'react-apollo';

import { compose } from '@gqlapp/core-common';
import { translate } from '@gqlapp/i18n-client-react';
import { FormError } from '@gqlapp/forms-client-react';

import authentication from '@gqlapp/authentication-client-react';

import LoginView from '../components/LoginView';
Expand Down
4 changes: 3 additions & 1 deletion modules/user/client-react/containers/Login.web.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { graphql, compose, withApollo } from 'react-apollo';
import { graphql, withApollo } from 'react-apollo';

import { compose } from '@gqlapp/core-common';
import { translate } from '@gqlapp/i18n-client-react';
import { FormError } from '@gqlapp/forms-client-react';

Expand Down
3 changes: 2 additions & 1 deletion modules/user/client-react/containers/Logout.native.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import { View } from 'react-native';
import { compose } from 'react-apollo';

import { compose } from '@gqlapp/core-common';
import { HeaderTitle } from '@gqlapp/look-client-react-native';
import { translate } from '@gqlapp/i18n-client-react';

Expand Down
6 changes: 2 additions & 4 deletions modules/user/client-react/containers/Profile.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// React
import React from 'react';
import { graphql } from 'react-apollo';

// Apollo
import { graphql, compose } from 'react-apollo';
import { compose } from '@gqlapp/core-common';

// Components
import ProfileView from '../components/ProfileView';

import CURRENT_USER_QUERY from '../graphql/CurrentUserQuery.graphql';
Expand Down
3 changes: 2 additions & 1 deletion modules/user/client-react/containers/Register.native.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import { graphql, compose } from 'react-apollo';
import { graphql } from 'react-apollo';

import { compose } from '@gqlapp/core-common';
import { translate } from '@gqlapp/i18n-client-react';
import { FormError } from '@gqlapp/forms-client-react';
import settings from '@gqlapp/config';
Expand Down
3 changes: 2 additions & 1 deletion modules/user/client-react/containers/Register.web.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { graphql, compose } from 'react-apollo';
import { graphql } from 'react-apollo';

import { compose } from '@gqlapp/core-common';
import { translate } from '@gqlapp/i18n-client-react';
import { FormError } from '@gqlapp/forms-client-react';
import settings from '@gqlapp/config';
Expand Down
7 changes: 5 additions & 2 deletions modules/user/client-react/containers/ResetPassword.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import { compose, graphql } from 'react-apollo';
import { translate } from '@gqlapp/i18n-client-react';
import { graphql } from 'react-apollo';

import { compose } from '@gqlapp/core-common';
import { translate } from '@gqlapp/i18n-client-react';
import { FormError } from '@gqlapp/forms-client-react';

import ResetPasswordView from '../components/ResetPasswordView';

import RESET_PASSWORD from '../graphql/ResetPassword.graphql';

const ResetPassword = props => {
Expand Down
3 changes: 2 additions & 1 deletion modules/user/client-react/containers/UserAdd.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import PropTypes from 'prop-types';
import { compose, graphql } from 'react-apollo';
import { graphql } from 'react-apollo';
import { pick } from 'lodash';

import { compose } from '@gqlapp/core-common';
import { translate } from '@gqlapp/i18n-client-react';
import { FormError } from '@gqlapp/forms-client-react';
import settings from '@gqlapp/config';
Expand Down
3 changes: 2 additions & 1 deletion modules/user/client-react/containers/UserEdit.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import PropTypes from 'prop-types';
import { compose, graphql } from 'react-apollo';
import { graphql } from 'react-apollo';
import { pick } from 'lodash';

import { compose } from '@gqlapp/core-common';
import { translate } from '@gqlapp/i18n-client-react';
import { FormError } from '@gqlapp/forms-client-react';
import settings from '@gqlapp/config';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { createAppContainer, createDrawerNavigator } from 'react-navigation';
import React from 'react';
import PropTypes from 'prop-types';
import { pickBy } from 'lodash';
import { compose } from 'react-apollo';

import { compose } from '@gqlapp/core-common';
import { DrawerComponent } from '@gqlapp/look-client-react-native';

import { withUser } from './Auth';
Expand Down
3 changes: 2 additions & 1 deletion modules/user/client-react/containers/Users.native.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import { StyleSheet, View } from 'react-native';
import PropTypes from 'prop-types';
import { compose } from 'react-apollo';

import { compose } from '@gqlapp/core-common';

import UsersList from '../components/UsersListView';
import UsersFilter from '../components/UsersFilterView';
Expand Down
9 changes: 5 additions & 4 deletions modules/user/client-react/containers/Users.web.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import Helmet from 'react-helmet';
import { Link } from 'react-router-dom';
import { compose } from 'react-apollo';

import { compose } from '@gqlapp/core-common';
import { translate } from '@gqlapp/i18n-client-react';
import { Button, PageLayout } from '@gqlapp/look-client-react';
import settings from '@gqlapp/config';
Expand All @@ -21,7 +21,8 @@ import {
} from './UserOperations';

const Users = props => {
const { t, updateQuery, subscribeToMore, filter } = props;
const { t, updateQuery, subscribeToMore } = props;
const filter = { isActive: true };
const usersUpdated = useUsersWithSubscription(subscribeToMore, filter);

useEffect(() => {
Expand Down Expand Up @@ -50,9 +51,9 @@ const Users = props => {
<Button color="primary">{t('users.btn.add')}</Button>
</Link>
<hr />
<UsersFilterView {...props} />
<UsersFilterView {...props} filter={filter} />
<hr />
<UsersListView {...props} />
<UsersListView {...props} filter={filter} />
</PageLayout>
);
};
Expand Down
4 changes: 2 additions & 2 deletions modules/user/client-react/containers/withSubscription.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export const useUsersWithSubscription = (subscribeToMore, filter) => {
const [usersUpdated, setUsersUpdated] = useState(null);

useEffect(() => {
const subscribe = subscribeToUsers();
return () => subscribe();
const unsubscribe = subscribeToUsers();
return () => unsubscribe();
});

const subscribeToUsers = () => {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"sass-loader": "^7.1.0",
"shelljs": "^0.8.1",
"source-list-map": "^2.0.0",
"style-loader": "^0.23.0",
"style-loader": "^1.0.0",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"ts-loader": "^4.5.0",
Expand Down Expand Up @@ -191,7 +191,7 @@
"hard-source-webpack-plugin": "https://github.com/conorh/hard-source-webpack-plugin",
"kleur": "^3.0.3",
"immutability-helper": "2.8.1",
"graphql": "14.1.1",
"graphql": "14.3.1",
"iterall": "^1.2.2",
"upath": "^1.1.0",
"watchpack": "https://github.com/Globegitter/watchpack"
Expand Down
2 changes: 1 addition & 1 deletion packages/client-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"apollo-link-ws": "^1.0.17",
"apollo-logger": "^0.3.2",
"apollo-upload-client": "^10.0.1",
"graphql": "^14.1.1",
"graphql": "^14.3.1",
"minilog": "^3.1.0",
"rxjs": "^6.5.2",
"subscriptions-transport-ws": "^0.9.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/client-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"error-stack-parser": "^2.0.1",
"extract-files": "^5.0.0",
"filesize": "^3.5.11",
"graphql": "^14.1.1",
"graphql": "^14.3.1",
"graphql-iso-date": "^3.5.0",
"graphql-tag": "^2.6.0",
"history": "^4.7.2",
Expand Down
Loading