diff --git a/.circleci/config.yml b/.circleci/config.yml index 6f3a2e5e..88792843 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,6 +33,4 @@ jobs: - store_artifacts: path: reports/junit - - run: | - npm install coveralls - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js + - run: npm run coveralls diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index f8bc5def..54f08f6c 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,6 +1,17 @@ +### Package + + + +- [ ] `graphql-hooks` +- [ ] `graphql-hooks-ssr` +- [ ] `graphql-hooks-memcache` + ### Environment - `graphql-hooks` version: + +- `graphql-hooks-ssr` version: +- `graphql-hooks-memcache` version: - `react` version: - Browser: diff --git a/.github/ISSUE_TEMPLATE/Bug_Report.md b/.github/ISSUE_TEMPLATE/Bug_Report.md index 8e721483..2d42936b 100644 --- a/.github/ISSUE_TEMPLATE/Bug_Report.md +++ b/.github/ISSUE_TEMPLATE/Bug_Report.md @@ -4,9 +4,20 @@ about: Bugs or any unexpected issues. labels: bug --- +### Package + + + +- [ ] `graphql-hooks` +- [ ] `graphql-hooks-ssr` +- [ ] `graphql-hooks-memcache` + ### Environment - `graphql-hooks` version: + +- `graphql-hooks-ssr` version: +- `graphql-hooks-memcache` version: - `react` version: - Browser: diff --git a/.gitignore b/.gitignore index d9a2046c..2fb2fa21 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ node_modules graphql-hooks-*.*.*.tgz package-lock.json -/coverage +coverage .DS_Store lib dist diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b31dc890..b56206ac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,6 +16,14 @@ We would like to avoid issues that require a follow up questions to identify the ## For Developers +### Packages + +We use [Lerna](https://lernajs.io) to manage this monorepo, you will find the different `graphql-hooks-*` modules in the `packages` directory. + +### Getting started + +Clone the repository and run `npm install`. This will install the root dependencies and all of the dependencies required by each package, using `lerna bootstrap`. + All contributions should use the [prettier](https://prettier.io/) formatter, pass linting and pass tests. You can do this by running: @@ -52,9 +60,9 @@ For more information on `@all-contributors` see it's [usage docs](https://allcon ### Release process: - `npm test` -- `npm version ` -- `git push && git push --tags` -- `npm publish` +- `npm run release` + +Follow the prompts from [`lerna publish`](https://lernajs.io/#command-publish) --- diff --git a/README.md b/README.md index 2e6730f0..664c6fd0 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ ![](https://img.shields.io/bundlephobia/minzip/graphql-hooks.svg?style=flat) [![npm version](https://badge.fury.io/js/graphql-hooks.svg)](https://badge.fury.io/js/graphql-hooks) [![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors) +[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lernajs.io/) 🎣 Minimal hooks-first GraphQL client. @@ -12,8 +13,8 @@ - 🥇 First-class hooks API - ⚖️ _Tiny_ bundle: only 5.1kB (1.9 gzipped) -- 📄 Full SSR support: see [graphql-hooks-ssr](https://github.com/nearform/graphql-hooks-ssr) -- 🔌 Plugin Caching: see [graphql-hooks-memcache](https://github.com/nearform/graphql-hooks-memcache) +- 📄 Full SSR support: see [graphql-hooks-ssr](packages/graphql-hooks-ssr) +- 🔌 Plugin Caching: see [graphql-hooks-memcache](packages/graphql-hooks-memcache) - 🔥 No more render props hell - ⏳ Handle loading and error states with ease @@ -124,7 +125,7 @@ const client = new GraphQLClient(config); - `cache.clear()` - `cache.keys()` - `getInitialState()` - - See [graphql-hooks-memcache](https://github.com/nearform/graphql-hooks-memcache) as a reference implementation + - See [graphql-hooks-memcache](packages/graphql-hooks-memcache) as a reference implementation - `fetch(url, options)`: Fetch implementation - defaults to the global `fetch` API - `fetchOptions`: See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch) for info on what options can be passed - `headers`: Object, e.g. `{ 'My-Header': 'hello' }` @@ -323,7 +324,7 @@ The `options` object that can be passed either to `useMutation(mutation, options ### SSR -See [graphql-hooks-ssr](https://github.com/nearform/graphql-hooks-ssr) for an in depth guide. +See [graphql-hooks-ssr](packages/graphql-hooks-ssr) for an in depth guide. ### Pagination @@ -467,6 +468,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d | [Brian Mullan
Brian Mullan](https://twitter.com/bmullan91)
[💬](#question-bmullan91 "Answering Questions") [🐛](https://github.com/nearform/graphql-hooks/issues?q=author%3Abmullan91 "Bug reports") [💻](https://github.com/nearform/graphql-hooks/commits?author=bmullan91 "Code") [🖋](#content-bmullan91 "Content") [📖](https://github.com/nearform/graphql-hooks/commits?author=bmullan91 "Documentation") [💡](#example-bmullan91 "Examples") [🤔](#ideas-bmullan91 "Ideas, Planning, & Feedback") [🚧](#maintenance-bmullan91 "Maintenance") [👀](#review-bmullan91 "Reviewed Pull Requests") [⚠️](https://github.com/nearform/graphql-hooks/commits?author=bmullan91 "Tests") | [Jack Clark
Jack Clark](https://jackdc.com)
[💬](#question-jackdclark "Answering Questions") [🐛](https://github.com/nearform/graphql-hooks/issues?q=author%3Ajackdclark "Bug reports") [💻](https://github.com/nearform/graphql-hooks/commits?author=jackdclark "Code") [🖋](#content-jackdclark "Content") [📖](https://github.com/nearform/graphql-hooks/commits?author=jackdclark "Documentation") [💡](#example-jackdclark "Examples") [🤔](#ideas-jackdclark "Ideas, Planning, & Feedback") [🚧](#maintenance-jackdclark "Maintenance") [👀](#review-jackdclark "Reviewed Pull Requests") [⚠️](https://github.com/nearform/graphql-hooks/commits?author=jackdclark "Tests") | [Joe Warren
Joe Warren](http://twitter.com/joezo)
[💬](#question-Joezo "Answering Questions") [🐛](https://github.com/nearform/graphql-hooks/issues?q=author%3AJoezo "Bug reports") [💻](https://github.com/nearform/graphql-hooks/commits?author=Joezo "Code") [🖋](#content-Joezo "Content") [📖](https://github.com/nearform/graphql-hooks/commits?author=Joezo "Documentation") [💡](#example-Joezo "Examples") [🤔](#ideas-Joezo "Ideas, Planning, & Feedback") [🚧](#maintenance-Joezo "Maintenance") [👀](#review-Joezo "Reviewed Pull Requests") [⚠️](https://github.com/nearform/graphql-hooks/commits?author=Joezo "Tests") | [Simone Busoli
Simone Busoli](http://simoneb.github.io)
[💬](#question-simoneb "Answering Questions") [🐛](https://github.com/nearform/graphql-hooks/issues?q=author%3Asimoneb "Bug reports") [📖](https://github.com/nearform/graphql-hooks/commits?author=simoneb "Documentation") | [jhey tompkins
jhey tompkins](https://jheytompkins.com)
[⚠️](https://github.com/nearform/graphql-hooks/commits?author=jh3y "Tests") [💬](#question-jh3y "Answering Questions") [🐛](https://github.com/nearform/graphql-hooks/issues?q=author%3Ajh3y "Bug reports") [💻](https://github.com/nearform/graphql-hooks/commits?author=jh3y "Code") [🖋](#content-jh3y "Content") | [Haroen Viaene
Haroen Viaene](https://haroen.me)
[🐛](https://github.com/nearform/graphql-hooks/issues?q=author%3AHaroenv "Bug reports") | | :---: | :---: | :---: | :---: | :---: | :---: | + This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! diff --git a/babel.config.js b/babel.config.js index d10abb39..19410677 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,3 +1,4 @@ +// this is used by jest only module.exports = { presets: [ [ diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 00000000..832bf4fd --- /dev/null +++ b/jest.config.js @@ -0,0 +1,25 @@ +const projects = [ + { + displayName: 'graphql-hooks', + roots: ['./packages/graphql-hooks'], + testMatch: ['/packages/graphql-hooks/**/*.test.js'], + setupFiles: ['/packages/graphql-hooks/test/setup.js'], + setupFilesAfterEnv: [ + '/packages/graphql-hooks/test/setupAfterEnv.js' + ], + automock: false + }, + { + roots: ['./packages/graphql-hooks-memcache'], + displayName: 'graphql-hooks-memcache', + testMatch: ['/packages/graphql-hooks-memcache/**/*.test.js'] + }, + { + roots: ['./packages/graphql-hooks-ssr'], + displayName: 'graphql-hooks-ssr', + testMatch: ['/packages/graphql-hooks-ssr/**/*.test.js'] + } +]; +module.exports = { + projects +}; diff --git a/lerna.json b/lerna.json new file mode 100644 index 00000000..7926728a --- /dev/null +++ b/lerna.json @@ -0,0 +1,4 @@ +{ + "packages": ["packages/*"], + "version": "independent" +} diff --git a/package.json b/package.json index 9ef0620e..cf6fe88c 100644 --- a/package.json +++ b/package.json @@ -1,68 +1,46 @@ { - "name": "graphql-hooks", - "version": "3.2.2", - "description": "Graphql Hooks", - "main": "lib/graphql-hooks.js", - "module": "es/graphql-hooks.js", - "unpkg": "dist/graphql-hooks.min.js", + "name": "root", + "private": true, "scripts": { "test": "jest", - "test:watch": "jest --watch", "test:coverage": "jest --coverage", - "eslint": "eslint src test", - "prettier": "prettier src/**/*.js test/**/*.js --write", - "build": "rollup -c", - "prepublishOnly": "npm run build" - }, - "files": [ - "dist", - "es", - "lib" - ], - "keywords": [ - "graphql", - "hooks", - "graphql-hooks", - "gql", - "gql-hooks", - "react-graphql-hooks", - "react", - "apollo" - ], - "author": "Brian Mullan ", - "license": "Apache-2.0", - "peerDependencies": { - "react": "^16.8.3" + "postinstall": "lerna bootstrap --no-ci", + "coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", + "eslint": "eslint *.js packages/*/*.js packages/*/{src,test}/**/*.js", + "prettier": "prettier *.js *.md packages/*/*.{js,md} packages/*/{src,test}/**/*.{js,md} --write", + "release": "lerna publish" }, "devDependencies": { "@babel/preset-env": "7.3.4", "@babel/preset-react": "7.0.0", "babel-eslint": "10.0.1", "babel-jest": "24.1.0", - "eslint": "5.15.0", + "coveralls": "3.0.3", "eslint-config-prettier": "4.1.0", "eslint-plugin-prettier": "3.0.1", - "eslint-plugin-react": "7.12.4", "eslint-plugin-react-hooks": "1.4.0", + "eslint-plugin-react": "7.12.4", + "eslint": "5.15.0", "husky": "1.3.1", "jest": "24.1.0", - "jest-fetch-mock": "2.1.1", + "lerna": "3.13.1", "lint-staged": "8.1.5", - "prettier": "1.16.4", - "react": "16.8.3", - "react-dom": "16.8.3", - "react-hooks-testing-library": "0.3.6", - "react-testing-library": "6.0.0", - "rollup": "1.4.1", - "rollup-plugin-babel": "4.3.2", - "rollup-plugin-node-resolve": "4.0.1", - "rollup-plugin-size-snapshot": "0.8.0", - "rollup-plugin-terser": "4.0.4" + "prettier": "1.16.4" }, "lint-staged": { - "./src/**/*.js": [ - "eslint src test", - "prettier src/**/*.js test/**/*.js --write", + "./packages/*/{src,test}/**/*.js": [ + "eslint", + "prettier --write", + "git add" + ], + "./packages/*/*.js": [ + "eslint", + "prettier --write", + "git add" + ], + "*.js": [ + "eslint", + "prettier --write", "git add" ] }, @@ -70,22 +48,5 @@ "hooks": { "pre-commit": "lint-staged" } - }, - "jest": { - "automock": false, - "setupFiles": [ - "./test/setup.js" - ], - "setupFilesAfterEnv": [ - "react-testing-library/cleanup-after-each" - ] - }, - "repository": { - "type": "git", - "url": "git://github.com/nearform/graphql-hooks.git" - }, - "bugs": { - "url": "https://github.com/nearform/graphql-hooks" - }, - "homepage": "https://github.com/nearform/graphql-hooks#readme" + } } diff --git a/packages/graphql-hooks-memcache/README.md b/packages/graphql-hooks-memcache/README.md new file mode 100644 index 00000000..91c03e89 --- /dev/null +++ b/packages/graphql-hooks-memcache/README.md @@ -0,0 +1,42 @@ +# graphql-hooks-memcache + +In-memory caching implementation for graphql-hooks + +## Install + +`npm install graphql-hooks-memcache` + +or + +`yarn add graphql-hooks-memcache` + +## Quick Start + +This is intended to be used as the `cache` option when calling `createClient` from `graphql-hooks`. + +```js +import { GraphQLClient } from 'graphql-hooks'; +import memCache from 'graphql-hooks-memcache'; + +const client = new GraphQLClient({ + endpoint: '/graphql', + cache: memCache() +}); +``` + +### Options + +`memCache(options)`: Option object properties + +- `size`: The number of items to store in the cache +- `ttl`: Milliseconds an item will remain in cache. Default behaviour will only evict items when `size` limit has been reached +- `initialState`: The value from `cache.getInitialState()` used for rehydrating the cache after SSR + +### API + +- `cache.get(key)`: Find item in cache that matches `key` +- `cache.set(key, value)`: Set an item in the cache +- `cache.delete(key)`: Delete an item from the cache +- `cache.clear()`: Clear all items from the cache +- `cache.keys()`: Returns an array of keys, useful when you need to iterate over the cache items +- `cache.getInitialState()`: A serialisable version of the cache - used during SSR diff --git a/packages/graphql-hooks-memcache/index.js b/packages/graphql-hooks-memcache/index.js new file mode 100644 index 00000000..b0da0ad1 --- /dev/null +++ b/packages/graphql-hooks-memcache/index.js @@ -0,0 +1,32 @@ +const LRU = require('tiny-lru'); +const fnv1a = require('@sindresorhus/fnv1a'); + +function generateKey(keyObj) { + return fnv1a(JSON.stringify(keyObj)).toString(36); +} + +module.exports = function memCache({ size = 100, ttl = 0, initialState } = {}) { + const lru = LRU(size, ttl); + + if (initialState) { + Object.keys(initialState).map(k => { + lru.set(k, initialState[k]); + }); + } + + return { + get: keyObj => lru.get(generateKey(keyObj)), + set: (keyObj, data) => lru.set(generateKey(keyObj), data), + delete: keyObj => lru.delete(generateKey(keyObj)), + clear: () => lru.clear(), + keys: () => lru.keys(), + getInitialState: () => + lru.keys().reduce( + (initialState, key) => ({ + ...initialState, + [key]: lru.get(key) + }), + {} + ) + }; +}; diff --git a/packages/graphql-hooks-memcache/package.json b/packages/graphql-hooks-memcache/package.json new file mode 100644 index 00000000..580dea52 --- /dev/null +++ b/packages/graphql-hooks-memcache/package.json @@ -0,0 +1,32 @@ +{ + "name": "graphql-hooks-memcache", + "version": "1.0.5", + "description": "In memory cache for graphql-hooks", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "graphql", + "hooks", + "react", + "graphql-hooks", + "cache", + "ssr", + "server-side rendering" + ], + "author": "Brian Mullan ", + "license": "Apache-2.0", + "dependencies": { + "@sindresorhus/fnv1a": "^1.0.0", + "tiny-lru": "^6.0.1" + }, + "repository": { + "type": "git", + "url": "git://github.com/nearform/graphql-hooks.git" + }, + "bugs": { + "url": "https://github.com/nearform/graphql-hooks/issues" + }, + "homepage": "https://github.com/nearform/graphql-hooks/blob/master/packages/graphql-hooks-memcache#readme" +} diff --git a/packages/graphql-hooks-ssr/README.md b/packages/graphql-hooks-ssr/README.md new file mode 100644 index 00000000..9342dc2c --- /dev/null +++ b/packages/graphql-hooks-ssr/README.md @@ -0,0 +1,79 @@ +# graphql-hooks-ssr + +Server-side rendering utils for `graphql-hooks` + +## Install + +`npm install graphql-hooks-ssr` + +or + +`yarn add graphql-hooks-ssr` + +## Quick Start + +The below example is for `fastify` but the same principles apply for `express` & `hapi`. + +```js +const { GraphQLClient } = require('graphql-hooks'); +const memCache = require('graphql-hooks-memcache'); +const { getInitialState } = require('graphql-hooks-ssr'); +const { ServerLocation } = require('@reach/router'); +// NOTE: use can use any 'fetch' polyfill +const fetch = require('isomorphic-unfetch'); + +app.get('/', async (req, reply) => { + // Step 1: Create the client inside the request handler + const client = new GraphQLClient({ + url: 'https://domain.com/graphql', + cache: memCache(), + fetch + }); + + // Step 2: Provide the `client` + // Optional: If your app contains a router, you'll need to tell it which route the user is on + // based on the request.. this example uses @reach/router + const App = ( + + + {/* Your App component goes here */} + + + ); + + // Step 3: Use the getInitialState method from graphql-hooks-ssr + // Pass in App + GraphQL client + const initialState = await getInitialState({ App, client }); + + // Step 4: Render the your App - all queries will now be cached + const content = ReactDOMServer.renderToString(App); + + // Step 5: Serialise the initialState object + include it in the html payload + const html = ` + + + +
${content}
+ + + + `; + + reply.type('text/html').send(html); +}); +``` + +### API + +#### `getInitialState(options)` + +Returns the serialisable cache after fetching all queries. + +- `options.App`: The react component to render +- `options.client`: An instance of `GraphQLClient` from `graphql-hooks` +- `options.render`: A custom render function; defaults to `ReactDOMServer.renderToStaticMarkup` diff --git a/packages/graphql-hooks-ssr/index.js b/packages/graphql-hooks-ssr/index.js new file mode 100644 index 00000000..db8591d4 --- /dev/null +++ b/packages/graphql-hooks-ssr/index.js @@ -0,0 +1,22 @@ +const ReactDOMServer = require('react-dom/server'); + +async function getInitialState(opts) { + const { App, client, render = ReactDOMServer.renderToStaticMarkup } = opts; + // ensure ssrMode is set: + client.ssrMode = true; + render(App); + + if (client.ssrPromises.length) { + await Promise.all(client.ssrPromises); + // clear promises + client.ssrPromises = []; + // recurse there may be dependant queries + return getInitialState(opts); + } else { + return client.cache.getInitialState(); + } +} + +module.exports = { + getInitialState +}; diff --git a/packages/graphql-hooks-ssr/package.json b/packages/graphql-hooks-ssr/package.json new file mode 100644 index 00000000..e4e75a58 --- /dev/null +++ b/packages/graphql-hooks-ssr/package.json @@ -0,0 +1,37 @@ +{ + "name": "graphql-hooks-ssr", + "version": "1.0.1", + "description": "Server side rendering utils for graphql-hooks", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 0" + }, + "keywords": [ + "graphql", + "hooks", + "react", + "graphql-hooks", + "cache", + "ssr", + "server-side rendering" + ], + "author": "Brian Mullan ", + "license": "Apache-2.0", + "peerDependencies": { + "react": "^16.8.1", + "react-dom": "^16.8.1" + }, + "dependencies": {}, + "devDependencies": { + "react": "16.8.3", + "react-dom": "16.8.3" + }, + "repository": { + "type": "git", + "url": "git://github.com/nearform/graphql-hooks.git" + }, + "bugs": { + "url": "https://github.com/nearform/graphql-hooks/issues" + }, + "homepage": "https://github.com/nearform/graphql-hooks/blob/master/packages/graphql-hooks-ssr#readme" +} diff --git a/.size-snapshot.json b/packages/graphql-hooks/.size-snapshot.json similarity index 59% rename from .size-snapshot.json rename to packages/graphql-hooks/.size-snapshot.json index abd2a476..df481c05 100644 --- a/.size-snapshot.json +++ b/packages/graphql-hooks/.size-snapshot.json @@ -1,13 +1,13 @@ { "lib/graphql-hooks.js": { - "bundled": 11105, - "minified": 5606, - "gzipped": 1919 + "bundled": 11191, + "minified": 5591, + "gzipped": 1912 }, "es/graphql-hooks.js": { - "bundled": 10760, - "minified": 5314, - "gzipped": 1844, + "bundled": 10846, + "minified": 5299, + "gzipped": 1837, "treeshaked": { "rollup": { "code": 67, @@ -19,9 +19,9 @@ } }, "es/graphql-hooks.mjs": { - "bundled": 3954, - "minified": 3954, - "gzipped": 1521, + "bundled": 3939, + "minified": 3939, + "gzipped": 1515, "treeshaked": { "rollup": { "code": 67, @@ -33,13 +33,13 @@ } }, "dist/graphql-hooks.js": { - "bundled": 11352, - "minified": 5114, - "gzipped": 1921 + "bundled": 11438, + "minified": 5099, + "gzipped": 1915 }, "dist/graphql-hooks.min.js": { - "bundled": 5070, - "minified": 5070, - "gzipped": 1900 + "bundled": 5055, + "minified": 5055, + "gzipped": 1891 } } diff --git a/packages/graphql-hooks/package.json b/packages/graphql-hooks/package.json new file mode 100644 index 00000000..3102bb91 --- /dev/null +++ b/packages/graphql-hooks/package.json @@ -0,0 +1,52 @@ +{ + "name": "graphql-hooks", + "version": "3.2.2", + "description": "Graphql Hooks", + "main": "lib/graphql-hooks.js", + "module": "es/graphql-hooks.js", + "unpkg": "dist/graphql-hooks.min.js", + "scripts": { + "build": "rollup -c", + "prepublishOnly": "npm run build" + }, + "files": [ + "dist", + "es", + "lib" + ], + "keywords": [ + "graphql", + "hooks", + "graphql-hooks", + "gql", + "gql-hooks", + "react-graphql-hooks", + "react", + "apollo" + ], + "author": "Brian Mullan ", + "license": "Apache-2.0", + "peerDependencies": { + "react": "^16.8.1" + }, + "devDependencies": { + "jest-fetch-mock": "2.1.1", + "react": "16.8.3", + "react-dom": "16.8.3", + "react-hooks-testing-library": "0.3.4", + "react-testing-library": "6.0.0", + "rollup": "1.3.2", + "rollup-plugin-babel": "4.3.2", + "rollup-plugin-node-resolve": "4.0.1", + "rollup-plugin-size-snapshot": "0.8.0", + "rollup-plugin-terser": "4.0.4" + }, + "repository": { + "type": "git", + "url": "git://github.com/nearform/graphql-hooks.git" + }, + "bugs": { + "url": "https://github.com/nearform/graphql-hooks/issues" + }, + "homepage": "https://github.com/nearform/graphql-hooks#readme" +} diff --git a/rollup.config.js b/packages/graphql-hooks/rollup.config.js similarity index 100% rename from rollup.config.js rename to packages/graphql-hooks/rollup.config.js diff --git a/src/.babelrc.js b/packages/graphql-hooks/src/.babelrc.js similarity index 100% rename from src/.babelrc.js rename to packages/graphql-hooks/src/.babelrc.js diff --git a/src/ClientContext.js b/packages/graphql-hooks/src/ClientContext.js similarity index 100% rename from src/ClientContext.js rename to packages/graphql-hooks/src/ClientContext.js diff --git a/src/GraphQLClient.js b/packages/graphql-hooks/src/GraphQLClient.js similarity index 100% rename from src/GraphQLClient.js rename to packages/graphql-hooks/src/GraphQLClient.js diff --git a/src/index.js b/packages/graphql-hooks/src/index.js similarity index 100% rename from src/index.js rename to packages/graphql-hooks/src/index.js diff --git a/src/useClientRequest.js b/packages/graphql-hooks/src/useClientRequest.js similarity index 100% rename from src/useClientRequest.js rename to packages/graphql-hooks/src/useClientRequest.js diff --git a/src/useQuery.js b/packages/graphql-hooks/src/useQuery.js similarity index 100% rename from src/useQuery.js rename to packages/graphql-hooks/src/useQuery.js diff --git a/test/integration/useQuery.test.js b/packages/graphql-hooks/test/integration/useQuery.test.js similarity index 100% rename from test/integration/useQuery.test.js rename to packages/graphql-hooks/test/integration/useQuery.test.js diff --git a/test/setup.js b/packages/graphql-hooks/test/setup.js similarity index 100% rename from test/setup.js rename to packages/graphql-hooks/test/setup.js diff --git a/packages/graphql-hooks/test/setupAfterEnv.js b/packages/graphql-hooks/test/setupAfterEnv.js new file mode 100644 index 00000000..eb4b4adb --- /dev/null +++ b/packages/graphql-hooks/test/setupAfterEnv.js @@ -0,0 +1 @@ +afterEach(require('react-testing-library').cleanup); diff --git a/test/unit/GraphQLClient.test.js b/packages/graphql-hooks/test/unit/GraphQLClient.test.js similarity index 100% rename from test/unit/GraphQLClient.test.js rename to packages/graphql-hooks/test/unit/GraphQLClient.test.js diff --git a/test/unit/useClientRequest.test.js b/packages/graphql-hooks/test/unit/useClientRequest.test.js similarity index 100% rename from test/unit/useClientRequest.test.js rename to packages/graphql-hooks/test/unit/useClientRequest.test.js diff --git a/test/unit/useManualQuery.test.js b/packages/graphql-hooks/test/unit/useManualQuery.test.js similarity index 100% rename from test/unit/useManualQuery.test.js rename to packages/graphql-hooks/test/unit/useManualQuery.test.js diff --git a/test/unit/useMutation.test.js b/packages/graphql-hooks/test/unit/useMutation.test.js similarity index 100% rename from test/unit/useMutation.test.js rename to packages/graphql-hooks/test/unit/useMutation.test.js diff --git a/test/unit/useQuery.test.js b/packages/graphql-hooks/test/unit/useQuery.test.js similarity index 100% rename from test/unit/useQuery.test.js rename to packages/graphql-hooks/test/unit/useQuery.test.js