From 4533445b8e852397f7b7b533a1501f515ed52f8f Mon Sep 17 00:00:00 2001 From: ZauberNerd Date: Wed, 22 Nov 2017 10:45:45 +0100 Subject: [PATCH] refactor(template-react): remove graphql from default template This commit removes the `hops-graphql` support from the default `hops-template-react`. BREAKING CHANGE: `hops-template-react` (default template) now no longer supports graphql out of the box. You can add the support yourself again or use a different template (we will provide a new `hops-template-graphql` shortly). Closes: #276 --- packages/template-react/package.json | 7 ++-- packages/template-react/src/app.js | 2 +- packages/template-react/src/home/commits.gql | 20 ----------- packages/template-react/src/home/home.js | 36 +++++++------------ .../home/spec/__snapshots__/home.spec.js.snap | 23 +----------- .../template-react/src/home/spec/home.spec.js | 27 ++------------ yarn.lock | 27 ++------------ 7 files changed, 21 insertions(+), 121 deletions(-) delete mode 100644 packages/template-react/src/home/commits.gql diff --git a/packages/template-react/package.json b/packages/template-react/package.json index a4fd739e5..9b88f9fe9 100644 --- a/packages/template-react/package.json +++ b/packages/template-react/package.json @@ -9,8 +9,7 @@ "locations": [ "/", "/counter" - ], - "graphqlUri": "https://www.graphqlhub.com/graphql" + ] } }, "scripts": { @@ -21,12 +20,10 @@ "flow": "flow" }, "dependencies": { - "graphql-tag": "^2.5.0", "hops-express": "7.3.4", - "hops-graphql": "7.4.1", "hops-react": "7.4.0", + "hops-redux": "7.4.0", "react": "^16.0.0", - "react-apollo": "^2.0.0", "react-dom": "^16.0.0", "react-helmet": "^5.2.0", "react-redux": "^5.0.6", diff --git a/packages/template-react/src/app.js b/packages/template-react/src/app.js index 04ff2ba02..cd867e8a0 100644 --- a/packages/template-react/src/app.js +++ b/packages/template-react/src/app.js @@ -3,7 +3,7 @@ import React from 'react'; import { Route, Switch, Link } from 'react-router-dom'; import { render, Miss } from 'hops-react'; -import { createContext } from 'hops-graphql'; +import { createContext } from 'hops-redux'; import { Home } from './home'; import { Counter } from './counter'; diff --git a/packages/template-react/src/home/commits.gql b/packages/template-react/src/home/commits.gql deleted file mode 100644 index 775385394..000000000 --- a/packages/template-react/src/home/commits.gql +++ /dev/null @@ -1,20 +0,0 @@ -{ - github { - repo(ownerUsername: "xing", name: "hops") { - id - name - commits(limit: 10) { - ... on GithubCommit { - sha - message - author { - ... on GithubUser { - id - login - } - } - } - } - } - } -} diff --git a/packages/template-react/src/home/home.js b/packages/template-react/src/home/home.js index 01d538f18..b70ea9a55 100644 --- a/packages/template-react/src/home/home.js +++ b/packages/template-react/src/home/home.js @@ -1,31 +1,19 @@ // @flow import React from 'react'; import Helmet from 'react-helmet'; -import { graphql } from 'react-apollo'; import styles from './styles.css'; -import query from './commits.gql'; -export const withCommits = graphql(query); -export const Home = ({ data: { loading, github } }) => ( -
- - Hops Demo - -

- Hello World! -

- { - (loading) - ? (

Loading...

) - : (github.repo.commits.map(commit => ( -

- "{commit.message}" by {commit.author.login} -

- ))) - } -
-); - -export default withCommits(Home); +export default function Home () { + return ( +
+ + Hops Demo + +

+ Hello World! +

+
+ ); +} diff --git a/packages/template-react/src/home/spec/__snapshots__/home.spec.js.snap b/packages/template-react/src/home/spec/__snapshots__/home.spec.js.snap index fc4b55b62..9ebd7f5a6 100644 --- a/packages/template-react/src/home/spec/__snapshots__/home.spec.js.snap +++ b/packages/template-react/src/home/spec/__snapshots__/home.spec.js.snap @@ -1,32 +1,11 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`renders loaded state correctly 1`] = ` +exports[`renders correctly 1`] = `

Hello World!

-

- " - bar - " by - - baz - -

-
-`; - -exports[`renders loading state correctly 1`] = ` -
-

- Hello World! -

-

- Loading... -

`; diff --git a/packages/template-react/src/home/spec/home.spec.js b/packages/template-react/src/home/spec/home.spec.js index 54f64880d..24455fbf9 100644 --- a/packages/template-react/src/home/spec/home.spec.js +++ b/packages/template-react/src/home/spec/home.spec.js @@ -2,32 +2,11 @@ import React from 'react'; import renderer from 'react-test-renderer'; -import { Home } from '../home'; +import { Home } from '../'; -it('renders loading state correctly', () => { +it('renders correctly', () => { const tree = renderer.create( - - ).toJSON(); - expect(tree).toMatchSnapshot(); -}); - -it('renders loaded state correctly', () => { - const data = { - loading: false, - github: { - repo: { - commits: [{ - sha: 'foo', - message: 'bar', - author: { - login: 'baz' - } - }] - } - } - }; - const tree = renderer.create( - + ).toJSON(); expect(tree).toMatchSnapshot(); }); diff --git a/yarn.lock b/yarn.lock index ecf8b201a..e633f9619 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3162,10 +3162,6 @@ graphql-anywhere@^4.0.1: dependencies: apollo-utilities "^1.0.2" -graphql-tag@^2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.5.0.tgz#b43bfd8b5babcd2c205ad680c03e98b238934e0f" - graphql@^0.11.7: version "0.11.7" resolved "https://registry.yarnpkg.com/graphql/-/graphql-0.11.7.tgz#e5abaa9cb7b7cccb84e9f0836bf4370d268750c6" @@ -3353,7 +3349,7 @@ hoek@4.x.x: version "4.2.0" resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.0.tgz#72d9d0754f7fe25ca2d01ad8f8f9a9449a89526d" -hoist-non-react-statics@^2.2.0, hoist-non-react-statics@^2.2.1, hoist-non-react-statics@^2.3.0: +hoist-non-react-statics@^2.2.1, hoist-non-react-statics@^2.3.0: version "2.3.1" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.3.1.tgz#343db84c6018c650778898240135a1420ee22ce0" @@ -4383,10 +4379,6 @@ lodash.cond@^4.3.0: version "4.5.2" resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5" -lodash.flowright@^3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/lodash.flowright/-/lodash.flowright-3.5.0.tgz#2b5fff399716d7e7dc5724fe9349f67065184d67" - lodash.map@^4.5.1: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3" @@ -4395,10 +4387,6 @@ lodash.memoize@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" -lodash.pick@^4.4.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" - lodash.reduce@4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.reduce/-/lodash.reduce-4.6.0.tgz#f1ab6b839299ad48f784abbf476596f03b914d3b" @@ -5786,7 +5774,7 @@ promise@^7.1.1: dependencies: asap "~2.0.3" -prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.5.8, prop-types@^15.6.0: +prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.6.0: version "15.6.0" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856" dependencies: @@ -5928,17 +5916,6 @@ rc@^1.0.1, rc@^1.1.6, rc@^1.1.7: minimist "^1.2.0" strip-json-comments "~2.0.1" -react-apollo@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/react-apollo/-/react-apollo-2.0.1.tgz#43997db9f294d81bd229eb705944fb36d5164607" - dependencies: - apollo-link "^1.0.0" - hoist-non-react-statics "^2.2.0" - invariant "^2.2.1" - lodash.flowright "^3.5.0" - lodash.pick "^4.4.0" - prop-types "^15.5.8" - react-dom@^16.0.0: version "16.1.1" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.1.1.tgz#b2e331b6d752faf1a2d31399969399a41d8d45f8"