Skip to content

Commit 07e17fd

Browse files
committed
1.6.0
1.6.0 - 2017-06-06 ------------------------------------------------ ## GraphQL * Adds `graphql-tag` loader, for storing queries in `.gql|graphql` files (closes #32) * Refactors `src/app.js` to use file queries * Adds `src/queries/all_messages.gql`, for retrieving GraphCool endpoint messages * Adds `src/queries/message.gql`, imported by `all_messages.gql` as a query fragment ## Webpack * Adds `graphql-tag` loader config to `kit/webpack/base.js` ## NPM * Adds packages: "graphql-tag": "^2.2.1"
1 parent 80f74a0 commit 07e17fd

File tree

7 files changed

+47
-12
lines changed

7 files changed

+47
-12
lines changed

CHANGELOG

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
1.6.0 - 2017-06-06
2+
------------------------------------------------
3+
4+
## GraphQL
5+
* Adds `graphql-tag` loader, for storing queries in `.gql|graphql` files (closes #32)
6+
* Refactors `src/app.js` to use file queries
7+
* Adds `src/queries/all_messages.gql`, for retrieving GraphCool endpoint messages
8+
* Adds `src/queries/message.gql`, imported by `all_messages.gql` as a query fragment
9+
10+
## Webpack
11+
* Adds `graphql-tag` loader config to `kit/webpack/base.js`
12+
13+
## NPM
14+
* Adds packages:
15+
"graphql-tag": "^2.2.1"
16+
117
1.5.3 - 2017-06-06
218
------------------------------------------------
319

kit/webpack/base.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ export default new WebpackConfig().merge({
6363
},
6464
},
6565

66+
// GraphQL queries
67+
{
68+
test: /\.(graphql|gql)$/,
69+
exclude: /node_modules/,
70+
loader: 'graphql-tag/loader',
71+
},
72+
6673
// Images. By default, we'll just use the file loader. In production,
6774
// we'll also crunch the images first -- so let's set up `loaders` to
6875
// be an array to make extending this easier

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"eslint-plugin-react": "^7.0.1",
4949
"extract-text-webpack-plugin": "^2.1.0",
5050
"file-loader": "^0.11.1",
51+
"graphql-tag": "^2.2.1",
5152
"html-webpack-plugin": "^2.28.0",
5253
"image-webpack-loader": "^3.3.1",
5354
"less": "^2.7.2",

src/app.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// ----------------------
22
// IMPORTS
33

4+
/* NPM */
5+
46
// React
57
import React from 'react';
68
import PropTypes from 'prop-types';
79

810
// GraphQL
9-
import { gql, graphql } from 'react-apollo';
11+
import { graphql } from 'react-apollo';
1012

1113
// Routing
1214
import {
@@ -18,9 +20,14 @@ import {
1820
// <Helmet> component for setting the page title
1921
import Helmet from 'react-helmet';
2022

23+
/* Local */
24+
2125
// NotFound 404 handler for unknown routes
2226
import { NotFound, Redirect } from 'kit/lib/routing';
2327

28+
// GraphQL queries
29+
import allMessages from 'src/queries/all_messages.gql';
30+
2431
// Styles
2532
import './styles.global.css';
2633
import css from './styles.css';
@@ -79,20 +86,10 @@ const Stats = () => {
7986

8087
// Now, let's create a GraphQL-enabled component...
8188

82-
// First, create the GraphQL query that we'll use to request data from our
83-
// sample endpoint
84-
const query = gql`
85-
query {
86-
allMessages(first:1) {
87-
text
88-
}
89-
}
90-
`;
91-
9289
// ... then, let's create the component and decorate it with the `graphql`
9390
// HOC that will automatically populate `this.props` with the query data
9491
// once the GraphQL API request has been completed
95-
@graphql(query)
92+
@graphql(allMessages)
9693
class GraphQLMessage extends React.PureComponent {
9794
static propTypes = {
9895
data: PropTypes.shape({

src/queries/all_messages.gql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#import "./message.gql"
2+
3+
query AllMessages {
4+
allMessages(first:1) {
5+
...Message
6+
}
7+
}

src/queries/message.gql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fragment Message on Message {
2+
text
3+
}

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3315,6 +3315,10 @@ graphql-tag@^2.0.0:
33153315
version "2.2.0"
33163316
resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.2.0.tgz#9ea24f35a19aab1be1e55675928344d84d852905"
33173317

3318+
graphql-tag@^2.2.1:
3319+
version "2.2.1"
3320+
resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.2.1.tgz#1da61feb6c6fc119ee8c579c4de424d389bee0c2"
3321+
33183322
graphql@^0.10.0:
33193323
version "0.10.1"
33203324
resolved "https://registry.yarnpkg.com/graphql/-/graphql-0.10.1.tgz#75c93c2ce73aeb5bae2eefb555a8e9e39c36027d"

0 commit comments

Comments
 (0)