kit

ReactQL starter kit (use the CLI)

Stars
229
Committers
14

Bot releases are visible (Hide)

kit - 2.3.0

Published by leebenson about 7 years ago

2.3.0 - 2017-08-17

GraphQL

  • Adds GraphiQL IDE by default to /graphql when using external GraphQL endpoint
  • Allows explicit GraphiQL IDE endpoint to be set on config.enableGraphQLServer|setGraphQLEndpoint()
  • Updates GraphiQL endpoint to match internal GraphQL POST endpoint URL by default (falls back to /graphql)

Config

  • Breaking change -- now config.enableGraphQLServer() should be called isomorphically!
  • Adds explicit config.setGraphQLSchema() for passing the schema to the GraphQL server (use inside a SERVER block only!)
kit - 2.2.0

Published by leebenson about 7 years ago

2.2.0 - 2017-08-17

NPM

  • Bumps packages:
    regenerator-runtime ^0.10.5 → ^0.11.0
    eslint-plugin-jsx-a11y ^5.1.1 → ^6.0.2
    apollo-server-koa ^1.0.5 → ^1.1.0
    react-apollo ^1.4.8 → ^1.4.14
    react-redux ^5.0.5 → ^5.0.6
    react-router ^4.1.1 → ^4.1.2
    react-router-dom ^4.1.1 → ^4.1.2
    redux ^3.7.1 → ^3.7.2
    babel-core ^6.25.0 → ^6.26.0
    babel-plugin-transform-object-rest-spread ^6.23.0 → ^6.26.0
    babel-plugin-transform-regenerator ^6.24.1 → ^6.26.0
    babel-polyfill ^6.23.0 → ^6.26.0
    cross-env ^5.0.4 → ^5.0.5
    css-loader ^0.28.4 → ^0.28.5
    eslint-plugin-react ^7.1.0 → ^7.2.1
    html-webpack-plugin ^2.29.0 → ^2.30.1
    less-loader ^4.0.4 → ^4.0.5
    postcss-nested ^2.1.0 → ^2.1.2
    progress-bar-webpack-plugin ^1.9.3 → ^1.10.0
    webpack ^3.4.1 → ^3.5.5
    webpack-bundle-analyzer ^2.8.2 → ^2.9.0
    webpack-config ^7.0.0 → ^7.2.1
    webpack-dev-server ^2.6.1 → ^2.7.1
    webpack-manifest-plugin ^1.2.1 → ^1.3.1
kit - 2.1.0

Published by leebenson about 7 years ago

2.1.0 - 2017-08-07

Production

  • Fixes production server run error introduced by when diagnosing #55
  • Fixes docker image building

NPM

  • Bumps packages:
  • "cross-env": "^5.0.4"
  • "eslint": "^4.4.1"
  • "chalk": "^2.1.0"
kit - 2.0.0

Published by leebenson about 7 years ago

2.0.0 - 2017-08-06

New features in 2.0.0

Kit v2 introduces a few significant improvements that make it easier to upgrade between kits, and power-up your ReactQL experience:

React v16 + new streaming SSR

React has been bumped to the new v16, and renderToString has been replaced with renderToStream -- for turbo-powered first page rendering of React to HTML.

Early tests have shown a promising reduction from 12ms+ for React-only rendering (no GraphQL) to 4-5ms on my local Macbook Pro, using out-the-box defaults.

What's more, on Node 8+, the asynchronous createReactHandler that sets up the Redux store, runs Helmet, initialises the component tree and starts the stream, has been benchmarked as low as 0.48ms on my same machine!

Your ReactQL project will be faster than ever.

Kit API - a cleaner separation between 'kit' and 'app' code

In kit v1.x, the lines between ReactQL and your client code were a little blurry. Editing the Apollo endpoint meant modifying config/project.js, which was a file that Webpack also used to assess whether to show the bundle optimiser post-build.

If you wanted to add anything more to the server or browser, you'd typically need to delve into kit/* files and make changes.

Now, the separation between two is clearer than ever. ReactQL v2.x introduces a new Config singleton instance that provides 'hooks' into adding functionality to the standard config, without mashing together custom code.

ReactQL is and always has been a 'starter kit', and will continue to be so. But now the framework-esque separation of client and kit code paves the way to clean abstractions, and easier upgrading.

In a future ReactQL CLI version, it's possible that you'll be able to upgrade an active project to the latest kit with a single command, instead of the current process of creating a new project, copying over src and manually/surgically editing kit files.

Built-in GraphQL server.

ReactQL was originally focused on being a front-end starter kit. But the effort put into creating a fast and capable SSR stack means you now also have an ideal home to run a monolithic GraphQL server, too.

Starting with 2.0, you're now able to add a GraphQL server easily, by add a few lines of code to src/app.js:

src/app.js

// Import the new `Config` singleton instance
import config from `kit/config`;

// Enable GraphQL on the server -- this code will be eliminated from the browser bundle
if (SERVER) {
  config.enableGraphQLServer(require('src/path/to/schema').default);
}

That's it!

The above mounts a GraphQL server inside Koa at /graphql, gives you a visual UI to query data via GraphiQL, and sets up Apollo to point to the server URI automatically. It takes care of your server-side CORS config, and adds POST body processing for incoming GraphQL queries.

It also adds apollo-local-query to Apollo client initialisation on the server, so instead of routing requests over the network, GraphQL queries are made against the schema already loaded in memory -- eliminating TCP/IP overhead.

Of course, if you want to connect to a third-party endpoint, you can still do that easily:

config.setApolloURI('http://example.com/graphql');

(Special thanks to graph.cool for allowing us to use their service in the starter kit in 1.x. Hopefully the move above will also take some load off your server 😄)

Add Redux reducers more easily

With the new Config API, you no longer need to edit kit/lib/redux.js to add custom reducers.

Instead, you can add them to src/app.js and keep reducers in userland:

import config from `kit/config`;

// Create a reducer somewhere, shaped as { state, reducer() } -- this will
// probably be imported from a separate file
const someReducer = {
  // This is the reducer's initial state
  state: {
    someSetting: true,
  },
  reducer(state, action) {
    // ... reducer code to do something with `state`
  }
}

// Add the reducer, and specify the reducer key
settings.addReducer('someKey', someReducer);

Custom routes

You can now add custom GET|POST|PUT|PATCH routes to the server, like so:

// We can add custom routes to the web server easily, by using
// `config.add<Get|Post|Put|Patch>Route()`.  Note:  These are server routes only.
config.addGetRoute('/test', async ctx => {
  ctx.body = 'Hello from your ReactQL route.';
});

Routes will be added in insertion order, to obey your precedence rules.

POST body parsing

koa-bodyparser is enabled by default, to process POST requests for a built-in GraphQL server or custom POST routes.

By default, it'll process JSON and form requests automatically.

You can disable with:

config.disableBodyParser();

Or pass in your own custom options to koa-bodyparser with:

config.setBodyParserOptions({
  // Example of a config option -- see https://github.com/koajs/bodyparser
  jsonLimit: '8mb',
})

Custom 404 handler

The custom 404 handler added in 2.0 is one of several planned API 'hooks' that allow you to attach custom functionality to common server and browser entry points, without editing kit code.

This example ships in the starter kit:

config.set404Handler((ctx, store) => {
  // For demo purposes, let's get a JSON dump of the current Redux state
  // to see that we can expect its contents
  const stateDump = JSON.stringify(store.getState());

  // Explicitly set the return status to 404.  This is done for us by
  // default if we don't have a custom 404 handler, but left to the function
  // otherwise (since we might not always want to return a 404)
  ctx.status = 404;

  // Set the body
  ctx.body = `This route does not exist on the server - Redux dump: ${stateDump}`;
});

You get access to the Koa ctx request context object as well as the Redux store, giving you the flexibility to handle responses in whichever way makes the most sense for your application.

In future kits, expect hooks to crop up in places like redirect and error handling.

Neater src layout; more commentary

The out-the-box sample app that comes with a new ReactQL project is now better organised. Instead of a single src/app.js file, components have been given their own files/folders, and tons of extra commentary has been added to give you a better idea of what's happening under the hood.

Whilst src/app.js is still required in every project (that's where ReactQL will look for your app code), now the file should serve two simple purposes:

  1. Configuring the app, per the new features above.
  2. Exporting the root React component, to mount automatically inside <Html> -> <div id="main"/>

This best practice will make it easier to organise your code, and know what goes where.

Several components also demonstrate the pattern of asset co-location; images and SASS code is often in the same directory as the calling .js file, to make it clear which assets belong to which React components.


v2.0 documentation will land on https://reactql.org/docs soon.

All changes:

Code layout

  • Removes moot config/project.js

Configuration

  • Adds new Config class to kit/config.js, initialised as a singleton to use globally in src/app.js
  • Adds the following new methods:
  • addReducer(key, reducer) -- adds a new Redux reducer in the shape of {state, reducer()}
  • disableBodyParser() -- disables koa-bodyparser in the server config
  • setBodyParserOptions(opt) -- pass custom koa-bodyparser options to override defaults
  • addRoute(method, route, handler) -- add new Koa route
  • addGetRoute(route, handler) -- add new GET route
  • addPostRoute(route, handler) -- add new POST route
  • addPutRoute(route, handler) -- add new PUT route
  • addPatchRoute(route, handler) -- add new PATCH route
  • addDeleteRoute(route, handler) -- add new DELETE route
  • set404Handler(func) -- sets a custom 404 handler, which is given (state, store) inside createReactHandler()
  • enableGraphQLServer(schema, endpoint = '/graphql', graphiql = true) -- enables built-in GraphQL web server at /graphql, (optionally) enables up GraphiQL
  • setGraphQLEndpoint(uri) -- sets the GraphQL server URI for Apollo. For use with external GraphQL servers.

Browser

  • Replaces ReactDOM's deprecated render with the new hydrate method, for rehydrating server HTML.

Server

  • Bumps to React v16's streaming API.
  • React's data-reactid tags no longer appear in resulting HTML, saving bandwidth
  • Adds GraphQL server configuration
  • Adds GraphiQL UI option when using a local GraphQL server
  • Adds apollo-local-query, for bypassing the network when using a local GraphQL server
  • Adds createNeworkInterface(), for memoizing network interface creation on the server
  • Refactors React to use renderToStream instead of renderToStaticMarkup
  • Refactors <Html> component to take component tree as a child prop, and not as a rendered string
  • Adds custom route configuration
  • Adds kcors to allow cross-origin requests by default (for REST/GraphQL)

Libs

  • Removes serverClient() method in kit/lib/apollo.js, to avoid unnecessary apollo-local-query bundling on the browser
  • Improves getURL() in kit/lib/env.js, to allow a boolean flag to enable HTTPS
  • Adds getServerURL() to kit/lib/env.js, to explicitly get the web server host and port (typically for GraphQL)
  • Refactors kib/lib/redux.js to derive config from the config.reducers Map

Webpack

  • Adds new npm run build-analyze option, to open a browser window showing the bundle analysis report after building
  • Removes explicit BUNDLE_ANALYZER config option -- now uses the above command

App

  • Refactors app code to tidy up the src folder
  • Gives each component its own file/folder layout, with images/CSS co-located
  • Adds tons of extra commentary to make it clearer how each component works
  • Moves <root>/reducers to src/reducers, to reflect best practices
  • Refactors counter reducer to use the new {state, reducer()} reducer shape (now exported bare; no longer attached to a reducer key)
  • Refactors SASS/CSS to use separate files to be imported by components, instead of together in one file

General

  • Fixes spacing issues being reported in ESLInt 4.0
  • Shaves 9kb off vendor.<hash>.js bundle (383kb -> 374kb... 107kb gzipped... 90.9kb Brotli!)

NPM

  • Adds packages:
  • "apollo-local-query": "^0.3.0",
  • "apollo-server-koa": "^1.0.5",
  • "graphql": "^0.10.5"
  • "kcors": "^2.2.1"
  • "koa-bodyparser": "^4.2.0"
  • Bumps packages:
  • "eslint": "^4.3.0"
  • "serve": "^6.0.6"
  • "react": "^16.0.0-beta.3"
  • "react-dom": "^16.0.0-beta.3"

Known issues

kit - 1.17.1

Published by leebenson about 7 years ago

1.17.1 - 2017-08-02

Webpack

  • Refactors inline image and font file regex to kit/webpack/common.js
  • Fixes image/font file loading, when importing from an NPM package
kit - 1.17.0

Published by leebenson about 7 years ago

1.17.0 - 2017-07-30

Server (development)

  • Adds --inspect to server fork in development, to enable debugging
kit - 1.16.0

Published by leebenson about 7 years ago

1.16.0 - 2017-07-26

Webpack

  • Moves sass sourceMap option to newer options object

NPM

  • Bumps packages:
    brotli-webpack-plugin ^0.3.0 → ^0.4.0
    boxen ^1.1.0 → ^1.2.1
    react-apollo ^1.4.3 → ^1.4.8
    chunk-manifest-webpack-plugin ^1.1.0 → ^1.1.2
    eslint-config-airbnb ^15.0.2 → ^15.1.0
    eslint-plugin-babel ^4.1.1 → ^4.1.2
    iltorb ^1.3.3 → ^1.3.5
    postcss-nested ^2.0.2 → ^2.1.0
    serve ^6.0.2 → ^6.0.3
    webpack ^3.1.0 → ^3.4.1
    webpack-dev-server ^2.5.1 → ^2.6.1
    webpack-manifest-plugin ^1.1.2 → ^1.2.1
kit - 1.15.1

Published by leebenson about 7 years ago

1.15.1 - 2017-07-22

PostCSS

  • Fixes url() imports in CSSNano, by disabling normalizeUrl
kit - 1.15.0

Published by leebenson about 7 years ago

1.15.0 - 2017-07-21

Webpack

  • Fixes global CSS/Sass/LESS RegEx check
kit - 1.14.0

Published by leebenson over 7 years ago

1.14.0 - 2017-07-17

General

  • Merges #49 - browser window now automatically opens on npm start

NPM

  • Removes compression-webpack-plugin in favour of zopfli-webpack-plugin
  • Bumps packages
    extract-text-webpack-plugin ^2.1.2 → ^3.0.0
    postcss-cssnext 3.0.0 → 3.0.2
    boxen ^1.1.0 → ^1.2.0
    react-router ^4.1.1 → ^4.1.2
    react-router-dom ^4.1.1 → ^4.1.2
    redux ^3.7.1 → ^3.7.2
    postcss-nested ^2.0.2 → ^2.0.4
    webpack ^3.1.0 → ^3.3.0
    webpack-bundle-analyzer ^2.8.2 → ^2.8.3
kit - 1.13.0

Published by leebenson over 7 years ago

1.13.0 - 2017-07-08

Webpack

  • Enables scope hoisting webpack.optimize.ModuleConcatenationPlugin-- shaves a few KB of the vendor bundle size

NPM

  • Bumps packages:
    postcss-cssnext 2.11.0 → 3.0.0
    react-apollo ^1.4.2 → ^1.4.3
    babel-preset-env ^1.5.2 → ^1.6.0
    eslint-config-airbnb ^15.0.1 → ^15.0.2
    eslint-plugin-import ^2.6.1 → ^2.7.0
    iltorb ^1.3.2 → ^1.3.3
    serve ^6.0.0 → ^6.0.2
    webpack ^3.0.0 → ^3.1.0
    webpack-dev-server ^2.5.0 → ^2.5.1
    webpack-manifest-plugin ^1.1.0 → ^1.1.2
kit - 1.12.0

Published by leebenson over 7 years ago

1.12.0 - 2017-07-02

ESLint

  • Reverts back to ESLint v3, to avoid Airbnb syntax issues (fixes #44)
  • Reverts to eslint-plugin-jsx-a11y ^5.1.0, fixing ESLint v3 issues

Testing

  • Adds jest test runner (currently no tests)
  • Adds npm test option to package.json
  • Adds .travis.yml for building and testing lint status via Travis-CI
kit - 1.11.0

Published by leebenson over 7 years ago

1.11.0 - 2017-06-30

Webpack

  • Removes Uglify2 compression options, to avoid edge cases in NPM packages
  • Bump to Webpack v3 and latest versions (shaves 12.2% off the default vendor build sizes)

NPM

  • Bumps versions:
    chalk ^1.1.3 → ^2.0.1
    eslint ^3.19.0 → ^4.1.1
    eslint-plugin-jsx-a11y ^5.0.3 → ^6.0.2
    serve ^5.2.2 → ^6.0.0
    webpack ^2.6.1 → ^3.0.0
    koa ^2.2.0 → ^2.3.0
    redux ^3.7.0 → ^3.7.1
    babel-loader ^7.1.0 → ^7.1.1
    eslint-import-resolver-webpack ^0.8.1 → ^0.8.3
    eslint-plugin-import ^2.3.0 → ^2.6.1
    graphql-tag ^2.4.0 → ^2.4.2
    html-webpack-plugin ^2.28.0 → ^2.29.0
    resolve-url-loader ^2.0.3 → ^2.1.0
kit - 1.10.1

Published by leebenson over 7 years ago

1.10.1 - 2017-06-21

Docker

  • Fixes #35 - image optimiser binaries are now built successfully
kit - 1.10.0

Published by leebenson over 7 years ago

1.10.0 - 2017-06-20

ESLint

kit - 1.9.0

Published by leebenson over 7 years ago

1.9.0 - 2017-06-20

Webpack

  • Removes redundant OccurrenceOrderPlugin (on in default in Weback v2)
  • Updates module.loaders -> module.rules, and loaders.loaders -> rules.use

NPM

  • Bumps packages:
    "babel-core": "^6.25.0"
    "babel-loader": "^7.1.0"
    "babel-preset-env": "^1.5.2"
    "cross-env": "^5.0.1"
    "eslint-plugin-compat": "^1.0.4"
    "eslint-plugin-react": "^7.1.0",
    "extract-text-webpack-plugin": "^2.1.2",
    "file-loader": "^0.11.2",
    "graphql-tag": "^2.4.0"
    "less-loader": "^4.0.4"
    "resolve-url-loader": "^2.0.3"
    "sass-loader": "^6.0.6",
    "serve": "^5.2.2",
    "style-loader": "^0.18.2"
    "webpack-dev-server": "^2.5.0"
    "koa-helmet": "^3.2.0",
    "koa-router": "^7.2.1"
    "react": "^15.6.1",
    "react-apollo": "^1.4.2",
    "react-dom": "^15.6.1"
    "redux": "^3.7.0"
kit - 1.8.1

Published by leebenson over 7 years ago

1.8.1 - 2017-06-15

Webpack

NPM:

  • Bumps packages:
    "postcss-loader": "^2.0.6"
kit - 1.8.0

Published by leebenson over 7 years ago

1.8.0 - 2017-06-15

State management (Redux)

  • Refactors kit/lib/redux.js to provide a pattern for adding custom reducers outside of Apollo
  • Adds reducers/counter.js sample reducer, for incrementing a counter
  • Adds <ReduxCounter> example to src/app.js for triggering an increment action and listening for store changes
  • Adds react-redux, for passing Redux store state to React via props
  • Adds redux-thunk, for allowing custom actions that return functions, giving them access to dispatch related actions
  • Adds seamless-immutable, for enforcing immutability in custom Redux state

ESLint

  • Bumps to ESLint v4 (from v3.19)

NPM

  • Adds packages
    "react-redux": "^5.0.5"
    "redux-thunk": "^2.2.0",
    "seamless-immutable": "^7.1.2"
  • Bumps packages:
    "eslint": "^4.0.0"
kit - 1.7.0

Published by leebenson over 7 years ago

1.7.0 - 2017-06-08

General

  • Fixes issue in kit/lib/env.js, where isProduction was always returning false

Docker

  • Adds Dockerfile, for building a production web server Docker image
  • Adds .dockerignore, copied from the existing .gitignore to avoid unnecessary build context

NPM

  • Removes yarn.lock -- the official advice is to avoid Yarn at present, due to certain third-party NPM packages relying on 'postinstall' hooks to build binaries from source
  • Adds package-lock.json, for faster builds with NPM v5
  • Explicitly adds iltorb and node-zopfli, binary packages required for Brotli and Zopfli compression respectively
  • Adds packages:
    "iltorb": "^1.3.1"
    "node-zopfli": "^2.0.2"
kit - 1.6.0

Published by leebenson over 7 years ago

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"
Related Projects