Skip to content

Commit d4279f4

Browse files
committed
2 parents 915378e + 1c1d387 commit d4279f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+9038
-5063
lines changed

.babelrc.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
module.exports = function(api) {
1+
module.exports = function (api) {
22
const plugins = [
3-
'@babel/plugin-syntax-dynamic-import',
3+
'@babel/plugin-transform-flow-strip-types',
44
'@babel/plugin-proposal-class-properties',
5-
'@babel/plugin-proposal-export-default-from',
6-
'@babel/plugin-proposal-export-namespace-from',
7-
'@babel/plugin-proposal-object-rest-spread',
85
]
96
const presets = [
107
[
118
'@babel/preset-env',
129
api.env('es5')
1310
? { forceAllTransforms: true }
14-
: { targets: { node: 'current' } },
11+
: { targets: { node: '12' } },
1512
],
1613
'@babel/preset-flow',
1714
]

.circleci/config.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: 2
2+
jobs:
3+
build:
4+
docker:
5+
- image: circleci/node:16
6+
7+
steps:
8+
- checkout
9+
10+
- run:
11+
name: Setup NPM Token
12+
command: |
13+
yarn config set registry "https://registry.npmjs.org/"
14+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
15+
echo "registry=https://registry.npmjs.org/" >> .npmrc
16+
17+
# https://github.com/atlassian/react-beautiful-dnd/issues/1007#issuecomment-446415426
18+
- run:
19+
name: Workaround for Flow crashing
20+
command: echo "server.max_workers=1" >> .flowconfig
21+
22+
- run:
23+
name: Install Dependencies
24+
command: yarn install --frozen-lockfile
25+
26+
- run:
27+
name: build
28+
command: yarn run prepublishOnly
29+
- run:
30+
name: upload test coverage
31+
command: yarn codecov
32+
- run:
33+
name: release
34+
command: yarn run semantic-release

.eslintrc

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
{
22
"extends": [
3-
"@jedwards1211/eslint-config","@jedwards1211/eslint-config-flow", "eslint-config-prettier"
3+
"@jedwards1211/eslint-config",
4+
"@jedwards1211/eslint-config-flow",
5+
"prettier"
46
],
5-
"parser": "babel-eslint",
6-
"parserOptions": {
7-
"ecmaVersion": 6,
8-
"sourceType": "module"
9-
},
7+
"parser": "@babel/eslint-parser",
108
"env": {
11-
"es6": true
9+
"es2017": true
1210
}
1311
}

.flowconfig

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[ignore]
2-
<PROJECT_ROOT>/lib/.*
2+
<PROJECT_ROOT>/[^/\\]+\.js$
3+
<PROJECT_ROOT>/[^/\\]+\.js\.flow$
34
<PROJECT_ROOT>/es/.*
45
<PROJECT_ROOT>/node_modules/fbjs/.*
56
<PROJECT_ROOT>/node_modules/.*/fbjs/.*
@@ -12,6 +13,3 @@
1213
[libs]
1314

1415
[options]
15-
module.system=node
16-
esproposal.class_static_fields=enable
17-
esproposal.class_instance_fields=enable

.gitignore

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
coverage
2-
.nyc_output
1+
/coverage
2+
/.nyc_output
33
node_modules
4-
lib
5-
es
4+
/lib
5+
/es
66
.eslintcache
7+
*.js
8+
*.js.flow
9+
*.ts
10+
!/flow-typed/**/*.js
11+
!/src/**/*.js
12+
!/src/**/*.ts
13+
!/test/**/*.js
14+
!/.babelrc.js

.npmignore

+11-17
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
coverage
2-
.nyc_output
3-
src
4-
lib
5-
test
6-
scripts
7-
node_modules
8-
.babelrc
9-
.eslintrc
10-
.prettierrc
11-
.travis.yml
12-
.eslintcache
13-
.idea
14-
solano.yml
15-
renovate.json
16-
commitlint.config.js
17-
flow-typed
1+
**
2+
!**/*.js
3+
!**/*.js.flow
4+
!**/*.d.ts
5+
!/*.md
6+
/src
7+
/test
8+
/coverage
9+
/flow-typed
10+
__tests__
11+
/.*

.prettierrc

-5
This file was deleted.

.travis.yml

-20
This file was deleted.

LICENSE.md

-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22-

README.md

+32-29
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# apollo-magic-refetch
22

3-
[![Build Status](https://travis-ci.org/jcoreio/apollo-magic-refetch.svg?branch=master)](https://travis-ci.org/jcoreio/apollo-magic-refetch)
3+
[![CircleCI](https://circleci.com/gh/jcoreio/apollo-magic-refetch.svg?style=svg)](https://circleci.com/gh/jcoreio/apollo-magic-refetch)
44
[![Coverage Status](https://codecov.io/gh/jcoreio/apollo-magic-refetch/branch/master/graph/badge.svg)](https://codecov.io/gh/jcoreio/apollo-magic-refetch)
55
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
66
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
@@ -20,19 +20,19 @@ Until that happens, this is probably your best bet!
2020

2121
# Table of Contents
2222

23-
* [How it works](#how-it-works)
24-
* [Current limitations](#current-limitations)
25-
* [ES environment requirements](#es-environment-requirements)
26-
* [Type metadata usage](#type-metadata-usage)
27-
* [Handling Deletions](#handling-deletions)
28-
* [Handling Creation](#handling-creation)
29-
* [Handling associations being broken](#handling-associations-being-broken)
30-
* [Handling associations being created](#handling-associations-being-created)
31-
* [API](#api)
32-
+ [`refetch(client, typenameOrTerms, [predicate, [idField]])`](#refetchclient-typenameorterms-predicate-idfield)
33-
+ [`refetch.fetchTypeMetadata(client)`](#refetchfetchtypemetadataclient)
34-
+ [`refetch.setTypeMetadata(typeMetadataPromise)`](#refetchsettypemetadatatypemetadatapromise)
35-
+ [`typesQuery`](#typesquery)
23+
- [How it works](#how-it-works)
24+
- [Current limitations](#current-limitations)
25+
- [ES environment requirements](#es-environment-requirements)
26+
- [Type metadata usage](#type-metadata-usage)
27+
- [Handling Deletions](#handling-deletions)
28+
- [Handling Creation](#handling-creation)
29+
- [Handling associations being broken](#handling-associations-being-broken)
30+
- [Handling associations being created](#handling-associations-being-created)
31+
- [API](#api)
32+
- [`refetch(client, typenameOrTerms, [predicate, [idField]])`](#refetchclient-typenameorterms-predicate-idfield)
33+
- [`refetch.fetchTypeMetadata(client)`](#refetchfetchtypemetadataclient)
34+
- [`refetch.setTypeMetadata(typeMetadataPromise)`](#refetchsettypemetadatatypemetadatapromise)
35+
- [`typesQuery`](#typesquery)
3636

3737
## How it works
3838

@@ -52,9 +52,9 @@ all pertinent mutations.
5252

5353
## Current limitations
5454

55-
* Interfaces and union types are not supported yet. This means if they are
56-
anywhere in your results, this library may fail to refetch when it should.
57-
* Lists of lists are not supported yet.
55+
- Interfaces and union types are not supported yet. This means if they are
56+
anywhere in your results, this library may fail to refetch when it should.
57+
- Lists of lists are not supported yet.
5858

5959
## ES environment requirements
6060

@@ -95,7 +95,7 @@ const app = express()
9595
const typeMetadataPromise = execute(schema, typesQuery)
9696

9797
app.get('/graphql/refetchTypeMetadata', (req, res) => {
98-
typeMetadataPromise.then(data => res.json(data))
98+
typeMetadataPromise.then((data) => res.json(data))
9999
})
100100
```
101101

@@ -107,14 +107,14 @@ import refetch from 'apollo-magic-refetch'
107107

108108
// accepts a promise that resolves to the graphql execution result.
109109
refetch.setTypeMetadata(
110-
fetch('/graphql/refetchTypeMetadata').then(res => res.json())
110+
fetch('/graphql/refetchTypeMetadata').then((res) => res.json())
111111
)
112112
```
113113

114114
## Handling Deletions
115115

116116
Typically you call `refetch` within the `update` callback of your `Mutation`
117-
that deletes objects. You just have to call `refetch` with the `__typename`
117+
that deletes objects. You just have to call `refetch` with the `__typename`
118118
that was deleted (in this case, `Device`) and the `id` of the deleted object.
119119
This refetches any active queries that contain the deleted object in cached data.
120120

@@ -152,13 +152,13 @@ const DestroyDeviceButton = ({deviceId}) => (
152152
## Handling Creation
153153

154154
Typically you call `refetch` within the `update` callback of your `Mutation`
155-
that creates objects. You just have to call `refetch` with the `__typename`
155+
that creates objects. You just have to call `refetch` with the `__typename`
156156
that was created.
157157

158158
Unlike deletions, you don't pass the `id` of the created
159-
object. Without a specific `id` to search for, it simply refetches all active
159+
object. Without a specific `id` to search for, it simply refetches all active
160160
queries that contain any object of the requested `__typename` in their cached
161-
data, in case the created object belongs in the new results. This is less
161+
data, in case the created object belongs in the new results. This is less
162162
efficient than refetching queries containing a specific `id`, but far easier
163163
than manually inserting the created object into each relevant query.
164164

@@ -204,7 +204,10 @@ sublist of `User`s. When one or more users is removed from an organization,
204204
it makes the following call:
205205

206206
```js
207-
refetch(client, [['User', userIds], ['Organization', organizationId]])
207+
refetch(client, [
208+
['User', userIds],
209+
['Organization', organizationId],
210+
])
208211
```
209212

210213
Passing an array to `refetch` means to only refetch queries containing all of
@@ -320,16 +323,16 @@ const mutation = gql`
320323

321324
const CreateUserFormContainer = ({ organizationId }) => (
322325
<ApolloConsumer>
323-
{client => (
326+
{(client) => (
324327
<Mutation
325328
mutation={mutation}
326329
update={() =>
327330
refetch(client, [['User'], ['Organization', organizationId]])
328331
}
329332
>
330-
{createUser => (
333+
{(createUser) => (
331334
<CreateUserForm
332-
onSubmit={values =>
335+
onSubmit={(values) =>
333336
createUser({
334337
variables: { organizationId, values },
335338
})
@@ -382,7 +385,7 @@ The name of the id field in the type that was deleted. This is only used if
382385
### `refetch.fetchTypeMetadata(client)`
383386

384387
Prefetches type metadata by running an introspection query on the given on
385-
`ApolloClient`. The server must support client introspection queries;
388+
`ApolloClient`. The server must support client introspection queries;
386389
otherwise use [`refetch.setTypeMetadata`](#refetchsettypemetadatatypemetadatapromise).
387390

388391
#### Arguments
@@ -410,7 +413,7 @@ import { typesQuery } from 'apollo-magic-refetch'
410413
```
411414
412415
The parsed GraphQL introspection query that gets all of the type metadata
413-
needed to determine which queries to refetch. Use this if your server forbids
416+
needed to determine which queries to refetch. Use this if your server forbids
414417
client introspection queries; execute this query on the server side and send
415418
the result to the client code that calls
416419
[`refetch.setTypeMetadata`](#refetchsettypemetadatatypemetadatapromise).

commitlint.config.js

-1
This file was deleted.

0 commit comments

Comments
 (0)