From 68cfc122a63377918179c63cda8ae5fce9f85d08 Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Thu, 13 Aug 2015 16:09:19 +0100 Subject: [PATCH 01/14] add eslint to the project --- .eslintignore | 9 + .eslintrc | 101 +++++ eslint-rules/README.md | 5 + .../warning-and-invariant-args-test.js | 102 +++++ eslint-rules/index.js | 7 + eslint-rules/package.json | 4 + eslint-rules/warning-and-invariant-args.js | 88 +++++ gulpfile.js | 2 + package.json | 6 + .../container/RelayContainerProxy.js | 4 +- .../interface/RelayConnectionInterface.js | 2 +- .../__tests__/printRelayQuery-test.js | 2 +- src/__forks__/traversal/printRelayQuery.js | 13 +- src/container/RelayContainer.js | 3 + .../__tests__/RelayContainer-test.js | 54 ++- .../RelayContainer_Component-test.js | 6 +- .../RelayContainer_hasFragmentData-test.js | 4 +- ...RelayContainer_hasOptimisticUpdate-test.js | 2 +- .../RelayContainer_setVariables-test.js | 44 +-- .../__tests__/RelayRootContainer-test.js | 13 +- .../__tests__/getRelayQueries-test.js | 4 +- .../__tests__/isRelayContainer-test.js | 4 +- .../mutation/GraphQLMutatorConstants.js | 2 +- src/legacy/query/GraphQL_EXPERIMENTAL.js | 26 +- .../store/GraphQLDeferredQueryTracker.js | 6 +- src/legacy/store/GraphQLQueryRunner.js | 4 +- src/legacy/store/GraphQLRange.js | 18 +- src/legacy/store/GraphQLSegment.js | 22 +- src/legacy/store/GraphQLStoreChangeEmitter.js | 4 +- src/legacy/store/GraphQLStoreDataHandler.js | 4 +- src/legacy/store/GraphQLStoreQueryResolver.js | 3 +- src/legacy/store/GraphQLStoreRangeUtils.js | 2 +- .../store/__mocks__/GraphQLQueryRunner.js | 4 +- .../__mocks__/GraphQLStoreQueryResolver.js | 2 +- .../store/__mocks__/GraphQLStoreTestUtils.js | 2 +- .../store/__mocks__/generateClientID.js | 2 +- .../GraphQLDeferredQueryTracker-test.js | 1 - .../__tests__/GraphQLFragmentPointer-test.js | 6 +- .../__tests__/GraphQLQueryRunner-test.js | 4 +- .../store/__tests__/GraphQLRange-test.js | 355 +++++++++-------- .../store/__tests__/GraphQLSegment-test.js | 48 +-- .../GraphQLStoreQueryResolver-test.js | 15 +- src/legacy/store/generateClientEdgeID.js | 2 +- src/mutation/RelayMutation.js | 1 - src/mutation/RelayMutationQuery.js | 6 +- src/mutation/RelayMutationTransaction.js | 4 +- src/mutation/__tests__/RelayMutation-test.js | 1 - .../__tests__/RelayMutationQuery-test.js | 47 ++- .../RelayMutationTransaction-test.js | 175 ++++----- .../default/RelayDefaultNetworkLayer.js | 4 +- .../RelayDefaultNetworkLayer-test.js | 6 +- src/network/RelayNetworkLayer.js | 2 +- src/query/RelayQuery.js | 2 +- src/query/RelayQuerySerializer.js | 8 - src/query/RelayQueryTransform.js | 1 - .../__tests__/RelayFragmentReference-test.js | 3 - src/query/__tests__/RelayQL-test.js | 2 + src/query/__tests__/RelayQuery-test.js | 22 +- src/query/__tests__/RelayQueryPath-test.js | 7 +- .../__tests__/RelayQuerySerializer-test.js | 6 +- .../__tests__/RelayQueryTransform-test.js | 3 - src/query/__tests__/RelayQueryVisitor-test.js | 3 - src/query/__tests__/toGraphQL-test.js | 3 +- src/query/fromGraphQL.js | 2 +- src/route/__tests__/RelayRoute-test.js | 8 +- src/store/RelayNeglectionStateMap.js | 6 +- src/store/RelayPendingQueryTracker.js | 2 +- src/store/RelayRecordStore.js | 2 +- src/store/RelayStore.js | 2 +- src/store/RelayStoreData.js | 2 +- src/store/RelayStoreGarbageCollector.js | 6 +- src/store/__mocks__/RelayStore.js | 4 +- .../__mocks__/observeAllRelayQueryData.js | 2 + src/store/__mocks__/observeRelayQueryData.js | 2 + .../RelayPendingQueryTracker-test.js | 4 - src/store/__tests__/RelayRecordStore-test.js | 122 +++--- .../__tests__/RelayRecordStore_write-test.js | 38 +- src/store/__tests__/RelayStoreData-test.js | 4 +- .../RelayStoreData_cacheManager-test.js | 18 +- .../RelayStoreGarbageCollector-test.js | 6 +- .../observeAllRelayQueryData-test.js | 4 +- .../__tests__/observeRelayQueryData-test.js | 140 ++++--- .../__tests__/readRelayQueryData-test.js | 124 +++--- .../__tests__/validateRelayReadQuery-test.js | 2 +- src/store/observeAllRelayQueryData.js | 3 + src/store/observeRelayQueryData.js | 2 + src/store/validateRelayReadQuery.js | 2 +- src/tools/RelayDeprecated.js | 4 +- src/tools/RelayGarbageCollection.js | 2 +- src/tools/RelayProfiler.js | 4 +- src/tools/RelayTaskScheduler.js | 2 +- src/tools/RelayTypes.js | 2 +- src/tools/__mocks__/RelayProfiler.js | 2 +- src/tools/__mocks__/RelayTestUtils.js | 10 +- src/tools/__mocks__/matchRecord.js | 16 +- src/tools/__tests__/RelayProfiler-test.js | 8 +- .../__tests__/RelayTaskScheduler-test.js | 8 +- .../__tests__/checkRelayQueryData-test.js | 51 ++- .../containsRelayQueryRootCall-test.js | 2 +- .../__tests__/diffRelayQuery-test.js | 195 +++++----- .../diffRelayQuery_connection-test.js | 357 +++++++++--------- .../__tests__/diffRelayQuery_scalar-test.js | 4 +- .../inferRelayFieldsFromData-test.js | 10 +- .../splitDeferredRelayQueries-test.js | 10 +- .../__tests__/subtractRelayQuery-test.js | 4 +- ...eRelayQueryPayload_connectionField-test.js | 146 +++---- ...writeRelayQueryPayload_linkedField-test.js | 32 +- .../writeRelayQueryPayload_paths-test.js | 4 +- ...elayQueryPayload_pluralLinkedField-test.js | 66 ++-- ...elayQueryPayload_pluralScalarField-test.js | 46 +-- .../writeRelayQueryPayload_rootRecord-test.js | 20 +- ...writeRelayQueryPayload_scalarField-test.js | 54 +-- .../__tests__/writeRelayUpdatePayload-test.js | 12 +- src/traversal/checkRelayQueryData.js | 6 +- src/traversal/containsRelayQueryRootCall.js | 2 +- src/traversal/diffRelayQuery.js | 8 +- src/traversal/flattenRelayQuery.js | 2 +- src/traversal/splitDeferredRelayQueries.js | 2 +- src/traversal/subtractRelayQuery.js | 2 +- src/traversal/writeRelayUpdatePayload.js | 4 +- 120 files changed, 1620 insertions(+), 1301 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc create mode 100644 eslint-rules/README.md create mode 100644 eslint-rules/__tests__/warning-and-invariant-args-test.js create mode 100644 eslint-rules/index.js create mode 100644 eslint-rules/package.json create mode 100644 eslint-rules/warning-and-invariant-args.js diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000000..9e7436c5c2d20 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,9 @@ +dist/ +docs/ +examples/ +node_modules/ +lib/ +scripts/ +# for disable website but should be done as well +website/ +*.md diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000000000..72601abdc8adb --- /dev/null +++ b/.eslintrc @@ -0,0 +1,101 @@ +--- +parser: babel-eslint + +plugins: + - react + - react-internal + +env: + browser: true + node: true + +globals: + __DEV__: true + # Jest / Jasmine + describe: false + xdescribe: false + beforeEach: false + afterEach: false + it: false + xit: false + jest: false + pit: false + expect: false + spyOn: false + jasmine: false + +rules: + # ERRORS + space-before-blocks: 2 + indent: [2, 2, {SwitchCase: 1}] + brace-style: 2 + space-after-keywords: 2 + strict: [2, global] + comma-dangle: [2, always-multiline] + # Make this a warning for now. We do this in a few places so we might need to + # disable + no-unused-expressions: 2 + eol-last: 2 + dot-notation: 2 + dot-location: [2, property] + consistent-return: 2 + no-unused-vars: [2, args: none] + quotes: [2, single, avoid-escape] + no-shadow: 2 + no-multi-spaces: 2 + + # WISHLIST. One day... + # We'll need a custom version of this that does a subset of the whole rule. + # Otherwise this is just too noisy. + # valid-jsdoc: 1 + # Ideally, we could just warn when *new* lines are added that exceed 80 chars + # while not warning about existing ones (often URLs, etc. which are + # necessarily long), but we don't have a good way to do so. + # max-len: [0, 80] + + # DISABLED. These aren't compatible with our style + # We use this for private/internal variables + no-underscore-dangle: 0 + # We pass constructors around / access them from members + new-cap: 0 + # We do this a lot. + no-use-before-define: 0 + # We do this in a few places to align values + key-spacing: 0 + # It's nice to be able to leave catch blocks empty + no-empty: 0 + # It makes code more readable to make this explicit sometimes + no-undef-init: 0 + + # BROKEN. We'd like to turn these back on. + # causes a ton of noise, eslint is too picky? + block-scoped-var: 0 + + # JSX + # Our transforms set this automatically + react/display-name: 0 + react/jsx-boolean-value: [2, always] + react/jsx-no-undef: 2 + react/jsx-quotes: [2, double] + # We don't care to do this + react/jsx-sort-prop-types: 0 + react/jsx-sort-props: 0 + react/jsx-uses-react: 2 + react/jsx-uses-vars: 2 + # It's easier to test some things this way + react/no-did-mount-set-state: 0 + react/no-did-update-set-state: 0 + # We define multiple components in test files + react/no-multi-comp: 0 + react/no-unknown-property: 2 + # This isn't useful in our test code + react/prop-types: 0 + react/react-in-jsx-scope: 2 + react/self-closing-comp: 2 + # We don't care to do this + react/sort-comp: 0 + react/wrap-multilines: [2, {declaration: false, assignment: false}] + + # CUSTOM RULES + # the second argument of warning/invariant should be a literal string + react-internal/warning-and-invariant-args: 2 diff --git a/eslint-rules/README.md b/eslint-rules/README.md new file mode 100644 index 0000000000000..9d081e69e72f2 --- /dev/null +++ b/eslint-rules/README.md @@ -0,0 +1,5 @@ +# Custom ESLint Rules + +This is a dummy npm package that allows us to treat it as an eslint-plugin. It's not actually published, nor are the rules here useful for users of react. If you want to lint your react code, try . + +**If you modify this rule, you must re-run `npm install ./eslint-rules` for it to take effect.** diff --git a/eslint-rules/__tests__/warning-and-invariant-args-test.js b/eslint-rules/__tests__/warning-and-invariant-args-test.js new file mode 100644 index 0000000000000..af1f26c74b3c5 --- /dev/null +++ b/eslint-rules/__tests__/warning-and-invariant-args-test.js @@ -0,0 +1,102 @@ +/** + * Copyright 2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @emails react-core + */ + +'use strict'; + +var rule = require('../warning-and-invariant-args'); +var RuleTester = require('eslint').RuleTester; +var ruleTester = new RuleTester(); + +ruleTester.run('eslint-rules/warning-and-invariant-args', rule, { + valid: [ + "warning(true, 'hello, world');", + "warning(true, 'expected %s, got %s', 42, 24);", + "invariant(true, 'hello, world');", + "invariant(true, 'expected %s, got %s', 42, 24);", + ], + invalid: [ + { + code: "warning('hello, world');", + errors: [ + { + message: 'warning takes at least two arguments', + }, + ], + }, + { + code: 'warning(true, null);', + errors: [ + { + message: 'The second argument to warning must be a string literal', + }, + ], + }, + { + code: 'var g = 5; invariant(true, g);', + errors: [ + { + message: 'The second argument to invariant must be a string literal', + }, + ], + }, + { + code: "warning(true, 'expected %s, got %s');", + errors: [ + { + message: + 'Expected 4 arguments in call to warning based on the number of ' + + '"%s" substitutions, but got 2', + }, + ], + }, + { + code: "warning(true, 'foo is a bar under foobar', 'junk argument');", + errors: [ + { + message: + 'Expected 2 arguments in call to warning based on the number of ' + + '"%s" substitutions, but got 3', + }, + ], + }, + { + code: "invariant(true, 'error!');", + errors: [ + { + message: + 'The invariant format should be able to uniquely identify this ' + + 'invariant. Please, use a more descriptive format than: error!', + }, + ], + }, + { + code: "warning(true, 'error!');", + errors: [ + { + message: + 'The warning format should be able to uniquely identify this ' + + 'warning. Please, use a more descriptive format than: error!', + }, + ], + }, + { + code: "warning(true, '%s %s, %s %s: %s (%s)', 1, 2, 3, 4, 5, 6);", + errors: [ + { + message: + 'The warning format should be able to uniquely identify this ' + + 'warning. Please, use a more descriptive format than: ' + + '%s %s, %s %s: %s (%s)', + }, + ], + }, + ], +}); diff --git a/eslint-rules/index.js b/eslint-rules/index.js new file mode 100644 index 0000000000000..5efee2d47caf2 --- /dev/null +++ b/eslint-rules/index.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = { + rules: { + 'warning-and-invariant-args': require('./warning-and-invariant-args'), + }, +}; diff --git a/eslint-rules/package.json b/eslint-rules/package.json new file mode 100644 index 0000000000000..6424cce415ee3 --- /dev/null +++ b/eslint-rules/package.json @@ -0,0 +1,4 @@ +{ + "name": "eslint-plugin-react-internal", + "version": "0.0.0" +} diff --git a/eslint-rules/warning-and-invariant-args.js b/eslint-rules/warning-and-invariant-args.js new file mode 100644 index 0000000000000..3611935579da8 --- /dev/null +++ b/eslint-rules/warning-and-invariant-args.js @@ -0,0 +1,88 @@ +/** + * Copyright 2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @emails react-core +*/ + +'use strict'; + +/** + * The warning() and invariant() functions take format strings as their second + * argument. + */ + +module.exports = function(context) { + // we also allow literal strings and concatinated literal strings + function getLiteralString(node) { + if (node.type === 'Literal' && typeof node.value === 'string') { + return node.value; + } else if (node.type === 'BinaryExpression' && node.operator === '+') { + var l = getLiteralString(node.left); + var r = getLiteralString(node.right); + if (l !== null && r !== null) { + return l + r; + } + } + return null; + } + + return { + CallExpression: function(node) { + // This could be a little smarter by checking context.getScope() to see + // how warning/invariant was defined. + var isWarningOrInvariant = + node.callee.type === 'Identifier' && + (node.callee.name === 'warning' || node.callee.name === 'invariant'); + if (!isWarningOrInvariant) { + return; + } + if (node.arguments.length < 2) { + context.report( + node, + '{{name}} takes at least two arguments', + {name: node.callee.name} + ); + return; + } + var format = getLiteralString(node.arguments[1]); + if (format === null) { + context.report( + node, + 'The second argument to {{name}} must be a string literal', + {name: node.callee.name} + ); + return; + } + if (format.length < 10 || /^[s\W]*$/.test(format)) { + context.report( + node, + 'The {{name}} format should be able to uniquely identify this ' + + '{{name}}. Please, use a more descriptive format than: {{format}}', + {name: node.callee.name, format: format} + ); + return; + } + // count the number of formating substitutions, plus the first two args + var expectedNArgs = (format.match(/%s/g) || []).length + 2; + if (node.arguments.length !== expectedNArgs) { + context.report( + node, + 'Expected {{expectedNArgs}} arguments in call to {{name}} based on ' + + 'the number of "%s" substitutions, but got {{length}}', + { + expectedNArgs: expectedNArgs, + name: node.callee.name, + length: node.arguments.length, + } + ); + } + }, + }; +}; + +module.exports.schema = []; diff --git a/gulpfile.js b/gulpfile.js index a94c2ed8b4909..9add46b518f36 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +/* eslint-disable */ + 'use strict'; var babel = require('gulp-babel'); diff --git a/package.json b/package.json index 8e2f2a02b6e15..705b00d758e43 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "build": "[ $(ulimit -n) -lt 4096 ] && ulimit -n 4096; gulp", "preinstall": "cd scripts/babel-relay-plugin/ && npm install", "prepublish": "npm run build", + "lint": "`npm bin`/eslint .", "test": "NODE_ENV=test jest" }, "engines": { @@ -39,9 +40,14 @@ }, "devDependencies": { "babel-core": "5.8.21", + "babel-eslint": "^4.0.5", "babel-loader": "5.3.2", "del": "^1.2.0", "envify": "^3.4.0", + "eslint": "^1.1.0", + "eslint-plugin-react": "^3.2.2", + "eslint-plugin-react-internal": "file:eslint-rules", + "eslint-tester": "^0.8.2", "gulp": "^3.9.0", "gulp-babel": "^5.1.0", "gulp-derequire": "^2.1.0", diff --git a/src/__forks__/container/RelayContainerProxy.js b/src/__forks__/container/RelayContainerProxy.js index 7e49fc8327d48..12be926316075 100644 --- a/src/__forks__/container/RelayContainerProxy.js +++ b/src/__forks__/container/RelayContainerProxy.js @@ -11,6 +11,8 @@ * @flow */ + /* eslint no-shadow: 1 */ + 'use strict'; import type {RelayContainer} from 'RelayTypes'; @@ -22,7 +24,7 @@ var RelayContainerProxy = { proxyMethods( RelayContainer: RelayContainer, Component: ReactClass - ): void {} + ): void {}, }; module.exports = RelayContainerProxy; diff --git a/src/__forks__/interface/RelayConnectionInterface.js b/src/__forks__/interface/RelayConnectionInterface.js index 6af932564931d..835871afd0586 100644 --- a/src/__forks__/interface/RelayConnectionInterface.js +++ b/src/__forks__/interface/RelayConnectionInterface.js @@ -80,4 +80,4 @@ var RelayConnectionInterface = { }, }; -module.exports = RelayConnectionInterface; \ No newline at end of file +module.exports = RelayConnectionInterface; diff --git a/src/__forks__/traversal/__tests__/printRelayQuery-test.js b/src/__forks__/traversal/__tests__/printRelayQuery-test.js index a0aebead924bb..2341538067a16 100644 --- a/src/__forks__/traversal/__tests__/printRelayQuery-test.js +++ b/src/__forks__/traversal/__tests__/printRelayQuery-test.js @@ -149,7 +149,7 @@ describe('printRelayQuery', () => { }, } `, { - env: value + env: value, }); expect(printRelayQuery(query)).toEqual(trimQuery(` query FooQuery { diff --git a/src/__forks__/traversal/printRelayQuery.js b/src/__forks__/traversal/printRelayQuery.js index 05048fb33c725..93c91fb49cb09 100644 --- a/src/__forks__/traversal/printRelayQuery.js +++ b/src/__forks__/traversal/printRelayQuery.js @@ -13,7 +13,6 @@ 'use strict'; -import type {Call} from 'RelayInternalTypes'; var RelayProfiler = require('RelayProfiler'); var RelayQuery = require('RelayQuery'); @@ -148,17 +147,17 @@ function printChildren( node: RelayQuery.Node, fragmentMap: FragmentMap ): string { - var children = node.getChildren().map(node => { - if (node instanceof RelayQuery.Field) { - return printField(node, fragmentMap); + var children = node.getChildren().map(childrenNode => { + if (childrenNode instanceof RelayQuery.Field) { + return printField(childrenNode, fragmentMap); } else { invariant( - node instanceof RelayQuery.Fragment, + childrenNode instanceof RelayQuery.Fragment, 'printRelayQuery(): expected child node to be a `Field` or ' + '`Fragment`, got `%s`.', - node.constructor.name + childrenNode.constructor.name ); - return printInlineFragment(node, fragmentMap); + return printInlineFragment(childrenNode, fragmentMap); } }); if (!children.length) { diff --git a/src/container/RelayContainer.js b/src/container/RelayContainer.js index e6496afa4cc74..6621d249c584c 100644 --- a/src/container/RelayContainer.js +++ b/src/container/RelayContainer.js @@ -11,6 +11,9 @@ * @flow */ +/* eslint no-shadow: 1 */ +/* eslint no-unused-expressions: 1 */ + 'use strict'; var ErrorUtils = require('ErrorUtils'); diff --git a/src/container/__tests__/RelayContainer-test.js b/src/container/__tests__/RelayContainer-test.js index b18c7cee2bdf1..887c357cda44f 100644 --- a/src/container/__tests__/RelayContainer-test.js +++ b/src/container/__tests__/RelayContainer-test.js @@ -25,12 +25,9 @@ describe('RelayContainer', function() { var React; var ReactTestUtils; var Relay; - var RelayMetaRoute; var RelayQuery; var RelayRoute; - var toGraphQL; - var MockContainer; var MockComponent; var RelayTestRenderer; @@ -71,8 +68,8 @@ describe('RelayContainer', function() { ), bar: jest.genMockFunction().mockImplementation( () => Relay.QL`fragment on Node @relay(plural:true){id,name}` - ) - } + ), + }, }); MockContainer.mock = {render}; @@ -104,7 +101,7 @@ describe('RelayContainer', function() { var BadContainer = Relay.createContainer(MockComponent, { fragments: { viewer: () => Relay.QL`query{node(id:"123"){id}}`, - } + }, }); var badFragmentReference = BadContainer.getFragment('viewer'); expect(() => { @@ -130,8 +127,8 @@ describe('RelayContainer', function() { uri } } - ` - } + `, + }, }); var fragment = getNode( MockProfilePhoto.getQuery('photo'), @@ -147,7 +144,7 @@ describe('RelayContainer', function() { ), new GraphQL.Field( 'id', null, null, null, null, null, {generated: true} - ) + ), ]) )); }); @@ -162,8 +159,8 @@ describe('RelayContainer', function() { name, ${MockProfileLink.getQuery('user')} } - ` - } + `, + }, }); var MockProfileLink = Relay.createContainer(anotherComponent, { fragments: { @@ -172,8 +169,8 @@ describe('RelayContainer', function() { id, url } - ` - } + `, + }, }); var fragment = getNode( MockProfile.getQuery('user'), @@ -182,19 +179,18 @@ describe('RelayContainer', function() { expect(fragment).toEqualQueryNode(getNode( new GraphQL.QueryFragment('Test', 'Actor', [ new GraphQL.Field('id'), - new GraphQL.Field('name') + new GraphQL.Field('name'), ], [ new GraphQL.QueryFragment('Test', 'Actor', [ new GraphQL.Field('id'), - new GraphQL.Field('url') - ]) + new GraphQL.Field('url'), + ]), ]) )); }); }); describe('conditional fragments', () => { - var sideshowFragment; var MockFeed; var feedFragment; @@ -205,8 +201,8 @@ describe('RelayContainer', function() { fragment on Viewer { newsFeed, } - ` - } + `, + }, }); sideshowFragment = new GraphQL.QueryFragment('Test', 'Viewer'); feedFragment = @@ -225,14 +221,14 @@ describe('RelayContainer', function() { fragment on Viewer { ${MockFeed.getQuery('viewer').if(variables.hasSideshow)}, } - ` - } + `, + }, }); // hasSideshow: true var fragment = getNode( MockSideshow.getQuery('viewer', { - hasSideshow: new GraphQL.CallVariable('sideshow') + hasSideshow: new GraphQL.CallVariable('sideshow'), }), {sideshow: true} ); @@ -246,7 +242,7 @@ describe('RelayContainer', function() { // hasSideshow: false fragment = getNode( MockSideshow.getQuery('viewer', { - hasSideshow: new GraphQL.CallVariable('sideshow') + hasSideshow: new GraphQL.CallVariable('sideshow'), }), {sideshow: false} ); @@ -265,8 +261,8 @@ describe('RelayContainer', function() { .getQuery('viewer') .unless(variables.hasSideshow)}, } - ` - } + `, + }, }); // hasSideshow: true @@ -513,7 +509,7 @@ describe('RelayContainer', function() { it('re-renders if props resolve to different objects', () => { var mockDataList = [ {__dataID__: '42', id: '42', name: 'Tim', ...mockFooPointer}, - {__dataID__: '42', id: '42', name: 'Tee', ...mockFooPointer} + {__dataID__: '42', id: '42', name: 'Tee', ...mockFooPointer}, ]; GraphQLStoreQueryResolver.mockResolveImplementation(0, function() { @@ -542,7 +538,7 @@ describe('RelayContainer', function() { var mockDataSet = { '42': {__dataID__: '42', name: 'Tim'}, '43': {__dataID__: '43', name: 'Tee'}, - '44': {__dataID__: '44', name: 'Toe'} + '44': {__dataID__: '44', name: 'Toe'}, }; var render = jest.genMockFunction().mockImplementation(() =>
); var shouldComponentUpdate = jest.genMockFunction(); @@ -553,8 +549,8 @@ describe('RelayContainer', function() { fragments: { foo: jest.genMockFunction().mockImplementation( () => Relay.QL`fragment on Node{id,name}` - ) - } + ), + }, }); GraphQLStoreQueryResolver.mockResolveImplementation(0, (pointer) => { diff --git a/src/container/__tests__/RelayContainer_Component-test.js b/src/container/__tests__/RelayContainer_Component-test.js index 565fa2f3dedac..c5e2681910620 100644 --- a/src/container/__tests__/RelayContainer_Component-test.js +++ b/src/container/__tests__/RelayContainer_Component-test.js @@ -37,7 +37,7 @@ describe('RelayContainer', function() { reactComponentExpect = require('reactComponentExpect'); MockComponent = React.createClass({ - render: jest.genMockFunction().mockImplementation(() =>
) + render: jest.genMockFunction().mockImplementation(() =>
), }); mockCreateContainer = component => { @@ -46,8 +46,8 @@ describe('RelayContainer', function() { fragments: { foo: jest.genMockFunction().mockImplementation( variables => Relay.QL`fragment on Node{id,url(site:$site)}` - ) - } + ), + }, }); }; diff --git a/src/container/__tests__/RelayContainer_hasFragmentData-test.js b/src/container/__tests__/RelayContainer_hasFragmentData-test.js index e546fb4839b6f..eff8df66c1e0c 100644 --- a/src/container/__tests__/RelayContainer_hasFragmentData-test.js +++ b/src/container/__tests__/RelayContainer_hasFragmentData-test.js @@ -41,8 +41,8 @@ describe('RelayContainer.hasFragmentData', function() { fragments: { foo: jest.genMockFunction().mockImplementation( variables => Relay.QL`fragment on Node{id,url(site:$site)}` - ) - } + ), + }, }); MockContainer.mock = {render}; diff --git a/src/container/__tests__/RelayContainer_hasOptimisticUpdate-test.js b/src/container/__tests__/RelayContainer_hasOptimisticUpdate-test.js index 1e65fa1489e37..5e6e95919b395 100644 --- a/src/container/__tests__/RelayContainer_hasOptimisticUpdate-test.js +++ b/src/container/__tests__/RelayContainer_hasOptimisticUpdate-test.js @@ -39,7 +39,7 @@ describe('RelayContainer.hasOptimisticUpdate', () => { } } MockContainer = Relay.createContainer(MockComponent, { - fragments: {foo: () => Relay.QL`fragment on Node{id}`} + fragments: {foo: () => Relay.QL`fragment on Node{id}`}, }); RelayTestRenderer = RelayTestUtils.createRenderer(); diff --git a/src/container/__tests__/RelayContainer_setVariables-test.js b/src/container/__tests__/RelayContainer_setVariables-test.js index b84f616e5dadd..72ca6e5a04086 100644 --- a/src/container/__tests__/RelayContainer_setVariables-test.js +++ b/src/container/__tests__/RelayContainer_setVariables-test.js @@ -52,9 +52,9 @@ describe('RelayContainer.setVariables', function() { var createContainer = Relay.createContainer; MockContainer = createContainer(MockComponent, { fragments: { - entity: entityQuery + entity: entityQuery, }, - initialVariables: {site: 'mobile'} + initialVariables: {site: 'mobile'}, }); GraphQLStoreQueryResolver.mockDefaultResolveImplementation(pointer => { @@ -64,8 +64,8 @@ describe('RelayContainer.setVariables', function() { id: '42', url: '//url', profilePicture: { - uri: '//url' - } + uri: '//url', + }, }; }); defaultState = { @@ -96,8 +96,8 @@ describe('RelayContainer.setVariables', function() { id: '42', url: '//url', profilePicture: { - uri: '//url' - } + uri: '//url', + }, }]; }); var pluralEntityQuery = jest.genMockFunction().mockImplementation( @@ -105,9 +105,9 @@ describe('RelayContainer.setVariables', function() { ); MockContainer = Relay.createContainer(MockComponent, { fragments: { - entity: pluralEntityQuery + entity: pluralEntityQuery, }, - initialVariables: {site: 'mobile'} + initialVariables: {site: 'mobile'}, }); // Return an array @@ -119,16 +119,16 @@ describe('RelayContainer.setVariables', function() { id: '21', url: '//url', profilePicture: { - uri: '//url' - } + uri: '//url', + }, }, { __dataID__: '42', id: '42', url: '//url', profilePicture: { - uri: '//url' - } + uri: '//url', + }, }, ]; }); @@ -157,7 +157,7 @@ describe('RelayContainer.setVariables', function() { it('creates queries only for records with dataIDs', () => { var updatedQueryData = [ {__dataID__: '21', id: '21', url: '//www'}, - {id:'1336', name: 'Fake data', url: '//www'} + {id:'1336', name: 'Fake data', url: '//www'}, ]; GraphQLStoreQueryResolver.mockDefaultResolveImplementation(pointer => { return updatedQueryData; @@ -413,7 +413,7 @@ describe('RelayContainer.setVariables', function() { var createContainer = Relay.createContainer; MockContainer = createContainer(MockComponent, { fragments: { - entity: entityQuery + entity: entityQuery, }, initialVariables: {site: 'mobile'}, prepareVariables, @@ -489,9 +489,9 @@ describe('RelayContainer.setVariables', function() { var MockInnerContainer = Relay.createContainer(MockInnerComponent, { fragments: { - entity: variables => Relay.QL`fragment on Node{url(site:$site)}` + entity: variables => Relay.QL`fragment on Node{url(site:$site)}`, }, - initialVariables: {site: undefined} + initialVariables: {site: undefined}, }); class MockWrapperComponent extends React.Component { @@ -510,9 +510,9 @@ describe('RelayContainer.setVariables', function() { fragments: { entity: variables => Relay.QL` fragment on Node{ ${MockInnerContainer.getFragment('entity', {site: variables.site})} - }` + }`, }, - initialVariables: {site: 'mobile'} + initialVariables: {site: 'mobile'}, }); mockInstance = RelayTestUtils.createRenderer(domContainer).render( @@ -543,12 +543,12 @@ describe('RelayContainer.setVariables', function() { profilePicture(size:$size) { uri, }, - }` + }`, }, initialVariables: { site: undefined, size: 48, - } + }, }); class MockWrapperComponent extends React.Component { @@ -567,9 +567,9 @@ describe('RelayContainer.setVariables', function() { fragments: { entity: variables => Relay.QL` fragment on Actor { ${MockInnerContainer.getFragment('entity', {site: variables.site})} - }` + }`, }, - initialVariables: {site: 'mobile'} + initialVariables: {site: 'mobile'}, }); mockInstance = RelayTestUtils.createRenderer(domContainer).render( diff --git a/src/container/__tests__/RelayRootContainer-test.js b/src/container/__tests__/RelayRootContainer-test.js index 9b37b97c3da28..1498bec9ad46c 100644 --- a/src/container/__tests__/RelayRootContainer-test.js +++ b/src/container/__tests__/RelayRootContainer-test.js @@ -24,7 +24,6 @@ describe('RelayRootContainer', function() { var RelayRootContainer; var RelayRoute; var RelayStore; - var RelayTypes; var ReactComponent; var RelayContainer; @@ -48,7 +47,7 @@ describe('RelayRootContainer', function() { ReactComponent = React.createClass({render: () =>
}); RelayContainer = Relay.createContainer(ReactComponent, { - fragments: {} + fragments: {}, }); ShallowRenderer = ReactTestUtils.createRenderer(); @@ -81,7 +80,7 @@ describe('RelayRootContainer', function() { }); var container = document.createElement('div'); jest.addMatchers({ - toRenderChildWithRoute(route) { + toRenderChildWithRoute(childRoute) { var context; function onRender() { context = this.context; @@ -96,7 +95,7 @@ describe('RelayRootContainer', function() { ReactDOM.render(element, container); var mockRequests = RelayStore.primeCache.mock.requests; mockRequests[mockRequests.length - 1].block(); - return context.route === route; + return context.route === childRoute; }, }); }); @@ -248,7 +247,7 @@ describe('RelayRootContainer', function() { it('creates and primes queries when `Component` changes', () => { var AnotherComponent = React.createClass({render: () =>
}); var AnotherContainer = Relay.createContainer(AnotherComponent, { - fragments: {} + fragments: {}, }); ShallowRenderer.render( @@ -391,7 +390,7 @@ describe('RelayRootContainer', function() { it('aborts loading requests', () => { function mockLoading(request) { - request.block(); + request.block(); } expect(mockLoading).toAbortOnUpdate(); expect(mockLoading).toAbortOnUnmount(); @@ -573,7 +572,7 @@ describe('RelayRootContainer', function() { { done: true, stale: false, - } + }, ]); }); diff --git a/src/container/__tests__/getRelayQueries-test.js b/src/container/__tests__/getRelayQueries-test.js index 57c3ef3a166f9..50824933a978d 100644 --- a/src/container/__tests__/getRelayQueries-test.js +++ b/src/container/__tests__/getRelayQueries-test.js @@ -44,7 +44,7 @@ describe('getRelayQueries', () => { fragments: { first: () => Relay.QL`fragment on Node{id,firstName}`, last: () => Relay.QL`fragment on Node{id,lastName}`, - } + }, }); makeRoute = function() { @@ -54,7 +54,7 @@ describe('getRelayQueries', () => { MockRoute.paramDefinitions = { id: { type: 'String', - id: true + id: true, }, }; MockRoute.queries = { diff --git a/src/container/__tests__/isRelayContainer-test.js b/src/container/__tests__/isRelayContainer-test.js index 08a01e5aed0ee..7f04c54196ba5 100644 --- a/src/container/__tests__/isRelayContainer-test.js +++ b/src/container/__tests__/isRelayContainer-test.js @@ -25,11 +25,11 @@ describe('isRelayContainer', function() { Relay = require('Relay'); MockComponent = React.createClass({ - render: () =>
+ render: () =>
, }); MockContainer = Relay.createContainer(MockComponent, { - fragments: {} + fragments: {}, }); }); diff --git a/src/legacy/mutation/GraphQLMutatorConstants.js b/src/legacy/mutation/GraphQLMutatorConstants.js index ca4247535304c..f566fe9f01847 100644 --- a/src/legacy/mutation/GraphQLMutatorConstants.js +++ b/src/legacy/mutation/GraphQLMutatorConstants.js @@ -29,7 +29,7 @@ var GraphQLMutatorConstants = { UPDATE_TYPES: {}, - RANGE_OPERATIONS: {} + RANGE_OPERATIONS: {}, }; GraphQLMutatorConstants.HANDLER_TYPES diff --git a/src/legacy/query/GraphQL_EXPERIMENTAL.js b/src/legacy/query/GraphQL_EXPERIMENTAL.js index 408dad24870ab..75786edc40e84 100644 --- a/src/legacy/query/GraphQL_EXPERIMENTAL.js +++ b/src/legacy/query/GraphQL_EXPERIMENTAL.js @@ -108,7 +108,7 @@ class GraphQLCallvNode { JSON_TYPES.CALL, this.name, this.value, - this.metadata === EMPTY_OBJECT ? null : this.metadata + this.metadata === EMPTY_OBJECT ? null : this.metadata, ]); } } @@ -139,7 +139,7 @@ class GraphQLCallValue { toJSON() { return [ JSON_TYPES.CALL_VALUE, - this.callValue + this.callValue, ]; } } @@ -188,7 +188,7 @@ class GraphQLBatchCallVariable { return [ JSON_TYPES.BATCH_VARIABLE, this.sourceQueryID, - this.jsonPath + this.jsonPath, ]; } } @@ -225,7 +225,7 @@ class GraphQLCallVariable { toJSON() { return [ JSON_TYPES.CALL_VARIABLE, - this.callVariableName + this.callVariableName, ]; } } @@ -284,7 +284,7 @@ class GraphQLFieldNode extends GraphQLNode { calls, alias, condition, - metadata + metadata, ] = descriptor; invariant(type === JSON_TYPES.FIELD, 'Expected field descriptor'); return new GraphQLFieldNode( @@ -307,7 +307,7 @@ class GraphQLFieldNode extends GraphQLNode { this.calls.length ? this._calls : null, this.alias, this.condition, - this.__metadata__ === EMPTY_OBJECT ? null : this.__metadata__ + this.__metadata__ === EMPTY_OBJECT ? null : this.__metadata__, ]); } } @@ -357,7 +357,7 @@ class GraphQLQueryFragment extends GraphQLNode { this.type, this.fields.length ? this.fields : null, this.fragments.length ? this.fragments : null, - this.metadata + this.metadata, ]); } } @@ -424,7 +424,7 @@ class GraphQLQuery extends GraphQLNode { this.fields.length ? this.fields : null, this.fragments.length ? this.fragments : null, this.__metadata__ !== EMPTY_OBJECT ? this.__metadata__ : null, - this.name || null + this.name || null, ]); } } @@ -470,7 +470,7 @@ class GraphQLQueryWithValues { return trimArray([ JSON_TYPES.QUERY_WITH_VALUES, this.query, - this.values + this.values, ]); } } @@ -526,7 +526,7 @@ class GraphQLMutation extends GraphQLOperation { mutationCall, fields, fragments, - metadata + metadata, ] = descriptor; invariant(type === JSON_TYPES.MUTATION, 'Expected mutation descriptor'); return new GraphQLMutation( @@ -542,7 +542,7 @@ class GraphQLMutation extends GraphQLOperation { /** * @return {number} */ - getJSONType() { + getJSONType() { return JSON_TYPES.MUTATION; } } @@ -568,7 +568,7 @@ class GraphQLSubscription extends GraphQLOperation { subscriptionCall, fields, fragments, - metadata + metadata, ] = descriptor; invariant( type === JSON_TYPES.SUBSCRIPTION, @@ -587,7 +587,7 @@ class GraphQLSubscription extends GraphQLOperation { /** * @return {number} */ - getJSONType() { + getJSONType() { return JSON_TYPES.SUBSCRIPTION; } } diff --git a/src/legacy/store/GraphQLDeferredQueryTracker.js b/src/legacy/store/GraphQLDeferredQueryTracker.js index a44925ba8570d..a75c88f257af0 100644 --- a/src/legacy/store/GraphQLDeferredQueryTracker.js +++ b/src/legacy/store/GraphQLDeferredQueryTracker.js @@ -112,7 +112,7 @@ var GraphQLDeferredQueryTracker = { 'remove() can only be called once' ); subscribers[index] = null; - } + }, }; }, @@ -219,7 +219,7 @@ var GraphQLDeferredQueryTracker = { rootCallToFragmentNameMap = new Map(); subscribers = []; broadcastItems = null; - } + }, }; /** @@ -421,7 +421,7 @@ function processBroadcasts() { } } - subscribers = subscribers.filter(subscriber => subscriber !== null); + subscribers = subscribers.filter(sub => sub !== null); broadcastItems = null; } diff --git a/src/legacy/store/GraphQLQueryRunner.js b/src/legacy/store/GraphQLQueryRunner.js index 37382075aa120..8f86d742e1400 100644 --- a/src/legacy/store/GraphQLQueryRunner.js +++ b/src/legacy/store/GraphQLQueryRunner.js @@ -11,6 +11,8 @@ * @flow */ + /* eslint no-unused-expressions: 1 */ + 'use strict'; var DliteFetchModeConstants = require('DliteFetchModeConstants'); @@ -290,7 +292,7 @@ function runQueries( return { abort(): void { setReadyState({aborted: true}); - } + }, }; } diff --git a/src/legacy/store/GraphQLRange.js b/src/legacy/store/GraphQLRange.js index 36975170c84d5..a2b5d31122545 100644 --- a/src/legacy/store/GraphQLRange.js +++ b/src/legacy/store/GraphQLRange.js @@ -176,7 +176,7 @@ class GraphQLRange { // the range (i.e. last(N)). this._orderedSegments = [ new GraphQLSegment(), - new GraphQLSegment() + new GraphQLSegment(), ]; // GraphQLRange nodes can also support static queries like surrounds, @@ -247,7 +247,7 @@ class GraphQLRange { this._staticQueriesMap[calls] = { edgeIDs: edgeIDsToStore, - cursors: cursorsToStore + cursors: cursorsToStore, }; } @@ -846,7 +846,7 @@ class GraphQLRange { var segment; var segmentIndex; var pageInfo = { - ...RelayConnectionInterface.getDefaultPageInfo() + ...RelayConnectionInterface.getDefaultPageInfo(), }; var afterCursor = calls.after; @@ -949,7 +949,7 @@ class GraphQLRange { var segment; var segmentIndex; var pageInfo = { - ...RelayConnectionInterface.getDefaultPageInfo() + ...RelayConnectionInterface.getDefaultPageInfo(), }; var beforeCursor = calls.before; @@ -1037,29 +1037,29 @@ class GraphQLRange { hasFirst, hasLast, staticQueriesMap, - orderedSegments + orderedSegments, ] = descriptor; var range = new GraphQLRange(); range._hasFirst = hasFirst; range._hasLast = hasLast; range._staticQueriesMap = staticQueriesMap; range._orderedSegments = - orderedSegments.map(descriptor => GraphQLSegment.fromJSON(descriptor)); + orderedSegments.map(orderedSegment => GraphQLSegment.fromJSON(orderedSegment)); return range; } - toJSON(){ + toJSON() { return [ this._hasFirst, this._hasLast, this._staticQueriesMap, - this._orderedSegments + this._orderedSegments, ]; } __debug() { return { - orderedSegments: this._orderedSegments + orderedSegments: this._orderedSegments, }; } diff --git a/src/legacy/store/GraphQLSegment.js b/src/legacy/store/GraphQLSegment.js index 95778f1adc5ea..ab67479f6b18d 100644 --- a/src/legacy/store/GraphQLSegment.js +++ b/src/legacy/store/GraphQLSegment.js @@ -161,7 +161,7 @@ class GraphQLSegment { if (!this.getLength()) { return { edgeIDs: [], - cursors: [] + cursors: [], }; } var currentIndex = this._minIndex; @@ -171,7 +171,7 @@ class GraphQLSegment { console.error('This segment does not have a cursor %s', cursor); return { edgeIDs: [], - cursors: [] + cursors: [], }; } currentIndex = index + 1; @@ -191,7 +191,7 @@ class GraphQLSegment { } return { edgeIDs: edgeIDs, - cursors: cursors + cursors: cursors, }; } @@ -205,7 +205,7 @@ class GraphQLSegment { if (!this.getLength()) { return { edgeIDs: [], - cursors: [] + cursors: [], }; } var currentIndex = this._maxIndex; @@ -215,7 +215,7 @@ class GraphQLSegment { console.error('This segment does not have a cursor %s', cursor); return { edgeIDs: [], - cursors: [] + cursors: [], }; } currentIndex = index - 1; @@ -236,7 +236,7 @@ class GraphQLSegment { // Reverse edges because larger index were added first return { edgeIDs: edgeIDs.reverse(), - cursors: cursors.reverse() + cursors: cursors.reverse(), }; } @@ -258,9 +258,9 @@ class GraphQLSegment { index + ' to (' + this._minIndex + - ", " + + ', ' + this._maxIndex + - ")" + ')' ); return; @@ -600,7 +600,7 @@ class GraphQLSegment { this._cursorToIndexMap, this._minIndex, this._maxIndex, - this._count + this._count, ]; } @@ -611,7 +611,7 @@ class GraphQLSegment { cursorToIndexMap, minIndex, maxIndex, - count + count, ] = descriptor; var segment = new GraphQLSegment(); segment._indexToMetadataMap = indexToMetadataMap; @@ -627,7 +627,7 @@ class GraphQLSegment { return { metadata: this._indexToMetadataMap, idToIndices: this._idToIndicesMap, - cursorToIndex: this._cursorToIndexMap + cursorToIndex: this._cursorToIndexMap, }; } diff --git a/src/legacy/store/GraphQLStoreChangeEmitter.js b/src/legacy/store/GraphQLStoreChangeEmitter.js index c68e54dac453c..314c5864db479 100644 --- a/src/legacy/store/GraphQLStoreChangeEmitter.js +++ b/src/legacy/store/GraphQLStoreChangeEmitter.js @@ -59,7 +59,7 @@ var GraphQLStoreChangeEmitter = { return { remove: function() { delete subscribers[index]; - } + }, }; }, @@ -81,7 +81,7 @@ var GraphQLStoreChangeEmitter = { * Exposed for profiling reasons. * @private */ - _processSubscribers: processSubscribers + _processSubscribers: processSubscribers, }; diff --git a/src/legacy/store/GraphQLStoreDataHandler.js b/src/legacy/store/GraphQLStoreDataHandler.js index 8bd3be6afc8f3..c93d13cf91cbb 100644 --- a/src/legacy/store/GraphQLStoreDataHandler.js +++ b/src/legacy/store/GraphQLStoreDataHandler.js @@ -16,7 +16,7 @@ var METADATA_KEYS = { __dataID__: true, __range__: true, - __status__: true + __status__: true, }; /** @@ -54,7 +54,7 @@ var GraphQLStoreDataHandler = { */ isMetadataKey: function(key: string): boolean { return METADATA_KEYS[key] || false; - } + }, }; module.exports = GraphQLStoreDataHandler; diff --git a/src/legacy/store/GraphQLStoreQueryResolver.js b/src/legacy/store/GraphQLStoreQueryResolver.js index 11f5f986108b5..45cd2cf7f8236 100644 --- a/src/legacy/store/GraphQLStoreQueryResolver.js +++ b/src/legacy/store/GraphQLStoreQueryResolver.js @@ -24,7 +24,6 @@ import type RelayQuery from 'RelayQuery'; var RelayStoreData = require('RelayStoreData'); import type {StoreReaderData} from 'RelayTypes'; -var invariant = require('invariant'); var filterExclusiveKeys = require('filterExclusiveKeys'); var readRelayQueryData = require('readRelayQueryData'); var recycleNodesInto = require('recycleNodesInto'); @@ -282,7 +281,7 @@ function getCanonicalID(id: DataID): DataID { } RelayProfiler.instrumentMethods(GraphQLStoreQueryResolver.prototype, { - resolve: 'GraphQLStoreQueryResolver.resolve' + resolve: 'GraphQLStoreQueryResolver.resolve', }); module.exports = GraphQLStoreQueryResolver; diff --git a/src/legacy/store/GraphQLStoreRangeUtils.js b/src/legacy/store/GraphQLStoreRangeUtils.js index c5d582cccd8c4..307271c494520 100644 --- a/src/legacy/store/GraphQLStoreRangeUtils.js +++ b/src/legacy/store/GraphQLStoreRangeUtils.js @@ -67,7 +67,7 @@ var GraphQLStoreRangeUtils = { rangeData[key] = { dataID: dataID, calls: calls, - callValues: callValues + callValues: callValues, }; } return key; diff --git a/src/legacy/store/__mocks__/GraphQLQueryRunner.js b/src/legacy/store/__mocks__/GraphQLQueryRunner.js index 37618f744fbde..4ece8b4e9290a 100644 --- a/src/legacy/store/__mocks__/GraphQLQueryRunner.js +++ b/src/legacy/store/__mocks__/GraphQLQueryRunner.js @@ -56,7 +56,7 @@ GraphQLQueryRunner.run.mockImplementation((...args) => { var returnValue = { abort: jest.genMockFunction().mockImplementation(() => { resolveImmediate(request.abort); - }) + }), }; GraphQLQueryRunner.run.mock.abort.push(returnValue.abort); GraphQLQueryRunner.run.mock.requests.push(request); @@ -70,7 +70,7 @@ GraphQLQueryRunner.forceFetch.mockImplementation((...args) => { var returnValue = { abort: jest.genMockFunction().mockImplementation(() => { resolveImmediate(request.abort); - }) + }), }; GraphQLQueryRunner.forceFetch.mock.abort.push(returnValue.abort); GraphQLQueryRunner.forceFetch.mock.requests.push(request); diff --git a/src/legacy/store/__mocks__/GraphQLStoreQueryResolver.js b/src/legacy/store/__mocks__/GraphQLStoreQueryResolver.js index 8ef3c90007d4a..690735b7a64a1 100644 --- a/src/legacy/store/__mocks__/GraphQLStoreQueryResolver.js +++ b/src/legacy/store/__mocks__/GraphQLStoreQueryResolver.js @@ -42,7 +42,7 @@ class GraphQLStoreQueryResolver { GraphQLStoreQueryResolver.mock = { instances: [], resolveImplementations: [], - defaultResolveImplementation: () => undefined + defaultResolveImplementation: () => undefined, }; module.exports = GraphQLStoreQueryResolver; diff --git a/src/legacy/store/__mocks__/GraphQLStoreTestUtils.js b/src/legacy/store/__mocks__/GraphQLStoreTestUtils.js index 175e86bf4a2bb..34b2c6b3526aa 100644 --- a/src/legacy/store/__mocks__/GraphQLStoreTestUtils.js +++ b/src/legacy/store/__mocks__/GraphQLStoreTestUtils.js @@ -92,7 +92,7 @@ var GraphQLStoreTestUtils = { for (var ii = 0; ii < actualFragments.length; ii++) { var context = { - actual: actualFragments[ii] + actual: actualFragments[ii], }; var matches = GraphQLStoreTestUtils.matchers.toMatchQueryFragment.call( context, diff --git a/src/legacy/store/__mocks__/generateClientID.js b/src/legacy/store/__mocks__/generateClientID.js index 5c17925474517..412eea973d124 100644 --- a/src/legacy/store/__mocks__/generateClientID.js +++ b/src/legacy/store/__mocks__/generateClientID.js @@ -12,7 +12,7 @@ var count = 1; var generateClientID = jest.genMockFunction().mockImplementation( - () => { return 'client:' + count++;} + () => 'client:' + count++ ); module.exports = generateClientID; diff --git a/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js b/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js index 44046fcd61f03..212e3d5ab05b4 100644 --- a/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js +++ b/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js @@ -22,7 +22,6 @@ describe('GraphQLDeferredQueryTracker', () => { var RelayStoreData; var flattenSplitRelayQueries; - var getWeakIdForObject; var splitDeferredRelayQueries; var {defer, getNode} = RelayTestUtils; diff --git a/src/legacy/store/__tests__/GraphQLFragmentPointer-test.js b/src/legacy/store/__tests__/GraphQLFragmentPointer-test.js index 387ca3cc954b9..642e9952d735a 100644 --- a/src/legacy/store/__tests__/GraphQLFragmentPointer-test.js +++ b/src/legacy/store/__tests__/GraphQLFragmentPointer-test.js @@ -31,7 +31,7 @@ describe('GraphQLFragmentPointer', () => { jest.addMatchers({ toEqualPointer(expected) { return this.actual.equals(expected); - } + }, }); }); @@ -155,7 +155,7 @@ describe('GraphQLFragmentPointer', () => { }); it('throws when creating a singular pointer with multiple IDs', () => { - expect(() =>{ + expect(() => { new GraphQLFragmentPointer(['123'], singularFragment); }).toFailInvariant( 'GraphQLFragmentPointer: Wrong plurality, array of data IDs ' + @@ -164,7 +164,7 @@ describe('GraphQLFragmentPointer', () => { }); it('throws when creating a plural pointer with a single ID', () => { - expect(() =>{ + expect(() => { new GraphQLFragmentPointer('123', pluralFragment); }).toFailInvariant( 'GraphQLFragmentPointer: Wrong plurality, single data ID supplied ' + diff --git a/src/legacy/store/__tests__/GraphQLQueryRunner-test.js b/src/legacy/store/__tests__/GraphQLQueryRunner-test.js index 50708f24e4b70..66ac15ce3a5f4 100644 --- a/src/legacy/store/__tests__/GraphQLQueryRunner-test.js +++ b/src/legacy/store/__tests__/GraphQLQueryRunner-test.js @@ -92,7 +92,7 @@ describe('GraphQLQueryRunner', () => { mockQuerySet = { foo: getNode(Relay.QL`query{viewer{actor{id,name}}}`), bar: getNode(Relay.QL`query{node(id:"4"){id,name}}`), - baz: null + baz: null, }; jest.addMatchers(RelayTestUtils.matchers); @@ -456,7 +456,7 @@ describe('GraphQLQueryRunner', () => { ].map(query => ({ required: deferQuery(getNode(query)), deferred: [], - })) + })), }; splitDeferredRelayQueries.mockImplementation(query => { diff --git a/src/legacy/store/__tests__/GraphQLRange-test.js b/src/legacy/store/__tests__/GraphQLRange-test.js index 88aacc4ecf16f..e095237036475 100644 --- a/src/legacy/store/__tests__/GraphQLRange-test.js +++ b/src/legacy/store/__tests__/GraphQLRange-test.js @@ -33,7 +33,7 @@ function mockEdge(id, hasNullCursor) { var edge = { __dataID__: dataID, node: {__dataID__: 'id' + id}, - cursor: (hasNullCursor ? null : 'cursor' + id) + cursor: (hasNullCursor ? null : 'cursor' + id), }; return edge; } @@ -72,7 +72,6 @@ var last5Edges = [edge96, edge97, edge98, edge99, edge100]; describe('GraphQLRange', () => { var GraphQLRange; var GraphQLStoreDataHandler; - var GraphQL; var RelayConnectionInterface; var origConsoleError; @@ -108,11 +107,11 @@ describe('GraphQLRange', () => { it('should add for first() query', () => { var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -133,7 +132,7 @@ describe('GraphQLRange', () => { ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems( @@ -145,7 +144,7 @@ describe('GraphQLRange', () => { var incrementalEdges = [edge4, edge5]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; queryCalls = [ @@ -170,7 +169,7 @@ describe('GraphQLRange', () => { edge2.__dataID__, edge3.__dataID__, edge4.__dataID__, - edge5.__dataID__ + edge5.__dataID__, ]); expect(result.diffCalls.length).toBe(0); @@ -182,19 +181,19 @@ describe('GraphQLRange', () => { ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems(queryCalls, last3Edges, pageInfo); var incrementalQueryCall = [ {name: 'after', value: 'cursor100'}, - {name: 'first', value: '2'} + {name: 'first', value: '2'}, ]; var incrementalEdges = [edge101, edge102]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems( @@ -214,7 +213,7 @@ describe('GraphQLRange', () => { edge99.__dataID__, edge100.__dataID__, edge101.__dataID__, - edge102.__dataID__ + edge102.__dataID__, ]); expect(result.diffCalls.length).toBe(0); @@ -222,25 +221,25 @@ describe('GraphQLRange', () => { it('should add for before().first() query', () => { var queryCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, first3Edges, pageInfo); var incrementalQueryCall = [ {name: 'before', value: 'cursor1'}, - {name: 'first', value: '2'} + {name: 'first', value: '2'}, ]; var incrementalEdges = [edgeNeg1, edge0]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems( incrementalQueryCall, @@ -249,7 +248,7 @@ describe('GraphQLRange', () => { ); // Request the full set to make sure it is stitched properly queryCalls = [ - {name: 'last', value: '5'} + {name: 'last', value: '5'}, ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -258,7 +257,7 @@ describe('GraphQLRange', () => { edge0.__dataID__, edge1.__dataID__, edge2.__dataID__, - edge3.__dataID__ + edge3.__dataID__, ]); expect(result.diffCalls.length).toBe(0); @@ -266,25 +265,25 @@ describe('GraphQLRange', () => { it('should add for before().first() query with gap', () => { var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, first3Edges, pageInfo); var incrementalQueryCall = [ {name: 'before', value: 'cursor1'}, - {name: 'first', value: '2'} + {name: 'first', value: '2'}, ]; var incrementalEdges = [edgeNeg10, edgeNeg9]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems( incrementalQueryCall, @@ -293,7 +292,7 @@ describe('GraphQLRange', () => { ); // Request super set queryCalls = [ - {name: 'first', value: '5'} + {name: 'first', value: '5'}, ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -303,19 +302,19 @@ describe('GraphQLRange', () => { expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor-9'}, {name: 'before', value: 'cursor1'}, - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]); }); it('should add for last() query', () => { var queryCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems(queryCalls, last3Edges, pageInfo); @@ -331,26 +330,26 @@ describe('GraphQLRange', () => { it('should add for before().last() query', () => { var queryCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems(queryCalls, last3Edges, pageInfo); var incrementalQueryCall = [ {name: 'before', value: 'cursor98'}, - {name: 'last', value: '2'} + {name: 'last', value: '2'}, ]; var incrementalEdges = [edge96, edge97]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems( @@ -361,7 +360,7 @@ describe('GraphQLRange', () => { // Request the full set queryCalls = [ - {name: 'last', value: '5'} + {name: 'last', value: '5'}, ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -370,32 +369,32 @@ describe('GraphQLRange', () => { edge97.__dataID__, edge98.__dataID__, edge99.__dataID__, - edge100.__dataID__ + edge100.__dataID__, ]); expect(result.diffCalls.length).toBe(0); }); it('should add for before().last() query in first segment', () => { var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, first3Edges, pageInfo); var incrementalQueryCall = [ {name: 'before', value: 'cursor1'}, - {name: 'last', value: '2'} + {name: 'last', value: '2'}, ]; var incrementalEdges = [edgeNeg1, edge0]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems( @@ -406,7 +405,7 @@ describe('GraphQLRange', () => { // Request the full set queryCalls = [ - {name: 'first', value: '5'} + {name: 'first', value: '5'}, ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -415,31 +414,31 @@ describe('GraphQLRange', () => { edge0.__dataID__, edge1.__dataID__, edge2.__dataID__, - edge3.__dataID__ + edge3.__dataID__, ]); expect(result.diffCalls.length).toBe(0); }); it('should add for after().last() query', () => { var queryCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems(queryCalls, last3Edges, pageInfo); var incrementalQueryCall = [ {name: 'after', value: 'cursor100'}, - {name: 'last', value: '2'} + {name: 'last', value: '2'}, ]; var incrementalEdges = [edge101, edge102]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems( @@ -450,7 +449,7 @@ describe('GraphQLRange', () => { // Request the full set queryCalls = [ - {name: 'last', value: '5'} + {name: 'last', value: '5'}, ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -459,7 +458,7 @@ describe('GraphQLRange', () => { edge99.__dataID__, edge100.__dataID__, edge101.__dataID__, - edge102.__dataID__ + edge102.__dataID__, ]); expect(result.diffCalls.length).toBe(0); @@ -473,7 +472,7 @@ describe('GraphQLRange', () => { var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems(queryCalls, last3Edges, pageInfo); @@ -501,14 +500,14 @@ describe('GraphQLRange', () => { expect(result.diffCalls).toEqual([ {name: 'before', value: 'cursor110'}, {name: 'after', value: 'cursor100'}, - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]); }); it('should error for invalid call value', () => { console.error = jest.genMockFunction(); var queryCalls = [ - {name: 'first', value: '0'} + {name: 'first', value: '0'}, ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -516,7 +515,7 @@ describe('GraphQLRange', () => { expect(console.error.mock.calls.length).toBe(1); expect(console.error.mock.calls[0]).toEqual([ 'GraphQLRange only supports first() or last() ' + - 'where count is greater than 0' + 'where count is greater than 0', ]); expect(result.requestedEdgeIDs).toEqual([]); expect(result.diffCalls.length).toBe(0); @@ -524,7 +523,7 @@ describe('GraphQLRange', () => { it('should retrieve for first() queries', () => { var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; // Request from empty range @@ -537,7 +536,7 @@ describe('GraphQLRange', () => { var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -554,7 +553,7 @@ describe('GraphQLRange', () => { // Request a subset queryCalls = [ - {name: 'first', value: '2'} + {name: 'first', value: '2'}, ]; result = range.retrieveRangeInfoForQuery(queryCalls); @@ -567,7 +566,7 @@ describe('GraphQLRange', () => { // Request a superset queryCalls = [ - {name: 'first', value: '5'} + {name: 'first', value: '5'}, ]; result = range.retrieveRangeInfoForQuery(queryCalls); @@ -576,7 +575,7 @@ describe('GraphQLRange', () => { ); expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '2'} + {name: 'first', value: '2'}, ]); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(false); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(true); @@ -591,7 +590,7 @@ describe('GraphQLRange', () => { var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems( @@ -626,7 +625,7 @@ describe('GraphQLRange', () => { ); expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(false); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(true); @@ -641,7 +640,7 @@ describe('GraphQLRange', () => { expect(result.requestedEdgeIDs).toEqual([]); expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '2'} + {name: 'first', value: '2'}, ]); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(false); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(true); @@ -662,7 +661,7 @@ describe('GraphQLRange', () => { var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems(queryCalls, last3Edges, pageInfo); @@ -697,7 +696,7 @@ describe('GraphQLRange', () => { ); expect(result.diffCalls).toEqual([ {name: 'before', value: 'cursor98'}, - {name: 'last', value: '2'} + {name: 'last', value: '2'}, ]); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(true); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(false); @@ -705,12 +704,12 @@ describe('GraphQLRange', () => { it('should retrieve for before().last() queries', () => { var queryCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems(queryCalls, last3Edges, pageInfo); @@ -718,7 +717,7 @@ describe('GraphQLRange', () => { // Request a subset with before var result = range.retrieveRangeInfoForQuery([ {name: 'before', value: 'cursor100'}, - {name: 'last', value: '2'} + {name: 'last', value: '2'}, ]); expect(result.requestedEdgeIDs).toEqual( @@ -731,7 +730,7 @@ describe('GraphQLRange', () => { // Request a superset with before result = range.retrieveRangeInfoForQuery([ {name: 'before', value: 'cursor100'}, - {name: 'last', value: '5'} + {name: 'last', value: '5'}, ]); expect(result.requestedEdgeIDs).toEqual( @@ -739,7 +738,7 @@ describe('GraphQLRange', () => { ); expect(result.diffCalls).toEqual([ {name: 'before', value: 'cursor98'}, - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(true); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(false); @@ -747,13 +746,13 @@ describe('GraphQLRange', () => { // Request a non-intersecting superset with before result = range.retrieveRangeInfoForQuery([ {name: 'before', value: 'cursor98'}, - {name: 'last', value: '2'} + {name: 'last', value: '2'}, ]); expect(result.requestedEdgeIDs).toEqual([]); expect(result.diffCalls).toEqual([ {name: 'before', value: 'cursor98'}, - {name: 'last', value: '2'} + {name: 'last', value: '2'}, ]); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(true); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(false); @@ -762,19 +761,19 @@ describe('GraphQLRange', () => { it('should retrieve for after().first() from last segment', () => { var queryCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems(queryCalls, last3Edges, pageInfo); // Request a subset with after var result = range.retrieveRangeInfoForQuery([ {name: 'after', value: 'cursor98'}, - {name: 'first', value: '1'} + {name: 'first', value: '1'}, ]); expect(result.requestedEdgeIDs).toEqual([edge99.__dataID__]); @@ -785,7 +784,7 @@ describe('GraphQLRange', () => { // Request a superset with after result = range.retrieveRangeInfoForQuery([ {name: 'after', value: 'cursor98'}, - {name: 'first', value: '5'} + {name: 'first', value: '5'}, ]); expect(result.requestedEdgeIDs).toEqual( @@ -798,7 +797,7 @@ describe('GraphQLRange', () => { // Request a non-intersecting superset with after result = range.retrieveRangeInfoForQuery([ {name: 'after', value: 'cursor100'}, - {name: 'first', value: '2'} + {name: 'first', value: '2'}, ]); expect(result.requestedEdgeIDs).toEqual([]); @@ -810,12 +809,12 @@ describe('GraphQLRange', () => { it('should retrieve for before().last() from first segment', () => { var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -823,7 +822,7 @@ describe('GraphQLRange', () => { // Request a subset with before var result = range.retrieveRangeInfoForQuery([ {name: 'before', value: 'cursor3'}, - {name: 'last', value: '1'} + {name: 'last', value: '1'}, ]); expect(result.requestedEdgeIDs).toEqual([edge2.__dataID__]); @@ -834,7 +833,7 @@ describe('GraphQLRange', () => { // Request a superset with before result = range.retrieveRangeInfoForQuery([ {name: 'before', value: 'cursor3'}, - {name: 'last', value: '5'} + {name: 'last', value: '5'}, ]); expect(result.requestedEdgeIDs).toEqual( @@ -847,7 +846,7 @@ describe('GraphQLRange', () => { // Request a non-intersecting superset with before result = range.retrieveRangeInfoForQuery([ {name: 'before', value: 'cursor1'}, - {name: 'last', value: '2'} + {name: 'last', value: '2'}, ]); expect(result.requestedEdgeIDs).toEqual([]); @@ -865,7 +864,7 @@ describe('GraphQLRange', () => { var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -884,31 +883,31 @@ describe('GraphQLRange', () => { it('should support nodes with null cursors', () => { var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; var first3EdgesWithNullCursors = [ edgeWithNullCursor1, edgeWithNullCursor2, - edgeWithNullCursor3 + edgeWithNullCursor3, ]; range.addItems(queryCalls, first3EdgesWithNullCursors, pageInfo); // Request the full set var result = range.retrieveRangeInfoForQuery([ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]); expect(result.requestedEdgeIDs).toEqual([ 'edgeWithNullCursor1', 'edgeWithNullCursor2', - 'edgeWithNullCursor3' + 'edgeWithNullCursor3', ]); expect(result.diffCalls.length).toBe(0); }); @@ -917,7 +916,7 @@ describe('GraphQLRange', () => { // Prepend on new range range.prependEdge(edge2); var result = range.retrieveRangeInfoForQuery([ - {name: 'first', value: '1'} + {name: 'first', value: '1'}, ]); expect(result.requestedEdgeIDs).toEqual([edge2.__dataID__]); expect(result.diffCalls.length).toBe(0); @@ -925,7 +924,7 @@ describe('GraphQLRange', () => { // Prepend on range that already has edge range.prependEdge(edge1); result = range.retrieveRangeInfoForQuery([ - {name: 'first', value: '2'} + {name: 'first', value: '2'}, ]); expect(result.requestedEdgeIDs).toEqual( [edge1.__dataID__, edge2.__dataID__] @@ -937,7 +936,7 @@ describe('GraphQLRange', () => { // Append on new range range.appendEdge(edge1); var result = range.retrieveRangeInfoForQuery([ - {name: 'last', value: '1'} + {name: 'last', value: '1'}, ]); expect(result.requestedEdgeIDs).toEqual([edge1.__dataID__]); expect(result.diffCalls.length).toBe(0); @@ -945,7 +944,7 @@ describe('GraphQLRange', () => { // Append on range that already has an edge range.appendEdge(edge2); result = range.retrieveRangeInfoForQuery([ - {name: 'last', value: '2'} + {name: 'last', value: '2'}, ]); expect(result.requestedEdgeIDs).toEqual( [edge1.__dataID__, edge2.__dataID__] @@ -955,19 +954,19 @@ describe('GraphQLRange', () => { it('should support bumping', () => { var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, first3Edges, pageInfo); var afterQueryCalls = [ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '1'} + {name: 'first', value: '1'}, ]; // Testing add after: adding id2 to end of range @@ -987,19 +986,19 @@ describe('GraphQLRange', () => { expect(result.diffCalls.length).toBe(0); queryCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems(queryCalls, last3Edges, pageInfo); var beforeQueryCalls = [ {name: 'before', value: 'cursor98'}, - {name: 'last', value: '1'} + {name: 'last', value: '1'}, ]; // Testing add before: adding id99 to end of range @@ -1021,16 +1020,16 @@ describe('GraphQLRange', () => { it('should not generate diff query when range is empty', () => { var queryFirstCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var queryLastCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; // Add empty first edges @@ -1053,16 +1052,16 @@ describe('GraphQLRange', () => { it('should collesce segments when we reach end', () => { var queryFirstCalls = [ - {name: 'first', value: '1'} + {name: 'first', value: '1'}, ]; var queryLastCalls = [ - {name: 'last', value: '1'} + {name: 'last', value: '1'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryFirstCalls, [edge1], pageInfo); @@ -1078,16 +1077,16 @@ describe('GraphQLRange', () => { it('should not generate diff query when there is no more', () => { var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; var beforeQueryCalls = [ {name: 'before', value: 'cursor1'}, - {name: 'last', value: '1'} + {name: 'last', value: '1'}, ]; range.addItems(queryCalls, first3Edges, pageInfo); @@ -1096,16 +1095,16 @@ describe('GraphQLRange', () => { expect(result.diffCalls.length).toBe(0); queryCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; var afterQueryCalls = [ {name: 'after', value: 'cursor100'}, - {name: 'first', value: '1'} + {name: 'first', value: '1'}, ]; range.addItems(queryCalls, last3Edges, pageInfo); @@ -1121,7 +1120,7 @@ describe('GraphQLRange', () => { var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -1140,13 +1139,13 @@ describe('GraphQLRange', () => { var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(surroundQueryCalls, first3Edges, pageInfo); var firstQueryCalls = [ - {name: 'first', value: '5'} + {name: 'first', value: '5'}, ]; var resultForFirstQuery = range.retrieveRangeInfoForQuery( @@ -1161,12 +1160,12 @@ describe('GraphQLRange', () => { console.error = jest.genMockFunction(); var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, [edge1, edge2, edge3], pageInfo); @@ -1176,7 +1175,7 @@ describe('GraphQLRange', () => { expect([ 'Relay was unable to reconcile edges on a connection. This most ' + 'likely occurred while trying to handle a server response that ' + - 'includes connection edges with nodes that lack an `id` field.' + 'includes connection edges with nodes that lack an `id` field.', ]).toBeWarnedNTimes(1); var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -1189,12 +1188,12 @@ describe('GraphQLRange', () => { console.error = jest.genMockFunction(); var queryCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; // Add items twice @@ -1205,7 +1204,7 @@ describe('GraphQLRange', () => { expect([ 'Relay was unable to reconcile edges on a connection. This most ' + 'likely occurred while trying to handle a server response that ' + - 'includes connection edges with nodes that lack an `id` field.' + 'includes connection edges with nodes that lack an `id` field.', ]).toBeWarnedNTimes(1); var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -1219,12 +1218,12 @@ describe('GraphQLRange', () => { console.warn = jest.genMockFunction(); var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; // Add items twice @@ -1240,12 +1239,12 @@ describe('GraphQLRange', () => { ); queryCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; // Add items twice @@ -1266,18 +1265,18 @@ describe('GraphQLRange', () => { console.warn = jest.genMockFunction(); var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, first3Edges, pageInfo); queryCalls = [ - {name: 'first', value: '5'} + {name: 'first', value: '5'}, ]; range.addItems(queryCalls, first5Edges, pageInfo); @@ -1290,22 +1289,22 @@ describe('GraphQLRange', () => { edge2.__dataID__, edge3.__dataID__, edge4.__dataID__, - edge5.__dataID__ + edge5.__dataID__, ]); queryCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems(queryCalls, last3Edges, pageInfo); queryCalls = [ - {name: 'last', value: '5'} + {name: 'last', value: '5'}, ]; range.addItems(queryCalls, last5Edges, pageInfo); @@ -1318,21 +1317,21 @@ describe('GraphQLRange', () => { edge97.__dataID__, edge98.__dataID__, edge99.__dataID__, - edge100.__dataID__ + edge100.__dataID__, ]); }); it('should stitch first and last segment', () => { var firstQueryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var lastQueryCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(firstQueryCalls, first3Edges, pageInfo); @@ -1340,12 +1339,12 @@ describe('GraphQLRange', () => { expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor3'}, - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]); pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(result.diffCalls, last3Edges, pageInfo); result = range.retrieveRangeInfoForQuery( @@ -1358,7 +1357,7 @@ describe('GraphQLRange', () => { edge3.__dataID__, edge98.__dataID__, edge99.__dataID__, - edge100.__dataID__ + edge100.__dataID__, ]); result = range.retrieveRangeInfoForQuery( [{name: 'last', value: '6'}], @@ -1370,14 +1369,14 @@ describe('GraphQLRange', () => { edge3.__dataID__, edge98.__dataID__, edge99.__dataID__, - edge100.__dataID__ + edge100.__dataID__, ]); range = new GraphQLRange(); pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems(lastQueryCalls, last3Edges, pageInfo); @@ -1385,12 +1384,12 @@ describe('GraphQLRange', () => { expect(result.diffCalls).toEqual([ {name: 'before', value: 'cursor98'}, - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]); pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(result.diffCalls, first3Edges, pageInfo); @@ -1404,7 +1403,7 @@ describe('GraphQLRange', () => { edge3.__dataID__, edge98.__dataID__, edge99.__dataID__, - edge100.__dataID__ + edge100.__dataID__, ]); result = range.retrieveRangeInfoForQuery( [{name: 'last', value: '6'}], @@ -1416,19 +1415,19 @@ describe('GraphQLRange', () => { edge3.__dataID__, edge98.__dataID__, edge99.__dataID__, - edge100.__dataID__ + edge100.__dataID__, ]); }); it('should stitch up gap in first segment', () => { // Add initial edges var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -1438,12 +1437,12 @@ describe('GraphQLRange', () => { // Create gap var incrementalQueryCall = [ {name: 'before', value: 'cursor1'}, - {name: 'first', value: '2'} + {name: 'first', value: '2'}, ]; var incrementalEdges = [edgeNeg3, edgeNeg2]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems( incrementalQueryCall, @@ -1452,32 +1451,32 @@ describe('GraphQLRange', () => { ); result = range.retrieveRangeInfoForQuery([ - {name: 'first', value: '5'} + {name: 'first', value: '5'}, ]); var diffCalls = result.diffCalls; expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor-2'}, {name: 'before', value: 'cursor1'}, - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]); // Fill in gap var gapEdges = [edgeNeg1, edge0]; pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(diffCalls, gapEdges, pageInfo); result = range.retrieveRangeInfoForQuery([ - {name: 'first', value: '5'} + {name: 'first', value: '5'}, ]); expect(result.requestedEdgeIDs).toEqual([ edgeNeg3.__dataID__, edgeNeg2.__dataID__, edgeNeg1.__dataID__, edge0.__dataID__, - edge1.__dataID__ + edge1.__dataID__, ]); expect(result.diffCalls.length).toBe(0); }); @@ -1485,11 +1484,11 @@ describe('GraphQLRange', () => { it('should stitch up gap in last segment', () => { // Add initial edges var queryCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems(queryCalls, last3Edges, pageInfo); @@ -1498,13 +1497,13 @@ describe('GraphQLRange', () => { // Create gap var incrementalQueryCall = [ {name: 'after', value: 'cursor100'}, - {name: 'last', value: '2'} + {name: 'last', value: '2'}, ]; var incrementalEdges = [edge103, edge104]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems( incrementalQueryCall, @@ -1513,44 +1512,44 @@ describe('GraphQLRange', () => { ); result = range.retrieveRangeInfoForQuery([ - {name: 'last', value: '5'} + {name: 'last', value: '5'}, ]); var diffCalls = result.diffCalls; expect(result.diffCalls).toEqual([ {name: 'before', value: 'cursor103'}, {name: 'after', value: 'cursor100'}, - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]); // Fill in gap var gapEdges = [edge101, edge102]; pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(diffCalls, gapEdges, pageInfo); result = range.retrieveRangeInfoForQuery([ - {name: 'last', value: '5'} + {name: 'last', value: '5'}, ]); expect(result.requestedEdgeIDs).toEqual([ edge100.__dataID__, edge101.__dataID__, edge102.__dataID__, edge103.__dataID__, - edge104.__dataID__ + edge104.__dataID__, ]); expect(result.diffCalls.length).toBe(0); }); it('should refetch for whole ranges for null cursor', () => { var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; var nullCursorEdges = [ @@ -1572,7 +1571,7 @@ describe('GraphQLRange', () => { it('replaces whole first() ranges when working with null cursors', () => { var queryCalls = [ - {name: 'first', value: '1'} + {name: 'first', value: '1'}, ]; var pageInfo = { @@ -1617,7 +1616,7 @@ describe('GraphQLRange', () => { it('replaces whole last() ranges when working with null cursors', () => { var queryCalls = [ - {name: 'last', value: '1'} + {name: 'last', value: '1'}, ]; var pageInfo = { @@ -1666,7 +1665,7 @@ describe('GraphQLRange', () => { var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; var nullCursorEdges = [ @@ -1696,12 +1695,12 @@ describe('GraphQLRange', () => { it('should delete', () => { var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -1712,18 +1711,18 @@ describe('GraphQLRange', () => { ); expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '1'} + {name: 'first', value: '1'}, ]); }); it('should not retrieve deleted bumped edges', () => { var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -1732,7 +1731,7 @@ describe('GraphQLRange', () => { // bump the second edge var afterQueryCalls = [ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '1'} + {name: 'first', value: '1'}, ]; range.addItems(afterQueryCalls, [first3Edges[1]], pageInfo); @@ -1745,10 +1744,10 @@ describe('GraphQLRange', () => { ); expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '1'} + {name: 'first', value: '1'}, ]); var queryCallsWithSession = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; result = range.retrieveRangeInfoForQuery(queryCallsWithSession); expect(result.requestedEdgeIDs).toEqual( @@ -1756,18 +1755,18 @@ describe('GraphQLRange', () => { ); expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '1'} + {name: 'first', value: '1'}, ]); }); it('should retrieve info for first() query given optimistic data', () => { var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -1806,7 +1805,7 @@ describe('GraphQLRange', () => { result = range.retrieveRangeInfoForQuery( [{name: 'first', value: '2'}], { - 'remove': [edge1.__dataID__] + 'remove': [edge1.__dataID__], } ); @@ -1819,7 +1818,7 @@ describe('GraphQLRange', () => { [{name: 'first', value: '3'}], { 'prepend': [edge4.__dataID__, edge5.__dataID__], - 'remove': [edge4.__dataID__, edge1.__dataID__] + 'remove': [edge4.__dataID__, edge1.__dataID__], } ); @@ -1831,12 +1830,12 @@ describe('GraphQLRange', () => { it('should retrieve info for last() query given optimistic data', () => { var queryCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; range.addItems(queryCalls, last3Edges, pageInfo); @@ -1886,7 +1885,7 @@ describe('GraphQLRange', () => { [{name: 'last', value: '3'}], { 'append': [edge97.__dataID__, edge96.__dataID__], - 'remove': [edge100.__dataID__, edge96.__dataID__] + 'remove': [edge100.__dataID__, edge96.__dataID__], } ); @@ -1898,11 +1897,11 @@ describe('GraphQLRange', () => { it('should toJSON', () => { var queryCalls = [ - {name: 'first', value: '3'} + {name: 'first', value: '3'}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -1935,13 +1934,13 @@ describe('GraphQLRange', () => { ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; range.addItems(surroundQueryCalls, first3Edges, pageInfo); // Non-static edges var queryCalls = [ - {name: 'last', value: '3'} + {name: 'last', value: '3'}, ]; range.addItems(queryCalls, last3Edges, pageInfo); // Sorting the IDs to make testing easier. diff --git a/src/legacy/store/__tests__/GraphQLSegment-test.js b/src/legacy/store/__tests__/GraphQLSegment-test.js index 81a09069dbb3c..ada4461f8ca4d 100644 --- a/src/legacy/store/__tests__/GraphQLSegment-test.js +++ b/src/legacy/store/__tests__/GraphQLSegment-test.js @@ -24,76 +24,76 @@ var edges = [ { __dataID__:'edge1', node: {__dataID__: 'id1'}, - cursor: 'cursor1' + cursor: 'cursor1', }, { __dataID__:'edge2', node: {__dataID__: 'id2'}, - cursor: 'cursor2' + cursor: 'cursor2', }, { __dataID__:'edge3', node: {__dataID__: 'id3'}, - cursor: 'cursor3' - } + cursor: 'cursor3', + }, ]; var moreEdges = [ { __dataID__:'edge4', node: {__dataID__: 'id4'}, - cursor: 'cursor4' + cursor: 'cursor4', }, { __dataID__:'edge5', node: {__dataID__: 'id5'}, - cursor: 'cursor5' + cursor: 'cursor5', }, { __dataID__:'edge6', node: {__dataID__: 'id6'}, - cursor: 'cursor6' - } + cursor: 'cursor6', + }, ]; var lastEdges = [ { __dataID__:'edge98', node: {__dataID__: 'id98'}, - cursor: 'cursor98' + cursor: 'cursor98', }, { __dataID__:'edge99', node: {__dataID__: 'id99'}, - cursor: 'cursor99' + cursor: 'cursor99', }, { __dataID__:'edge100', node: {__dataID__: 'id100'}, - cursor: 'cursor100' - } + cursor: 'cursor100', + }, ]; var beforeLastEdges = [ { __dataID__:'edge95', node: {__dataID__: 'id95'}, - cursor: 'cursor95' + cursor: 'cursor95', }, { __dataID__:'edge96', node: {__dataID__: 'id96'}, - cursor: 'cursor96' + cursor: 'cursor96', }, { __dataID__:'edge97', node: {__dataID__: 'id97'}, - cursor: 'cursor97' - } + cursor: 'cursor97', + }, ]; var oneEdge = { __dataID__:'edgeOneEdge', node: {__dataID__: 'idOneEdge'}, - cursor: 'cursorOneEdge' + cursor: 'cursorOneEdge', }; var anotherEdge = { __dataID__:'edgeAnotherEdge', node: {__dataID__: 'idAnotherEdge'}, - cursor: 'cursorAnotherEdge' + cursor: 'cursorAnotherEdge', }; /** @@ -270,7 +270,7 @@ describe('GraphQLSegment', () => { it('rolls back bumped edges from failed concatSegment operations', () => { console.error = jest.genMockFunction(); segment.addEdgesAfterCursor(edges.slice(0, 2), null); - expect(segment.__debug().idToIndices['edge2'].length).toBe(1); + expect(segment.__debug().idToIndices.edge2.length).toBe(1); var otherSegment = new GraphQLSegment(); var edge2 = edges.slice(1, 2); @@ -286,7 +286,7 @@ describe('GraphQLSegment', () => { 'edge2' ); // Make sure it rolled back the deleted edge from indices map - expect(segment.__debug().idToIndices['edge2'].length).toBe(1); + expect(segment.__debug().idToIndices.edge2.length).toBe(1); }); it('should check for valid id in segment', () => { @@ -421,16 +421,16 @@ describe('GraphQLSegment', () => { { __dataID__: 'edge3', node: {__dataID__: 'id3'}, - cursor: 'cursor3' + cursor: 'cursor3', }, { __dataID__: 'edge4', node: {__dataID__: 'id4'}, - cursor: 'cursor4' + cursor: 'cursor4', }, { __dataID__: 'edge5', node: {__dataID__: 'id5'}, - cursor: 'cursor5' - } + cursor: 'cursor5', + }, ]; // deleted edge in the original segment diff --git a/src/legacy/store/__tests__/GraphQLStoreQueryResolver-test.js b/src/legacy/store/__tests__/GraphQLStoreQueryResolver-test.js index accc8e52fc535..61c1fc43a2429 100644 --- a/src/legacy/store/__tests__/GraphQLStoreQueryResolver-test.js +++ b/src/legacy/store/__tests__/GraphQLStoreQueryResolver-test.js @@ -135,7 +135,7 @@ describe('GraphQLStoreQueryResolver', () => { ); mockReader({ - [mockResultA.id]: mockResultA + [mockResultA.id]: mockResultA, }); var resolvedA = resolver.resolve(fragmentPointer); @@ -143,7 +143,7 @@ describe('GraphQLStoreQueryResolver', () => { callback(['1038750002']); mockReader({ - [mockResultB.id]: mockResultB + [mockResultB.id]: mockResultB, }); var resolvedB = resolver.resolve(fragmentPointer); @@ -182,7 +182,7 @@ describe('GraphQLStoreQueryResolver', () => { ); var mockResults = { '1': {__dataID__: '1', name: 'One'}, - '2': {__dataID__: '2', name: 'Two'} + '2': {__dataID__: '2', name: 'Two'}, }; mockReader(mockResults); @@ -211,7 +211,7 @@ describe('GraphQLStoreQueryResolver', () => { ); var mockResults = { '1': {__dataID__: '1', name: 'One'}, - '2': {__dataID__: '2', name: 'Two'} + '2': {__dataID__: '2', name: 'Two'}, }; mockReader(mockResults); @@ -233,7 +233,7 @@ describe('GraphQLStoreQueryResolver', () => { ); var mockResults = { '1': {__dataID__: '1', name: 'One'}, - '2': {__dataID__: '2', name: 'Two'} + '2': {__dataID__: '2', name: 'Two'}, }; mockReader(mockResults); @@ -271,7 +271,7 @@ describe('GraphQLStoreQueryResolver', () => { ); var mockResults = { '1': {__dataID__: '1', name: 'One'}, - '2': {__dataID__: '2', name: 'Two'} + '2': {__dataID__: '2', name: 'Two'}, }; mockReader(mockResults); @@ -366,7 +366,8 @@ describe('GraphQLStoreQueryResolver', () => { GraphQLStoreChangeEmitter.addListenerForIDs.mock.calls[0][1]; // On first resolve we get data for all added ids expect(getIncreaseSubscriptionsParameters(2)).toEqual([ - 'address', 'chris' + 'address', + 'chris', ]); // New mock data for the resolve diff --git a/src/legacy/store/generateClientEdgeID.js b/src/legacy/store/generateClientEdgeID.js index ed2fc193cc981..6702fb7acf812 100644 --- a/src/legacy/store/generateClientEdgeID.js +++ b/src/legacy/store/generateClientEdgeID.js @@ -20,7 +20,7 @@ * @internal */ function generateClientEdgeID(rangeID: string, nodeID: string): string { - return 'client:' + rangeID + ':' + nodeID; + return 'client:' + rangeID + ':' + nodeID; } module.exports = generateClientEdgeID; diff --git a/src/mutation/RelayMutation.js b/src/mutation/RelayMutation.js index 3de77514cb55f..5c7ffc7cc5679 100644 --- a/src/mutation/RelayMutation.js +++ b/src/mutation/RelayMutation.js @@ -14,7 +14,6 @@ 'use strict'; import type GraphQL from 'GraphQL_EXPERIMENTAL'; -import type GraphQLFragmentPointer from 'GraphQLFragmentPointer'; var RelayDeprecated = require('RelayDeprecated'); var RelayFragmentReference = require('RelayFragmentReference'); import type RelayMetaRoute from 'RelayMetaRoute'; diff --git a/src/mutation/RelayMutationQuery.js b/src/mutation/RelayMutationQuery.js index 437fca83ec6d4..fe732ba51f4f1 100644 --- a/src/mutation/RelayMutationQuery.js +++ b/src/mutation/RelayMutationQuery.js @@ -11,6 +11,8 @@ * @flow */ +/* eslint comma-dangle: 1 */ + 'use strict'; import type GraphQL from 'GraphQL_EXPERIMENTAL'; @@ -310,7 +312,7 @@ var RelayMutationQuery = { null, null, {'requisite':true} - ) + ), ]; configs.forEach(config => { @@ -367,7 +369,7 @@ var RelayMutationQuery = { children, mutation.metadata ))); - } + }, }; function getFieldFromFatQuery( diff --git a/src/mutation/RelayMutationTransaction.js b/src/mutation/RelayMutationTransaction.js index 1a830c25002ab..f29e9d7fc088a 100644 --- a/src/mutation/RelayMutationTransaction.js +++ b/src/mutation/RelayMutationTransaction.js @@ -328,7 +328,9 @@ class RelayMutationTransaction { var shouldRollback = true; var commitFailureCallback = this._onCommitFailureCallback; if (commitFailureCallback) { - var preventAutoRollback = function() { shouldRollback = false; }; + var preventAutoRollback = function() { + shouldRollback = false; + }; ErrorUtils.applyWithGuard( commitFailureCallback, null, diff --git a/src/mutation/__tests__/RelayMutation-test.js b/src/mutation/__tests__/RelayMutation-test.js index 409df1bfc5a24..25633f71a30da 100644 --- a/src/mutation/__tests__/RelayMutation-test.js +++ b/src/mutation/__tests__/RelayMutation-test.js @@ -21,7 +21,6 @@ jest describe('RelayMutation', function() { var MockMutation; var Relay; - var RelayQuery; var buildRQL; var fromGraphQL; diff --git a/src/mutation/__tests__/RelayMutationQuery-test.js b/src/mutation/__tests__/RelayMutationQuery-test.js index 2bb0198d707fc..f61113d468f62 100644 --- a/src/mutation/__tests__/RelayMutationQuery-test.js +++ b/src/mutation/__tests__/RelayMutationQuery-test.js @@ -76,8 +76,8 @@ describe('RelayMutationQuery', () => { fatQuery, tracker, fieldIDs: { - unsubscribee: '4' - } + unsubscribee: '4', + }, }); }).toFailInvariant( 'RelayMutationQuery: Invalid field name on fat query, `unsubscribee`.' @@ -103,8 +103,8 @@ describe('RelayMutationQuery', () => { fatQuery, tracker, fieldIDs: { - feedback: '123' - } + feedback: '123', + }, }); var expected = getNodeWithoutSource(Relay.QL` fragment on FeedbackLikeResponsePayload { @@ -116,7 +116,7 @@ describe('RelayMutationQuery', () => { expect(flattenRelayQuery(node)) .toEqualQueryNode(flattenRelayQuery(expected)); expect(tracker.getTrackedChildrenForID.mock.calls).toEqual([ - ['123'] + ['123'], ]); }); @@ -140,8 +140,8 @@ describe('RelayMutationQuery', () => { fatQuery, tracker, fieldIDs: { - stories: ['123'] - } + stories: ['123'], + }, }); var expected = getNodeWithoutSource(Relay.QL` fragment on ViewerNotificationsUpdateAllSeenStateResponsePayload { @@ -153,7 +153,7 @@ describe('RelayMutationQuery', () => { expect(flattenRelayQuery(node)) .toEqualQueryNode(flattenRelayQuery(expected)); expect(tracker.getTrackedChildrenForID.mock.calls).toEqual([ - ['123'] + ['123'], ]); }); @@ -189,8 +189,8 @@ describe('RelayMutationQuery', () => { fatQuery, tracker, fieldIDs: { - stories: ['123', '456'] - } + stories: ['123', '456'], + }, }); var node = intersectRelayQuery.mock.calls[0][0]; var expected = getNodeWithoutSource(Relay.QL` @@ -209,7 +209,7 @@ describe('RelayMutationQuery', () => { .toEqualQueryNode(flattenRelayQuery(expected)); expect(tracker.getTrackedChildrenForID.mock.calls).toEqual([ ['123'], - ['456'] + ['456'], ]); }); }); @@ -276,13 +276,12 @@ describe('RelayMutationQuery', () => { expect(flattenRelayQuery(node)) .toEqualQueryNode(flattenRelayQuery(expected)); expect(tracker.getTrackedChildrenForID.mock.calls).toEqual([ - ['123'] + ['123'], ]); }); }); describe('edge insertion', () => { - var GraphQLMutatorConstants; var fatQuery, rangeBehaviors; beforeEach(() => { @@ -328,7 +327,7 @@ describe('RelayMutationQuery', () => { connectionName: 'comments', parentID: '123', edgeName: 'feedbackCommentEdge', - rangeBehaviors + rangeBehaviors, }); var expected = getNodeWithoutSource(Relay.QL` fragment on CommentCreateResponsePayload { @@ -349,7 +348,7 @@ describe('RelayMutationQuery', () => { expect(flattenRelayQuery(node)) .toEqualQueryNode(flattenRelayQuery(expected)); expect(tracker.getTrackedChildrenForID.mock.calls).toEqual([ - ['123'] + ['123'], ]); }); @@ -383,7 +382,7 @@ describe('RelayMutationQuery', () => { connectionName: 'comments', parentID: '123', edgeName: 'feedbackCommentEdge', - rangeBehaviors + rangeBehaviors, }); var expected = getNodeWithoutSource(Relay.QL` fragment on CommentCreateResponsePayload { @@ -438,7 +437,7 @@ describe('RelayMutationQuery', () => { connectionName: 'comments', parentID: '123', edgeName: 'feedbackCommentEdge', - rangeBehaviors + rangeBehaviors, }); var expected = getNodeWithoutSource(Relay.QL` fragment on CommentCreateResponsePayload { @@ -481,7 +480,7 @@ describe('RelayMutationQuery', () => { parentID: '123', edgeName: 'feedbackCommentEdge', parentName: 'feedback', - rangeBehaviors + rangeBehaviors, }); var expected = getNodeWithoutSource(Relay.QL` fragment on CommentCreateResponsePayload { @@ -517,7 +516,7 @@ describe('RelayMutationQuery', () => { parentID: '123', edgeName: 'feedbackCommentEdge', parentName: 'feedback', - rangeBehaviors + rangeBehaviors, }); var expected = getNodeWithoutSource(Relay.QL` fragment on CommentCreateResponsePayload { @@ -548,7 +547,7 @@ describe('RelayMutationQuery', () => { parentID: '123', edgeName: 'feedbackCommentEdge', parentName: 'story', - rangeBehaviors + rangeBehaviors, }); }).toFailInvariant( 'RelayMutationQuery: Invalid field name on fat query, `story`.' @@ -576,7 +575,7 @@ describe('RelayMutationQuery', () => { var mockData = {}; RelayMutationQuery.buildFragmentForOptimisticUpdate({ response: mockData, - fatQuery + fatQuery, }); expect(inferRelayFieldsFromData.mock.calls.length).toBe(1); @@ -601,7 +600,7 @@ describe('RelayMutationQuery', () => { doesViewerLike: true, id: '1', likers: { - count: 4 + count: 4, }, }, }, @@ -944,7 +943,7 @@ describe('RelayMutationQuery', () => { }, } `], - } + }, ]; var mutation = Relay.QL`mutation{commentCreate(input:$input)}`; @@ -1035,7 +1034,7 @@ describe('RelayMutationQuery', () => { parentID, connectionName, edgeName, - rangeBehaviors + rangeBehaviors, }, { type: RelayMutationType.FIELDS_CHANGE, diff --git a/src/mutation/__tests__/RelayMutationTransaction-test.js b/src/mutation/__tests__/RelayMutationTransaction-test.js index 331b3fa3aaafc..9d31e743e9955 100644 --- a/src/mutation/__tests__/RelayMutationTransaction-test.js +++ b/src/mutation/__tests__/RelayMutationTransaction-test.js @@ -300,93 +300,94 @@ describe('RelayMutationTransaction', () => { it('auto-rollbacks colliding queued transactions upon failure, unless ' + 'prevented', () => { - var failureCallback1 = jest.genMockFunction().mockImplementation( - (transaction, preventAutoRollback) => { - expect(transaction).toBe(transaction1); - expect(transaction.getStatus()).toBe( - RelayMutationTransactionStatus.COMMIT_FAILED - ); - preventAutoRollback(); - } - ); - var transaction1 = new RelayMutationTransaction(mockMutation1); - transaction1.commit({onFailure: failureCallback1}); - - var failureCallback2 = jest.genMockFunction().mockImplementation( - (transaction, preventAutoRollback) => { - expect(transaction).toBe(transaction2); - expect(transaction.getStatus()).toBe( - RelayMutationTransactionStatus.COLLISION_COMMIT_FAILED - ); - } - ); - var transaction2 = new RelayMutationTransaction(mockMutation1); - transaction2.commit({onFailure: failureCallback2}); - - var failureCallback3 = jest.genMockFunction().mockImplementation( - (transaction, preventAutoRollback) => { - expect(transaction).toBe(transaction3); - expect(transaction.getStatus()).toBe( - RelayMutationTransactionStatus.COLLISION_COMMIT_FAILED - ); - preventAutoRollback(); - } - ); - var transaction3 = new RelayMutationTransaction(mockMutation1); - transaction3.commit({onFailure: failureCallback3}); - - expect(transaction1.getStatus()).toBe( - RelayMutationTransactionStatus.COMMITTING - ); - expect(transaction2.getStatus()).toBe( - RelayMutationTransactionStatus.COMMIT_QUEUED - ); - expect(transaction3.getStatus()).toBe( - RelayMutationTransactionStatus.COMMIT_QUEUED - ); - - var failureCallback4 = jest.genMockFunction().mockImplementation(); - var transaction4 = new RelayMutationTransaction(mockMutation2); - transaction4.commit({onFailure: failureCallback4}); - - var failureCallback5 = jest.genMockFunction().mockImplementation(); - var transaction5 = new RelayMutationTransaction(mockMutation2); - transaction5.commit({onFailure: failureCallback5}); - - expect(transaction4.getStatus()).toBe( - RelayMutationTransactionStatus.COMMITTING - ); - expect(transaction5.getStatus()).toBe( - RelayMutationTransactionStatus.COMMIT_QUEUED - ); - expect(RelayNetworkLayer.sendMutation.mock.calls.length).toBe(2); - - var request = RelayNetworkLayer.sendMutation.mock.calls[0][0]; - request.reject(new Error('error')); - jest.runAllTimers(); - - expect(failureCallback1).toBeCalled(); - expect(failureCallback2).toBeCalled(); - expect(failureCallback3).toBeCalled(); - expect(failureCallback4).not.toBeCalled(); - expect(failureCallback5).not.toBeCalled(); - expect(transaction1.getStatus()).toBe( - RelayMutationTransactionStatus.COMMIT_FAILED - ); - expect(() => transaction2.getStatus()).toThrow( - 'Invariant Violation: RelayMutationTransaction: Only pending ' + - 'transactions can be interacted with.' - ); - expect(transaction3.getStatus()).toBe( - RelayMutationTransactionStatus.COLLISION_COMMIT_FAILED - ); - expect(transaction4.getStatus()).toBe( - RelayMutationTransactionStatus.COMMITTING - ); - expect(transaction5.getStatus()).toBe( - RelayMutationTransactionStatus.COMMIT_QUEUED - ); - }); + var failureCallback1 = jest.genMockFunction().mockImplementation( + (transaction, preventAutoRollback) => { + expect(transaction).toBe(transaction1); + expect(transaction.getStatus()).toBe( + RelayMutationTransactionStatus.COMMIT_FAILED + ); + preventAutoRollback(); + } + ); + var transaction1 = new RelayMutationTransaction(mockMutation1); + transaction1.commit({onFailure: failureCallback1}); + + var failureCallback2 = jest.genMockFunction().mockImplementation( + (transaction, preventAutoRollback) => { + expect(transaction).toBe(transaction2); + expect(transaction.getStatus()).toBe( + RelayMutationTransactionStatus.COLLISION_COMMIT_FAILED + ); + } + ); + var transaction2 = new RelayMutationTransaction(mockMutation1); + transaction2.commit({onFailure: failureCallback2}); + + var failureCallback3 = jest.genMockFunction().mockImplementation( + (transaction, preventAutoRollback) => { + expect(transaction).toBe(transaction3); + expect(transaction.getStatus()).toBe( + RelayMutationTransactionStatus.COLLISION_COMMIT_FAILED + ); + preventAutoRollback(); + } + ); + var transaction3 = new RelayMutationTransaction(mockMutation1); + transaction3.commit({onFailure: failureCallback3}); + + expect(transaction1.getStatus()).toBe( + RelayMutationTransactionStatus.COMMITTING + ); + expect(transaction2.getStatus()).toBe( + RelayMutationTransactionStatus.COMMIT_QUEUED + ); + expect(transaction3.getStatus()).toBe( + RelayMutationTransactionStatus.COMMIT_QUEUED + ); + + var failureCallback4 = jest.genMockFunction().mockImplementation(); + var transaction4 = new RelayMutationTransaction(mockMutation2); + transaction4.commit({onFailure: failureCallback4}); + + var failureCallback5 = jest.genMockFunction().mockImplementation(); + var transaction5 = new RelayMutationTransaction(mockMutation2); + transaction5.commit({onFailure: failureCallback5}); + + expect(transaction4.getStatus()).toBe( + RelayMutationTransactionStatus.COMMITTING + ); + expect(transaction5.getStatus()).toBe( + RelayMutationTransactionStatus.COMMIT_QUEUED + ); + expect(RelayNetworkLayer.sendMutation.mock.calls.length).toBe(2); + + var request = RelayNetworkLayer.sendMutation.mock.calls[0][0]; + request.reject(new Error('error')); + jest.runAllTimers(); + + expect(failureCallback1).toBeCalled(); + expect(failureCallback2).toBeCalled(); + expect(failureCallback3).toBeCalled(); + expect(failureCallback4).not.toBeCalled(); + expect(failureCallback5).not.toBeCalled(); + expect(transaction1.getStatus()).toBe( + RelayMutationTransactionStatus.COMMIT_FAILED + ); + expect(() => transaction2.getStatus()).toThrow( + 'Invariant Violation: RelayMutationTransaction: Only pending ' + + 'transactions can be interacted with.' + ); + expect(transaction3.getStatus()).toBe( + RelayMutationTransactionStatus.COLLISION_COMMIT_FAILED + ); + expect(transaction4.getStatus()).toBe( + RelayMutationTransactionStatus.COMMITTING + ); + expect(transaction5.getStatus()).toBe( + RelayMutationTransactionStatus.COMMIT_QUEUED + ); + } + ); }); describe('recommit', () => { diff --git a/src/network-layer/default/RelayDefaultNetworkLayer.js b/src/network-layer/default/RelayDefaultNetworkLayer.js index 96460c190c11d..9e5e59a2573f4 100644 --- a/src/network-layer/default/RelayDefaultNetworkLayer.js +++ b/src/network-layer/default/RelayDefaultNetworkLayer.js @@ -157,7 +157,7 @@ class RelayDefaultNetworkLayer { * Rejects HTTP responses with a status code that is not >= 200 and < 300. * This is done to follow the internal behavior of `fetchWithRetries`. */ -function throwOnServerError(response: any): any { +function throwOnServerError(response: any): any { if (response.status >= 200 && response.status < 300) { return response; } else { @@ -186,7 +186,7 @@ function formatRequestErrors( var offset = Math.min(column - 1, CONTEXT_BEFORE); return [ queryLine.substr(column - 1 - offset, CONTEXT_LENGTH), - ' '.repeat(offset) + '^^^' + ' '.repeat(offset) + '^^^', ].map(messageLine => indent + messageLine).join('\n'); }).join('\n') ); diff --git a/src/network-layer/default/__tests__/RelayDefaultNetworkLayer-test.js b/src/network-layer/default/__tests__/RelayDefaultNetworkLayer-test.js index 92d410b138bcb..adf5713157694 100644 --- a/src/network-layer/default/__tests__/RelayDefaultNetworkLayer-test.js +++ b/src/network-layer/default/__tests__/RelayDefaultNetworkLayer-test.js @@ -45,7 +45,7 @@ describe('RelayDefaultNetworkLayer', () => { RelayConnectionInterface = require('RelayConnectionInterface'); RelayDefaultNetworkLayer = require('RelayDefaultNetworkLayer'); RelayMetaRoute = require('RelayMetaRoute'); - RelayMutationRequest = require('RelayMutationRequest'); + RelayMutationRequest = require('RelayMutationRequest'); RelayQuery = require('RelayQuery'); RelayQueryRequest = require('RelayQueryRequest'); @@ -107,7 +107,7 @@ describe('RelayDefaultNetworkLayer', () => { expect(method).toBe('POST'); expect(headers).toEqual({ - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', }); expect(body).toEqual(JSON.stringify({ query: request.getQueryString(), @@ -119,7 +119,7 @@ describe('RelayDefaultNetworkLayer', () => { var response = { data: { test_call: { - field: 1 + field: 1, }, }, }; diff --git a/src/network/RelayNetworkLayer.js b/src/network/RelayNetworkLayer.js index 045aa6af7bdd3..102b1d790243b 100644 --- a/src/network/RelayNetworkLayer.js +++ b/src/network/RelayNetworkLayer.js @@ -56,7 +56,7 @@ var RelayNetworkLayer = { supports(...options: Array): boolean { var networkLayer = getCurrentNetworkLayer(); return networkLayer.supports(...options); - } + }, }; function getCurrentNetworkLayer(): NetworkLayer { diff --git a/src/query/RelayQuery.js b/src/query/RelayQuery.js index e623d22cc6785..05935e7135edb 100644 --- a/src/query/RelayQuery.js +++ b/src/query/RelayQuery.js @@ -16,7 +16,7 @@ var GraphQL = require('GraphQL_EXPERIMENTAL'); var RelayConnectionInterface = require('RelayConnectionInterface'); var RelayFragmentReference = require('RelayFragmentReference'); -import type {Call} from 'RelayInternalTypes'; +import type {Call} from 'RelayInternalTypes'; var RelayMetaRoute = require('RelayMetaRoute'); var RelayRouteFragment = require('RelayRouteFragment'); import type {Variables} from 'RelayTypes'; diff --git a/src/query/RelayQuerySerializer.js b/src/query/RelayQuerySerializer.js index 58fcdd550f960..f428352603c37 100644 --- a/src/query/RelayQuerySerializer.js +++ b/src/query/RelayQuerySerializer.js @@ -27,14 +27,6 @@ type Field = { metadata: {[key: string]: mixed} }; -type Query = { - kind: 'Query'; - name: string; - calls: Array; - children: Array; - metadata: {[key: string]: mixed} -}; - type FragmentDefinition = { kind: 'FragmentDefinition'; name: string; diff --git a/src/query/RelayQueryTransform.js b/src/query/RelayQueryTransform.js index 54b89315e083c..3b097fedb5810 100644 --- a/src/query/RelayQueryTransform.js +++ b/src/query/RelayQueryTransform.js @@ -13,7 +13,6 @@ 'use strict'; -import type RelayQuery from 'RelayQuery'; var RelayQueryVisitor = require('RelayQueryVisitor'); /** diff --git a/src/query/__tests__/RelayFragmentReference-test.js b/src/query/__tests__/RelayFragmentReference-test.js index 272ab0a5ab731..4e1e849f6ce53 100644 --- a/src/query/__tests__/RelayFragmentReference-test.js +++ b/src/query/__tests__/RelayFragmentReference-test.js @@ -19,9 +19,6 @@ describe('RelayFragmentReference', () => { var Relay; var RelayFragmentReference; var RelayMetaRoute; - var RelayQuery; - - var generateRQLFieldAlias; var route; diff --git a/src/query/__tests__/RelayQL-test.js b/src/query/__tests__/RelayQL-test.js index 5eb786195073d..51f4fc6180bbb 100644 --- a/src/query/__tests__/RelayQL-test.js +++ b/src/query/__tests__/RelayQL-test.js @@ -9,6 +9,8 @@ * @emails oncall+relay */ + /* eslint no-unused-expressions: 1 */ + 'use strict'; var RelayTestUtils = require('RelayTestUtils'); diff --git a/src/query/__tests__/RelayQuery-test.js b/src/query/__tests__/RelayQuery-test.js index cdee601a7601d..0b50f38b5cfe5 100644 --- a/src/query/__tests__/RelayQuery-test.js +++ b/src/query/__tests__/RelayQuery-test.js @@ -312,7 +312,7 @@ describe('RelayQuery', () => { query.__concreteNode__.metadata = {rootCallType: 'scalar'}; expect(query.getCallType()).toBe('scalar'); - var me = getNode(Relay.QL`query{me{id}}`); + me = getNode(Relay.QL`query{me{id}}`); expect(me.getCallType()).toBe(undefined); }); @@ -481,7 +481,7 @@ describe('RelayQuery', () => { country, } `; - var fragment = getNode(node); + fragment = getNode(node); expect(fragment.getDebugName()).toBe('UnknownFile'); expect(fragment.getType()).toBe('StreetAddress'); expect(fragment.getFragmentID()).toBe(generateRQLFieldAlias( @@ -493,7 +493,7 @@ describe('RelayQuery', () => { var node = Relay.QL`fragment on Node{id}`; var route = RelayMetaRoute.get('Foo'); var variables = {}; - var fragment = RelayQuery.Node.create(node, route, variables); + fragment = RelayQuery.Node.create(node, route, variables); var fragmentID = generateRQLFieldAlias('0.Foo.{}'); expect(fragment.getFragmentID()).toBe(fragmentID); @@ -582,7 +582,7 @@ describe('RelayQuery', () => { city } `; - var fragment = getNode(fragmentRQL); + fragment = getNode(fragmentRQL); var node = fragment.createNode(fragmentRQL); expect(node instanceof RelayQuery.Fragment).toBe(true); expect(node.getType()).toBe('StreetAddress'); @@ -731,7 +731,7 @@ describe('RelayQuery', () => { `; var variables = {size: '32'}; var pictureVariable = - getNode(pictureVariableRQL, variables).getChildren()[0]; + getNode(pictureVariableRQL, variables).getChildren()[0]; expect(pictureScalar.equals(pictureVariable)).toBe(true); var diffId = getNode(generatedIdRQL).getChildren()[1]; @@ -989,7 +989,7 @@ describe('RelayQuery', () => { // variables return their values expect(friendVariable.getCallsWithValues()).toEqual([ {name: 'first', value: 10}, - {name: 'after', value: 'offset'} + {name: 'after', value: 'offset'}, ]); var pictureScalarRQL = Relay.QL` @@ -999,7 +999,7 @@ describe('RelayQuery', () => { `; var pictureScalar = getNode(pictureScalarRQL).getChildren()[0]; expect(pictureScalar.getCallsWithValues()).toEqual([ - {name: 'size', value: ['32', '64']} + {name: 'size', value: ['32', '64']}, ]); var pictureVariableRQL = Relay.QL` @@ -1014,7 +1014,7 @@ describe('RelayQuery', () => { var pictureVariable = getNode(pictureVariableRQL, variables).getChildren()[0]; expect(pictureVariable.getCallsWithValues()).toEqual([ - {name: 'size', value: [32, '64']} + {name: 'size', value: [32, '64']}, ]); }); @@ -1039,7 +1039,7 @@ describe('RelayQuery', () => { ); expect(clonedFeed.getSchemaName()).toBe('friends'); expect(clonedFeed.getCallsWithValues()).toEqual([ - {name: 'first', value: 25} + {name: 'first', value: 25}, ]); expect(clonedFeed.getSerializationKey()).toEqual( generateRQLFieldAlias('friends.first(25)') @@ -1269,7 +1269,7 @@ describe('RelayQuery', () => { expect(root instanceof RelayQuery.Root).toBe(true); expect(root.getRootCall()).toEqual({ name: 'node', - value: '4' + value: '4', }); expect(root.getChildren().length).toBe(1); expect(root.getChildren()[0]).toBe(field); @@ -1286,7 +1286,7 @@ describe('RelayQuery', () => { expect(root instanceof RelayQuery.Root).toBe(true); expect(root.getRootCall()).toEqual({ name: 'node', - value: '4' + value: '4', }); expect(root.getChildren().length).toBe(1); expect(root.getChildren()[0]).toBe(field); diff --git a/src/query/__tests__/RelayQueryPath-test.js b/src/query/__tests__/RelayQueryPath-test.js index 62ee3237d1310..2d76c8c292adc 100644 --- a/src/query/__tests__/RelayQueryPath-test.js +++ b/src/query/__tests__/RelayQueryPath-test.js @@ -16,7 +16,6 @@ RelayTestUtils.unmockRelay(); describe('RelayQueryPath', () => { var Relay; - var RelayQuery; var RelayQueryPath; var fromJSON; @@ -213,7 +212,7 @@ describe('RelayQueryPath', () => { children: [], metadata: { requisite: true, - parentType: 'Node' + parentType: 'Node', }, }, ], @@ -301,7 +300,7 @@ describe('RelayQueryPath', () => { children: [], metadata: { requisite: true, - parentType: 'Node' + parentType: 'Node', }, }], metadata: {}, @@ -313,7 +312,7 @@ describe('RelayQueryPath', () => { calls: [], children: [EMPTY_FRAGMENT], metadata: { - parentType: 'Actor' + parentType: 'Actor', }, }, ]); diff --git a/src/query/__tests__/RelayQuerySerializer-test.js b/src/query/__tests__/RelayQuerySerializer-test.js index 537856bd9e742..1d9b55c59adfa 100644 --- a/src/query/__tests__/RelayQuerySerializer-test.js +++ b/src/query/__tests__/RelayQuerySerializer-test.js @@ -183,7 +183,7 @@ describe('RelayQuerySerializer', () => { metadata: { requisite: true, parentType: 'Node', - } + }, }], metadata: { isDeferred: false, @@ -210,7 +210,7 @@ describe('RelayQuerySerializer', () => { metadata: { requisite: true, parentType: 'Node', - } + }, }], metadata: { isDeferred: true, @@ -325,7 +325,7 @@ describe('RelayQuerySerializer', () => { pk: 'id', requisite: true, rootCall: 'node', - parentType: 'FriendsEdge' + parentType: 'FriendsEdge', }, }], metadata: {plural: true, parentType: 'FriendsConnection'}, diff --git a/src/query/__tests__/RelayQueryTransform-test.js b/src/query/__tests__/RelayQueryTransform-test.js index ee0f2f65690a6..fefc4d2ad3ae6 100644 --- a/src/query/__tests__/RelayQueryTransform-test.js +++ b/src/query/__tests__/RelayQueryTransform-test.js @@ -15,13 +15,10 @@ var RelayTestUtils = require('RelayTestUtils'); RelayTestUtils.unmockRelay(); describe('RelayQueryTransform', () => { - var GraphQL; var Relay; var RelayQuery; var RelayQueryTransform; - var generateRQLFieldAlias; - var {getNode} = RelayTestUtils; var query; diff --git a/src/query/__tests__/RelayQueryVisitor-test.js b/src/query/__tests__/RelayQueryVisitor-test.js index 8a5977ea96dba..cbee4da213e0f 100644 --- a/src/query/__tests__/RelayQueryVisitor-test.js +++ b/src/query/__tests__/RelayQueryVisitor-test.js @@ -15,13 +15,10 @@ var RelayTestUtils = require('RelayTestUtils'); RelayTestUtils.unmockRelay(); describe('RelayQueryVisitor', () => { - var GraphQL; var Relay; var RelayQuery; var RelayQueryVisitor; - var generateRQLFieldAlias; - var {getNode} = RelayTestUtils; var query; diff --git a/src/query/__tests__/toGraphQL-test.js b/src/query/__tests__/toGraphQL-test.js index af30d8db82c8b..0fb268c83fb5d 100644 --- a/src/query/__tests__/toGraphQL-test.js +++ b/src/query/__tests__/toGraphQL-test.js @@ -15,7 +15,6 @@ var RelayTestUtils = require('RelayTestUtils'); RelayTestUtils.unmockRelay(); describe('toGraphQL', function() { - var GraphQL; var Relay; var fromGraphQL; @@ -45,7 +44,7 @@ describe('toGraphQL', function() { 'Expected ' + expected + not + 'to equal ' + actual; return expected === actual; - } + }, }); }); diff --git a/src/query/fromGraphQL.js b/src/query/fromGraphQL.js index 795c2d1ad67cc..f0736471d1353 100644 --- a/src/query/fromGraphQL.js +++ b/src/query/fromGraphQL.js @@ -70,7 +70,7 @@ var fromGraphQL = { 'fromGraphQL.Operation(): Expected a mutation/subscription node.' ); return node; - } + }, }; RelayProfiler.instrumentMethods(fromGraphQL, { diff --git a/src/route/__tests__/RelayRoute-test.js b/src/route/__tests__/RelayRoute-test.js index d62027230e061..9edb674d63d42 100644 --- a/src/route/__tests__/RelayRoute-test.js +++ b/src/route/__tests__/RelayRoute-test.js @@ -33,12 +33,12 @@ describe('RelayRoute', () => { MockRoute.paramDefinitions = { required: { type: 'String', - required: true + required: true, }, optional: { type: 'String', - required: false - } + required: false, + }, }; MockRoute.queries = { required: (Component, params) => Relay.QL` @@ -54,7 +54,7 @@ describe('RelayRoute', () => { ${Component.getQuery('optional')} } } - ` + `, }; return MockRoute; }; diff --git a/src/store/RelayNeglectionStateMap.js b/src/store/RelayNeglectionStateMap.js index 3466bb6d6f5ca..1682322c66603 100644 --- a/src/store/RelayNeglectionStateMap.js +++ b/src/store/RelayNeglectionStateMap.js @@ -59,7 +59,7 @@ class RelayNeglectionStateMap { dataID ); data.subscriptions--; - this._map.set(dataID, data); + this._map.set(dataID, data); } increaseSubscriptionsFor(dataID: DataID): void { @@ -70,7 +70,7 @@ class RelayNeglectionStateMap { } var data = this._map.get(dataID); data.subscriptions++; - this._map.set(dataID, data); + this._map.set(dataID, data); } register(dataID: DataID): void { @@ -110,7 +110,7 @@ class RelayNeglectionStateMap { } var value = states[ii++]; return {done, value}; - } + }, }; } diff --git a/src/store/RelayPendingQueryTracker.js b/src/store/RelayPendingQueryTracker.js index ca9883fdba5cf..1b0a23556d59d 100644 --- a/src/store/RelayPendingQueryTracker.js +++ b/src/store/RelayPendingQueryTracker.js @@ -208,7 +208,7 @@ class PendingFetch { var queryID = this.getQuery().getID(); delete pendingFetchMap[queryID]; - warning(false, error.message); + warning(false, 'Cannot mark as rejected'); this._errors.push(error); this._updateResolvedDeferred(); diff --git a/src/store/RelayRecordStore.js b/src/store/RelayRecordStore.js index 3376ee0bc7eff..20266c13c7c58 100644 --- a/src/store/RelayRecordStore.js +++ b/src/store/RelayRecordStore.js @@ -562,7 +562,7 @@ class RelayRecordStore { var connectionIDs; forEachObject(record, (datum, key) => { if (datum && getFieldNameFromKey(key) === schemaName) { - var dataID = datum.__dataID__; + dataID = datum.__dataID__; if (dataID) { connectionIDs = connectionIDs || []; connectionIDs.push(dataID); diff --git a/src/store/RelayStore.js b/src/store/RelayStore.js index d6cd6b4bc8803..b75a85e30f1e8 100644 --- a/src/store/RelayStore.js +++ b/src/store/RelayStore.js @@ -175,7 +175,7 @@ var RelayStore = { ): void { var transaction = new RelayMutationTransaction(mutation); transaction.commit(callbacks); - } + }, }; module.exports = RelayStore; diff --git a/src/store/RelayStoreData.js b/src/store/RelayStoreData.js index 8952a84204584..ce7029f709345 100644 --- a/src/store/RelayStoreData.js +++ b/src/store/RelayStoreData.js @@ -162,7 +162,7 @@ class RelayStoreData { * Runs the callback after all data has been read out from diskc cache into * cachedRecords */ - runWithDiskCache(callback: () => void): void{ + runWithDiskCache(callback: () => void): void { if (this._cachePopulated || !this._cacheManager) { resolveImmediate(callback); } else { diff --git a/src/store/RelayStoreGarbageCollector.js b/src/store/RelayStoreGarbageCollector.js index abef163667b15..23d205ed5fdfd 100644 --- a/src/store/RelayStoreGarbageCollector.js +++ b/src/store/RelayStoreGarbageCollector.js @@ -128,7 +128,7 @@ class RelayStoreGarbageCollector { iterator = offset; var profileState = { count: -1, - stepLength: stepLength + stepLength: stepLength, }; var profile = RelayProfiler.profile( 'RelayStoreGarbageCollector.collect', @@ -239,14 +239,14 @@ class RelayStoreGarbageCollector { var remainingRecords: Array = [ records[dataID], queuedRecords[dataID], - cachedRecords[dataID] + cachedRecords[dataID], ]; // If `field` contains a linked record and the linked record has a // client-site DataID the record will be added to `remainingRecords` and // it's DataID will be set to `true` in `removalStatusMap`. function enqueueField(field: FieldValue): void { - var dataID = getClientIDFromLinkedRecord(field); + dataID = getClientIDFromLinkedRecord(field); // If we have a dataID we haven't seen before we add it to the remaining // records if (dataID && !removalStatusMap[dataID]) { diff --git a/src/store/__mocks__/RelayStore.js b/src/store/__mocks__/RelayStore.js index 017f404ad38ba..f88e5000f1a73 100644 --- a/src/store/__mocks__/RelayStore.js +++ b/src/store/__mocks__/RelayStore.js @@ -60,7 +60,7 @@ RelayStore.primeCache.mockImplementation((...args) => { var returnValue = { abort: jest.genMockFunction().mockImplementation(() => { resolveImmediate(request.abort); - }) + }), }; RelayStore.primeCache.mock.abort.push(returnValue.abort); RelayStore.primeCache.mock.requests.push(request); @@ -74,7 +74,7 @@ RelayStore.forceFetch.mockImplementation((...args) => { var returnValue = { abort: jest.genMockFunction().mockImplementation(() => { resolveImmediate(request.abort); - }) + }), }; RelayStore.forceFetch.mock.abort.push(returnValue.abort); RelayStore.forceFetch.mock.requests.push(request); diff --git a/src/store/__mocks__/observeAllRelayQueryData.js b/src/store/__mocks__/observeAllRelayQueryData.js index c4fb10c72c93a..900729d3ebdcd 100644 --- a/src/store/__mocks__/observeAllRelayQueryData.js +++ b/src/store/__mocks__/observeAllRelayQueryData.js @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ + /* eslint no-shadow: 1 */ + 'use strict'; var actualImplementation = require.requireActual('observeAllRelayQueryData'); diff --git a/src/store/__mocks__/observeRelayQueryData.js b/src/store/__mocks__/observeRelayQueryData.js index d869eceef141f..16cb136ce3ffa 100644 --- a/src/store/__mocks__/observeRelayQueryData.js +++ b/src/store/__mocks__/observeRelayQueryData.js @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ + /* eslint no-shadow: 1 */ + 'use strict'; var actualImplementation = require.requireActual('observeRelayQueryData'); diff --git a/src/store/__tests__/RelayPendingQueryTracker-test.js b/src/store/__tests__/RelayPendingQueryTracker-test.js index 72b9a65e75c7c..6d3e112cea226 100644 --- a/src/store/__tests__/RelayPendingQueryTracker-test.js +++ b/src/store/__tests__/RelayPendingQueryTracker-test.js @@ -18,17 +18,13 @@ jest.dontMock('RelayPendingQueryTracker'); describe('RelayPendingQueryTracker', () => { var DliteFetchModeConstants; - var GraphQL; - var Promise; var Relay; var RelayPendingQueryTracker; - var RelayQuery; var RelayStoreData; var addPending; var fetchRelayQuery; var subtractRelayQuery; - var toGraphQL; var writeRelayQueryPayload; var {getNode} = RelayTestUtils; diff --git a/src/store/__tests__/RelayRecordStore-test.js b/src/store/__tests__/RelayRecordStore-test.js index 99c27bb9dddfc..316dffcd9c922 100644 --- a/src/store/__tests__/RelayRecordStore-test.js +++ b/src/store/__tests__/RelayRecordStore-test.js @@ -367,47 +367,49 @@ describe('RelayRecordStore', () => { it('falls through to existing records for fields not in the queued record', () => { - var record = { - id: '4', - name: 'Zuck', - __dataID__: '4', - }; - var queuedRecord = { - id: '4', - __dataID__: '4', - }; - var store = new RelayRecordStore({ - records: {'4': record}, - queuedRecords: {'4': queuedRecord}, - }); - expect(store.getField('4', 'name')).toBe('Zuck'); - }); + var record = { + id: '4', + name: 'Zuck', + __dataID__: '4', + }; + var queuedRecord = { + id: '4', + __dataID__: '4', + }; + var store = new RelayRecordStore({ + records: {'4': record}, + queuedRecords: {'4': queuedRecord}, + }); + expect(store.getField('4', 'name')).toBe('Zuck'); + } + ); it('falls through to cached records for fields not in the existing record', () => { - var record = { - id: '4', - __dataID__: '4', - }; - var cachedRecord = { - id: '4', - name: 'Mark', - __dataID__: '4', - }; - var store = new RelayRecordStore({ - cachedRecords: {'4': cachedRecord}, - records: {'4': record}, - }); - expect(store.getField('4', 'name')).toBe('Mark'); - }); + var record = { + id: '4', + __dataID__: '4', + }; + var cachedRecord = { + id: '4', + name: 'Mark', + __dataID__: '4', + }; + var store = new RelayRecordStore({ + cachedRecords: {'4': cachedRecord}, + records: {'4': record}, + }); + expect(store.getField('4', 'name')).toBe('Mark'); + } + ); }); describe('getLinkedRecordID()', () => { it('throws if the data is an unexpected format', () => { var records = { story: { - feedback: 'not an object' - } + feedback: 'not an object', + }, }; var store = new RelayRecordStore({records}); expect(() => { @@ -420,7 +422,7 @@ describe('RelayRecordStore', () => { '4': { id: '4', __dataID__: '4', - } + }, }; var store = new RelayRecordStore({records}); expect(store.getLinkedRecordID('4', 'address')).toBe(undefined); @@ -431,7 +433,7 @@ describe('RelayRecordStore', () => { '4': { id: '4', __dataID__: '4', - address: null + address: null, }, }; var store = new RelayRecordStore({records}); @@ -445,7 +447,7 @@ describe('RelayRecordStore', () => { __dataID__: '4', address: { __dataID__: 'client:1', - } + }, }, 'client:1': { street: '1 Hacker Way', @@ -460,8 +462,8 @@ describe('RelayRecordStore', () => { it('throws if the data is an unexpected format', () => { var records = { 'story': { - actors: ['not an object'] - } + actors: ['not an object'], + }, }; var store = new RelayRecordStore({records}); expect(() => { @@ -473,8 +475,8 @@ describe('RelayRecordStore', () => { var records = { '4': { id: '4', - __dataID__: '4' - } + __dataID__: '4', + }, }; var store = new RelayRecordStore({records}); expect(store.getLinkedRecordIDs('4', 'actors')).toBe(undefined); @@ -485,8 +487,8 @@ describe('RelayRecordStore', () => { '4': { id: '4', __dataID__: '4', - actors: null - } + actors: null, + }, }; var store = new RelayRecordStore({records}); expect(store.getLinkedRecordIDs('4', 'actors')).toBe(null); @@ -500,13 +502,13 @@ describe('RelayRecordStore', () => { actors: [ {__dataID__: 'item:1'}, {__dataID__: 'item:2'}, - ] - } + ], + }, }; var store = new RelayRecordStore({records}); expect(store.getLinkedRecordIDs('4', 'actors')).toEqual([ 'item:1', - 'item:2' + 'item:2', ]); }); }); @@ -521,7 +523,7 @@ describe('RelayRecordStore', () => { id: '4', __dataID__: '4', 'friends': { - __dataID__: 'client:1' + __dataID__: 'client:1', }, }, 'client:1': { @@ -530,8 +532,8 @@ describe('RelayRecordStore', () => { 'edge:1': { __dataID__: 'edge:1', node: { - __dataID__: 'node:1' - } + __dataID__: 'node:1', + }, }, 'node:1': { __dataID__: 'node:1', @@ -550,7 +552,7 @@ describe('RelayRecordStore', () => { var store = new RelayRecordStore({records}); var calls = [ {name: 'first', value: '10'}, - {name: 'orderby', value: 'TOP_STORIES'} + {name: 'orderby', value: 'TOP_STORIES'}, ]; expect(store.getRangeMetadata('client:1', calls)).toBe(undefined); }); @@ -561,7 +563,7 @@ describe('RelayRecordStore', () => { store.getRangeMetadata('client:1', []); expect([ 'RelayRecordStore.getRangeMetadata(): Expected range to exist if ' + - '`edges` has been fetched.' + '`edges` has been fetched.', ]).toBeWarnedNTimes(1); }); @@ -594,7 +596,7 @@ describe('RelayRecordStore', () => { diffCalls: [ {name: 'first', value: '1'}, {name: 'after', value: 'edge:1'}, - ] + ], }); var store = new RelayRecordStore({records}); var rangeInfo = store.getRangeMetadata('client:1', [ @@ -609,10 +611,10 @@ describe('RelayRecordStore', () => { ]); expect(rangeInfo.requestedEdges).toEqual([{ edgeID: 'edge:1', - nodeID: 'node:1' + nodeID: 'node:1', }]); expect(rangeInfo.filterCalls).toEqual([ - {name: 'orderby', value: ['TOP_STORIES']} + {name: 'orderby', value: ['TOP_STORIES']}, ]); }); }); @@ -634,8 +636,8 @@ describe('RelayRecordStore', () => { var calls = [ { name: 'orderby', - value: 'TOP_STORIES' - } + value: 'TOP_STORIES', + }, ]; var records = { 'client:1': { @@ -662,7 +664,7 @@ describe('RelayRecordStore', () => { it('returns null if the record is not in a connection', () => { var records = { '1': { - __dataID__: '1' + __dataID__: '1', }, }; var store = new RelayRecordStore({records}); @@ -672,7 +674,7 @@ describe('RelayRecordStore', () => { it('returns the connection ids containing the node', () => { var records = { '1': { - __dataID__: '1' + __dataID__: '1', }, 'range:1': { __dataID__: 'range:1', @@ -690,7 +692,7 @@ describe('RelayRecordStore', () => { var store = new RelayRecordStore({records}, null, nodeRangeMap); expect(store.getConnectionIDsForRecord('1')).toEqual([ 'range:1', - 'range:2' + 'range:2', ]); // node/connection link is cleared when the node is deleted @@ -723,11 +725,11 @@ describe('RelayRecordStore', () => { '1': { __dataID__: '1', 'photos': { - __dataID__: '2' + __dataID__: '2', }, 'photos.orderby(likes)': { - __dataID__: '3' - } + __dataID__: '3', + }, }, }; var store = new RelayRecordStore({records}); diff --git a/src/store/__tests__/RelayRecordStore_write-test.js b/src/store/__tests__/RelayRecordStore_write-test.js index 043cc716f4ec9..def6db1d4309b 100644 --- a/src/store/__tests__/RelayRecordStore_write-test.js +++ b/src/store/__tests__/RelayRecordStore_write-test.js @@ -14,7 +14,6 @@ jest.autoMockOff(); describe('RelayRecordStore', () => { - var GraphQL; var GraphQLRange; var RelayConnectionInterface; var RelayMockCacheManager; @@ -75,7 +74,7 @@ describe('RelayRecordStore', () => { var cache = RelayMockCacheManager.genCacheManager(); var records = { '1': { - __dataID__: '1' + __dataID__: '1', }, }; var store = new RelayRecordStore({records}, null, null, cache); @@ -178,7 +177,7 @@ describe('RelayRecordStore', () => { is_verified: true, phone_number: { display_number: '1-800-555-1212', // directory assistance - } + }, }; store.putField('1', 'all_phones', [phone]); expect(store.getField('1', 'all_phones')).toEqual([phone]); @@ -420,7 +419,7 @@ describe('RelayRecordStore', () => { ); }); - it('overwrites ranges if present', () => { + it('overwrites ranges if present', () => { var cache = RelayMockCacheManager.genCacheManager(); var records = {}; var store = new RelayRecordStore({records}, null, null, cache); @@ -482,11 +481,11 @@ describe('RelayRecordStore', () => { var calls = [ { name: 'orderby', - value: 'TOP_STORIES' + value: 'TOP_STORIES', }, { name: 'first', - value: '10' + value: '10', }, ]; store.putRecord('1'); @@ -550,8 +549,8 @@ describe('RelayRecordStore', () => { ); // node are automatically associated with the range - nodes.forEach(nodeID => { - expect(store.getConnectionIDsForRecord(nodeID)).toEqual([connectionID]); + nodes.forEach(node => { + expect(store.getConnectionIDsForRecord(node)).toEqual([connectionID]); }); var rangeInfo = store.getRangeMetadata(connectionID, calls); @@ -580,7 +579,6 @@ describe('RelayRecordStore', () => { var queuedRecords; var queuedStore; var records; - var store; var _inc = 0; function addEdgeToStore(store) { @@ -666,7 +664,7 @@ describe('RelayRecordStore', () => { var rangeInfo = store.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ edgeID, - firstEdgeID + firstEdgeID, ]); expect(store.getConnectionIDsForRecord(nodeID)).toEqual([connectionID]); expect(cache.cacheField).toBeCalledWith( @@ -685,7 +683,7 @@ describe('RelayRecordStore', () => { var rangeInfo = queuedStore.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ edgeID, - firstEdgeID + firstEdgeID, ]); // cache not updated on optimistic range update expect(cache.cacheField).not.toBeCalledWith( @@ -697,7 +695,7 @@ describe('RelayRecordStore', () => { // base store is unchanged rangeInfo = store.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ - firstEdgeID + firstEdgeID, ]); expect(store.getConnectionIDsForRecord(nodeID)).toEqual(null); }); @@ -711,7 +709,7 @@ describe('RelayRecordStore', () => { var rangeInfo = store.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ lastEdgeID, - edgeID + edgeID, ]); expect(store.getConnectionIDsForRecord(nodeID)).toEqual([connectionID]); expect(cache.cacheField).toBeCalledWith( @@ -730,7 +728,7 @@ describe('RelayRecordStore', () => { var rangeInfo = queuedStore.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ lastEdgeID, - edgeID + edgeID, ]); // cache not updated on optimistic range update expect(cache.cacheField).not.toBeCalledWith( @@ -742,14 +740,14 @@ describe('RelayRecordStore', () => { // base store is unchanged rangeInfo = store.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ - lastEdgeID + lastEdgeID, ]); expect(store.getConnectionIDsForRecord(nodeID)).toEqual(null); }); it('deletes edges from base stores', () => { expect(store.getConnectionIDsForRecord(firstNodeID)).toEqual([ - connectionID + connectionID, ]); store.applyRangeUpdate(connectionID, firstEdgeID, REMOVE); @@ -782,10 +780,10 @@ describe('RelayRecordStore', () => { // base store is unchanged rangeInfo = store.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ - firstEdgeID + firstEdgeID, ]); expect(store.getConnectionIDsForRecord(firstNodeID)).toEqual([ - connectionID + connectionID, ]); }); @@ -798,7 +796,7 @@ describe('RelayRecordStore', () => { var calls = [{name: 'first', value: 1}]; var rangeInfo = queuedStore.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ - firstEdgeID + firstEdgeID, ]); }); @@ -811,7 +809,7 @@ describe('RelayRecordStore', () => { var calls = [{name: 'last', value: 1}]; var rangeInfo = queuedStore.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ - lastEdgeID + lastEdgeID, ]); }); }); diff --git a/src/store/__tests__/RelayStoreData-test.js b/src/store/__tests__/RelayStoreData-test.js index b0720e8bff83e..968ecbedee644 100644 --- a/src/store/__tests__/RelayStoreData-test.js +++ b/src/store/__tests__/RelayStoreData-test.js @@ -60,7 +60,7 @@ describe('RelayStoreData', () => { topLevelComments: { count: 1, }, - } + }, }; storeData.handleQueryPayload(query, response); @@ -203,7 +203,7 @@ describe('RelayStoreData', () => { topLevelComments: { count: 1, }, - } + }, }; storeData.handleQueryPayload(query, response); diff --git a/src/store/__tests__/RelayStoreData_cacheManager-test.js b/src/store/__tests__/RelayStoreData_cacheManager-test.js index 9575259497689..58bce8e687f64 100644 --- a/src/store/__tests__/RelayStoreData_cacheManager-test.js +++ b/src/store/__tests__/RelayStoreData_cacheManager-test.js @@ -61,7 +61,7 @@ describe('RelayStoreData', function() { CLIENT_MUTATION_ID, HAS_NEXT_PAGE, HAS_PREV_PAGE, - PAGE_INFO + PAGE_INFO, } = RelayConnectionInterface); cacheManager = RelayMockCacheManager.genCacheManager(); @@ -126,7 +126,7 @@ describe('RelayStoreData', function() { '123': { __dataID__: '123', id: '123', - } + }, }); }); @@ -149,7 +149,7 @@ describe('RelayStoreData', function() { '123': { __dataID__: '123', id: '123', - } + }, }); }); @@ -168,7 +168,7 @@ describe('RelayStoreData', function() { __dataID__: 'client:viewer', __path__: getPathToRecord('client:viewer'), isFbEmployee: true, - } + }, }); }); @@ -232,7 +232,7 @@ describe('RelayStoreData', function() { {service: 'GTALK'}, {service: 'TWITTER'}, ], - } + }, }; storeData.handleQueryPayload(query, response); @@ -291,13 +291,13 @@ describe('RelayStoreData', function() { edges: [ { node: { - id: '1' + id: '1', }, cursor: '1', }, { node: { - id: '2' + id: '2', }, cursor: '2', }, @@ -488,7 +488,7 @@ describe('RelayStoreData', function() { [HAS_NEXT_PAGE]: true, }, }, - } + }, }; storeData.handleQueryPayload(query, response); @@ -609,7 +609,7 @@ describe('RelayStoreData', function() { [HAS_NEXT_PAGE]: true, }, }, - } + }, }; storeData.handleQueryPayload(query, response); diff --git a/src/store/__tests__/RelayStoreGarbageCollector-test.js b/src/store/__tests__/RelayStoreGarbageCollector-test.js index 940752f81b613..7b860332a32da 100644 --- a/src/store/__tests__/RelayStoreGarbageCollector-test.js +++ b/src/store/__tests__/RelayStoreGarbageCollector-test.js @@ -9,6 +9,8 @@ * @emails oncall+relay */ +/* eslint no-shadow: 1 */ + 'use strict'; jest @@ -471,7 +473,7 @@ describe('RelayStoreGarbageCollector', () => { __dataID__: 'b', field2: {__dataID__: 'client:2'}, }, - 'client:2': {__dataID__: 'client:2'} + 'client:2': {__dataID__: 'client:2'}, }); } ); @@ -479,7 +481,7 @@ describe('RelayStoreGarbageCollector', () => { it('removes all edges when a range is removed', () => { var mockRange = new GraphQLRange(); mockRange.getEdgeIDs = jest.genMockFunction().mockReturnValue([ - 'client:1', 'client:2' + 'client:1', 'client:2', ]); var records = { range: {__dataID__: 'range', __range__: mockRange}, diff --git a/src/store/__tests__/observeAllRelayQueryData-test.js b/src/store/__tests__/observeAllRelayQueryData-test.js index 3e052b65d9135..6689ce7c2760f 100644 --- a/src/store/__tests__/observeAllRelayQueryData-test.js +++ b/src/store/__tests__/observeAllRelayQueryData-test.js @@ -9,6 +9,8 @@ * @emails oncall+relay */ + /* eslint no-shadow: 1 */ + 'use strict'; var RelayTestUtils = require('RelayTestUtils'); @@ -194,7 +196,7 @@ describe('observeRelayQueryData', () => { ]); }); - it('calls the callback with data in the same order the dataIDs are', () =>{ + it('calls the callback with data in the same order the dataIDs are', () => { var query = getNode(Relay.QL`fragment on Node @relay(plural:true){id}`); var records = { a: {__dataID__: 'a', id: 1}, diff --git a/src/store/__tests__/observeRelayQueryData-test.js b/src/store/__tests__/observeRelayQueryData-test.js index 73304a2ed7160..730ddef5bb181 100644 --- a/src/store/__tests__/observeRelayQueryData-test.js +++ b/src/store/__tests__/observeRelayQueryData-test.js @@ -17,12 +17,10 @@ RelayTestUtils.unmockRelay(); describe('observeRelayQueryData', () => { var GraphQLStoreChangeEmitter; var Relay; - var RelayQuery; var RelayRecordStore; var addListenerForIDs; var observeRelayQueryData; - var readRelayQueryData; var firstMockCallback; var secondMockCallback; @@ -86,7 +84,7 @@ describe('observeRelayQueryData', () => { var query = getNode(Relay.QL`fragment on Node{id, name}`); var records = {node: null}; observeData(records, query, 'node').subscribe({ - onNext: firstMockCallback + onNext: firstMockCallback, }); expect(firstMockCallback).toBeCalledWith(null); @@ -146,93 +144,91 @@ describe('observeRelayQueryData', () => { // Check that the change emitter still listens to the right id expect(addListenerForIDs.mock.calls[1][0]).toEqual([ - 'user', 'date' + 'user', 'date', ]); }); it('calls subscribers when data is added to an observed node', () => { - var recordsStore = new RelayRecordStore({records: { - user: {id: 1, name: 'Chris', birthdate: {__dataID__: 'date'}}, - date: null, - }}); - var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); - var observable = observeRelayQueryData(recordsStore, query, 'user'); + var recordsStore = new RelayRecordStore({records: { + user: {id: 1, name: 'Chris', birthdate: {__dataID__: 'date'}}, + date: null, + }}); + var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); + var observable = observeRelayQueryData(recordsStore, query, 'user'); - observable.subscribe({onNext: firstMockCallback}); - var handleUpdate = addListenerForIDs.mock.calls[0][1]; + observable.subscribe({onNext: firstMockCallback}); + var handleUpdate = addListenerForIDs.mock.calls[0][1]; - // Mutate birthdate record - recordsStore.putRecord('date'); - recordsStore.putField('date', 'day', 30); - handleUpdate(); + // Mutate birthdate record + recordsStore.putRecord('date'); + recordsStore.putField('date', 'day', 30); + handleUpdate(); - expect(firstMockCallback).toBeCalledWith({ - __dataID__: 'user', - id: 1, - name: 'Chris', - birthdate: { - __dataID__: 'date', - day: 30, - }, - }); - expect(addListenerForIDs.mock.remove[0]).toBeCalled(); - expect(addListenerForIDs.mock.calls[1][0]).toEqual([ - 'user', 'date' - ]); - } - ); + expect(firstMockCallback).toBeCalledWith({ + __dataID__: 'user', + id: 1, + name: 'Chris', + birthdate: { + __dataID__: 'date', + day: 30, + }, + }); + expect(addListenerForIDs.mock.remove[0]).toBeCalled(); + expect(addListenerForIDs.mock.calls[1][0]).toEqual([ + 'user', 'date', + ]); + }); it('calls a subscriber when data disappears from a node', () => { - var recordsStore = new RelayRecordStore({records: { - user: {id: 1, name: 'Jon', birthdate: {__dataID__: 'date'}}, - date: {day: 15 }, - }}); - var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); - var observable = observeRelayQueryData(recordsStore, query, 'user'); + var recordsStore = new RelayRecordStore({records: { + user: {id: 1, name: 'Jon', birthdate: {__dataID__: 'date'}}, + date: {day: 15 }, + }}); + var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); + var observable = observeRelayQueryData(recordsStore, query, 'user'); - observable.subscribe({onNext: firstMockCallback}); - var handleUpdate = addListenerForIDs.mock.calls[0][1]; + observable.subscribe({onNext: firstMockCallback}); + var handleUpdate = addListenerForIDs.mock.calls[0][1]; - // Remove record from store - recordsStore.deleteRecord('date'); - handleUpdate(); + // Remove record from store + recordsStore.deleteRecord('date'); + handleUpdate(); - expect(firstMockCallback).toBeCalledWith({ - __dataID__: 'user', - id: 1, - name: 'Jon', - birthdate: null, - }); - expect(addListenerForIDs.mock.calls[0][0]).toEqual([ - 'user', 'date' - ]); - expect(addListenerForIDs.mock.remove[0]).toBeCalled(); - expect(addListenerForIDs.mock.calls[1][0]).toEqual([ - 'user', 'date' - ]); - } - ); + expect(firstMockCallback).toBeCalledWith({ + __dataID__: 'user', + id: 1, + name: 'Jon', + birthdate: null, + }); + expect(addListenerForIDs.mock.calls[0][0]).toEqual([ + 'user', 'date', + ]); + expect(addListenerForIDs.mock.remove[0]).toBeCalled(); + expect(addListenerForIDs.mock.calls[1][0]).toEqual([ + 'user', 'date', + ]); + }); it('no longer calls disposed-of subscribers when data changes', () => { - var recordsStore = new RelayRecordStore({records: { - user: {id: 1, name: 'Jon', birthdate: {__dataID__: 'date'}}, - date: {day: 15 }, - }}); - var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); - var observable = observeRelayQueryData(recordsStore, query, 'user'); + var recordsStore = new RelayRecordStore({records: { + user: {id: 1, name: 'Jon', birthdate: {__dataID__: 'date'}}, + date: {day: 15 }, + }}); + var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); + var observable = observeRelayQueryData(recordsStore, query, 'user'); - observable.subscribe({onNext: firstMockCallback}); - var handleUpdate = addListenerForIDs.mock.calls[0][1]; - var subscription = observable.subscribe({onNext: secondMockCallback}); + observable.subscribe({onNext: firstMockCallback}); + var handleUpdate = addListenerForIDs.mock.calls[0][1]; + var subscription = observable.subscribe({onNext: secondMockCallback}); - expect(secondMockCallback).toBeCalled(); + expect(secondMockCallback).toBeCalled(); - subscription.dispose(); - recordsStore.deleteRecord('date'); - handleUpdate(); + subscription.dispose(); + recordsStore.deleteRecord('date'); + handleUpdate(); - expect(firstMockCallback.mock.calls.length).toBe(2); - expect(secondMockCallback.mock.calls.length).toBe(1); + expect(firstMockCallback.mock.calls.length).toBe(2); + expect(secondMockCallback.mock.calls.length).toBe(1); }); describe('garbage collection', () => { diff --git a/src/store/__tests__/readRelayQueryData-test.js b/src/store/__tests__/readRelayQueryData-test.js index b6857b479b0eb..3702e98a4277a 100644 --- a/src/store/__tests__/readRelayQueryData-test.js +++ b/src/store/__tests__/readRelayQueryData-test.js @@ -21,7 +21,6 @@ describe('readRelayQueryData', () => { var Relay; var RelayConnectionInterface; var RelayFragmentReference; - var RelayQuery; var RelayRecordStore; var callsToGraphQL; var readRelayQueryData; @@ -57,7 +56,7 @@ describe('readRelayQueryData', () => { HAS_NEXT_PAGE, HAS_PREV_PAGE, PAGE_INFO, - START_CURSOR + START_CURSOR, } = RelayConnectionInterface); jest.addMatchers(RelayTestUtils.matchers); @@ -180,7 +179,7 @@ describe('readRelayQueryData', () => { user_id: { id: 'user_id', websites: [], - } + }, }; var query = getNode(Relay.QL`fragment on User{id,websites}`); var data = getData({records}, query, 'user_id'); @@ -193,8 +192,8 @@ describe('readRelayQueryData', () => { var records = { user_id: { id: 'user_id', - websites - } + websites, + }, }; var query = getNode(Relay.QL`fragment on User{id,websites}`); var data = getData({records}, query, 'user_id'); @@ -263,7 +262,7 @@ describe('readRelayQueryData', () => { __dataID__: 'client:1', city: 'San Francisco', country: 'US', - } + }, }; var fragment1 = Relay.QL`fragment on Actor{address{city}}`; @@ -279,7 +278,7 @@ describe('readRelayQueryData', () => { __dataID__: 'client:1', city: 'San Francisco', country: 'US', - } + }, }); }); @@ -315,7 +314,7 @@ describe('readRelayQueryData', () => { [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false, - } + }, }); var data = getData({records}, query, rangeID); expect(data).toEqual({ @@ -381,7 +380,7 @@ describe('readRelayQueryData', () => { [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - } + }, }); var data = getData({records}, query, 'feedbackID'); @@ -428,7 +427,7 @@ describe('readRelayQueryData', () => { [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - } + }, }); var data = getData({records}, query, 'feedbackID'); @@ -439,7 +438,7 @@ describe('readRelayQueryData', () => { count: 57, [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - } + }, }, }); }); @@ -535,7 +534,7 @@ describe('readRelayQueryData', () => { __dataID__: 'feedback_id', likers: { __dataID__: 'likers_id', - } + }, }, likers_id: { __dataID__: 'likers_id', @@ -552,16 +551,16 @@ describe('readRelayQueryData', () => { __dataID__: 'likers_edge_id', node: { __dataID__: 'liker_id', - } + }, }, likers_page_info_id: { __dataID__: 'likers_page_info_id', - [HAS_NEXT_PAGE]: true + [HAS_NEXT_PAGE]: true, }, liker_id: { __dataID__: 'liker_id', - name: 'Tim' - } + name: 'Tim', + }, }; var query = getNode(Relay.QL`fragment on Feedback{likers(first:"1"){edges{node{name}}}}`); @@ -604,7 +603,7 @@ describe('readRelayQueryData', () => { __dataID__: 'feedback_id', comments: { __dataID__: 'comments_id', - } + }, }, comments_id: { __dataID__: 'comments_id', @@ -632,7 +631,7 @@ describe('readRelayQueryData', () => { [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - } + }, }); var data = getData( @@ -647,7 +646,7 @@ describe('readRelayQueryData', () => { [PAGE_INFO]: { [START_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, - } + }, }); data = getData({records}, query, 'feedback_id'); @@ -667,7 +666,7 @@ describe('readRelayQueryData', () => { __dataID__: 'feedback_id', comments: { __dataID__: 'comments_id', - } + }, }, comments_id: { __dataID__: 'comments_id', @@ -681,7 +680,7 @@ describe('readRelayQueryData', () => { __dataID__: 'comment_edge_id', node: {__dataID__: 'comment_node_id'}, cursor: 'cursor', - } + }, }; var fragmentReference = new RelayFragmentReference( () => Relay.QL`fragment on CommentsConnection{edges{node{id}}}`, @@ -709,7 +708,7 @@ describe('readRelayQueryData', () => { [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - } + }, }); var data = getData( @@ -725,12 +724,12 @@ describe('readRelayQueryData', () => { __dataID__: 'comment_edge_id', node: { __dataID__: 'comment_node_id', - id: 'comment_node_id' - } + id: 'comment_node_id', + }, }], [PAGE_INFO]: { [START_CURSOR]: 'cursor', - } + }, }); data = getData({records}, query, 'feedback_id'); @@ -753,23 +752,23 @@ describe('readRelayQueryData', () => { {__dataID__: 'client1'}, {__dataID__: 'client2'}, ], - hometown: {__dataID__: 'hometown_id'} + hometown: {__dataID__: 'hometown_id'}, }, hometown_id: { __dataID__: 'hometown_id', id: 'hometown_id', - name: 'hometown name' + name: 'hometown name', }, client1: { __dataID__: 'client1', service: 'GTALK', - name: '123' + name: '123', }, client2: { __dataID__: 'client1', service: 'TWITTER', - name: '123' - } + name: '123', + }, }; var fragmentReference = new RelayFragmentReference( () => Relay.QL`fragment on Screenname {service, name}`, @@ -838,35 +837,36 @@ describe('readRelayQueryData', () => { it('does not clobber previously-read sibling fields when a linked dataID ' + 'is `null` or `undefined`', () => { - var query = getNode(Relay.QL` - fragment on User { - id, - address { - city, - }, - } - `); - var records = { - user_id: { - __dataID__: 'user_id', - id: 'user_id', - address: null, - }, - }; - var data = getData({records}, query, 'user_id'); - expect(data.address).toBeNull(); - expect(data.id).toBe('user_id'); - - records = { - user_id: { - __dataID__: 'user_id', - id: 'user_id', - }, - }; - data = getData({records}, query, 'user_id'); - expect(data.address).toBeUndefined(); - expect(data.id).toBe('user_id'); - }); + var query = getNode(Relay.QL` + fragment on User { + id, + address { + city, + }, + } + `); + var records = { + user_id: { + __dataID__: 'user_id', + id: 'user_id', + address: null, + }, + }; + var data = getData({records}, query, 'user_id'); + expect(data.address).toBeNull(); + expect(data.id).toBe('user_id'); + + records = { + user_id: { + __dataID__: 'user_id', + id: 'user_id', + }, + }; + data = getData({records}, query, 'user_id'); + expect(data.address).toBeUndefined(); + expect(data.id).toBe('user_id'); + } + ); it('does not set undefined value if linked dataID missing', () => { var query = getNode(Relay.QL` @@ -967,7 +967,7 @@ describe('readRelayQueryData', () => { [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - } + }, }); data = getData({records}, query, 'user_id'); expect(data.friends.count).toBe(42); @@ -1090,7 +1090,7 @@ describe('readRelayQueryData', () => { [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false, - } + }, }); // First we read the outer fragment, which populates the @@ -1197,7 +1197,7 @@ describe('readRelayQueryData', () => { [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - } + }, }); var data = getData( diff --git a/src/store/__tests__/validateRelayReadQuery-test.js b/src/store/__tests__/validateRelayReadQuery-test.js index a3c037e3d0d6c..4cd777e196ea8 100644 --- a/src/store/__tests__/validateRelayReadQuery-test.js +++ b/src/store/__tests__/validateRelayReadQuery-test.js @@ -47,7 +47,7 @@ describe('validateRelayReadQuery', () => { alias ); return true; - } + }, }); }); diff --git a/src/store/observeAllRelayQueryData.js b/src/store/observeAllRelayQueryData.js index dc1f0581e7872..52f8bfb1e1875 100644 --- a/src/store/observeAllRelayQueryData.js +++ b/src/store/observeAllRelayQueryData.js @@ -11,6 +11,9 @@ * @flow */ + /* eslint no-shadow: 1 */ + /* eslint no-unused-expressions: 1 */ + 'use strict'; import type {DataID} from 'RelayInternalTypes'; diff --git a/src/store/observeRelayQueryData.js b/src/store/observeRelayQueryData.js index c18da5d930522..518999edd1988 100644 --- a/src/store/observeRelayQueryData.js +++ b/src/store/observeRelayQueryData.js @@ -11,6 +11,8 @@ * @flow */ + /* eslint no-unused-expressions: 1 */ + 'use strict'; var GraphQLStoreChangeEmitter = require('GraphQLStoreChangeEmitter'); var RelayError = require('RelayError'); diff --git a/src/store/validateRelayReadQuery.js b/src/store/validateRelayReadQuery.js index 48782d9f78db4..4cbbc57a92061 100644 --- a/src/store/validateRelayReadQuery.js +++ b/src/store/validateRelayReadQuery.js @@ -42,7 +42,7 @@ if (__DEV__) { * At the moment, "well-formed" means that the query does not contain * duplicate aliases. */ - validateRelayReadQuery = function validateRelayReadQuery( + validateRelayReadQuery = function( queryNode: RelayQuery.Node, options?: StoreReaderOptions ): void { diff --git a/src/tools/RelayDeprecated.js b/src/tools/RelayDeprecated.js index dac63c5827046..c4b7652fa55d0 100644 --- a/src/tools/RelayDeprecated.js +++ b/src/tools/RelayDeprecated.js @@ -33,7 +33,7 @@ var RelayDeprecated = { */ warn({was, now}: { was: string, - now: string + now: string, }): void { warning(false, 'Relay: `%s` is deprecated; use `%s`.', was, now); }, @@ -44,7 +44,7 @@ var RelayDeprecated = { createWarning({was, now, adapter}: { was: string, now: string, - adapter: Function + adapter: Function, }): Function { return function() { RelayDeprecated.warn({was, now}); diff --git a/src/tools/RelayGarbageCollection.js b/src/tools/RelayGarbageCollection.js index 81536c3ff31b0..006788dcc15bd 100644 --- a/src/tools/RelayGarbageCollection.js +++ b/src/tools/RelayGarbageCollection.js @@ -63,7 +63,7 @@ var RelayGarbageCollection = { if (garbageCollector) { garbageCollector.scheduleCollection(stepLength); } - } + }, }; module.exports = RelayGarbageCollection; diff --git a/src/tools/RelayProfiler.js b/src/tools/RelayProfiler.js index 2f413811f85ef..a2bec4c6860b5 100644 --- a/src/tools/RelayProfiler.js +++ b/src/tools/RelayProfiler.js @@ -11,6 +11,8 @@ * @flow */ +/* eslint no-shadow: 1 */ + 'use strict'; var emptyFunction = require('emptyFunction'); @@ -210,7 +212,7 @@ var RelayProfiler = { profileHandler.onStop(name, state); } }); - } + }, }; } } diff --git a/src/tools/RelayTaskScheduler.js b/src/tools/RelayTaskScheduler.js index 82df23e8492b7..3de29e956d6c9 100644 --- a/src/tools/RelayTaskScheduler.js +++ b/src/tools/RelayTaskScheduler.js @@ -123,7 +123,7 @@ var RelayTaskScheduler = { }); scheduleIfNecessary(); return promise; - } + }, }; function scheduleIfNecessary(): void { diff --git a/src/tools/RelayTypes.js b/src/tools/RelayTypes.js index 072a4bfd7c04b..a09ba496e05ec 100644 --- a/src/tools/RelayTypes.js +++ b/src/tools/RelayTypes.js @@ -17,7 +17,7 @@ * Types that Relay framework users may find useful. */ import type URI from 'URI'; -import type {DataID, ClientMutationID} from 'RelayInternalTypes'; +import type {DataID} from 'RelayInternalTypes'; import type RelayMutationTransaction from 'RelayMutationTransaction'; // Routes and variables diff --git a/src/tools/__mocks__/RelayProfiler.js b/src/tools/__mocks__/RelayProfiler.js index cec1e372b3f70..ed726261225ad 100644 --- a/src/tools/__mocks__/RelayProfiler.js +++ b/src/tools/__mocks__/RelayProfiler.js @@ -32,7 +32,7 @@ var RelayProfiler = { detachAggregateHandler: jest.genMockFunction(), profile: jest.genMockFunction().mockImplementation(() => { return { - stop: jest.genMockFunction() + stop: jest.genMockFunction(), }; }), attachProfileHandler: jest.genMockFunction(), diff --git a/src/tools/__mocks__/RelayTestUtils.js b/src/tools/__mocks__/RelayTestUtils.js index 65d718b6e6d5b..1048bf8b5920a 100644 --- a/src/tools/__mocks__/RelayTestUtils.js +++ b/src/tools/__mocks__/RelayTestUtils.js @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ + /* eslint no-shadow: 1 */ + 'use strict'; /** @@ -90,7 +92,7 @@ var RelayTestUtils = { container ); return result; - } + }, }; }, @@ -354,7 +356,7 @@ var RelayTestUtils = { } var fragment = RelayQuery.Node.create( new GraphQL.QueryFragment('Test', 'Node', [ - new GraphQL.Field('__test__') + new GraphQL.Field('__test__'), ]), RelayMetaRoute.get('$RelayTestUtils'), {} @@ -380,7 +382,7 @@ var RelayTestUtils = { * when the objects match. */ toMatchQueryJSON(expected) { - var matchQueryJSON = (actual, expected, path) => { + var matchQueryJSON = (actual, expected, path) => { if (typeof actual !== 'object') { if (actual === expected) { return true; @@ -433,7 +435,7 @@ var RelayTestUtils = { return true; }; return matchQueryJSON(this.actual, expected, []); - } + }, }, unmockRelay() { diff --git a/src/tools/__mocks__/matchRecord.js b/src/tools/__mocks__/matchRecord.js index 0a8d4022e0314..b3696779a29a9 100644 --- a/src/tools/__mocks__/matchRecord.js +++ b/src/tools/__mocks__/matchRecord.js @@ -20,7 +20,7 @@ type Result = { var METADATA_KEYS = { '__dataID__': true, '__range__': true, - '__status__': true + '__status__': true, }; function matchRecord( @@ -32,7 +32,7 @@ function matchRecord( return { isMatched: actual === expected, message: 'be ' + expected + ', but got ' + actual, - path + path, }; } @@ -43,20 +43,20 @@ function matchRecord( message: ( 'be ' + expected.toString() + ', but got ' + actual.toString() ), - path + path, }; } else { return { isMatched: false, message: 'be ' + expected + ', but got ' + actual.toString(), - path + path, }; } } else if (expected instanceof GraphQLFragmentPointer) { return { isMatched: false, message: 'be ' + expected.toString() + ', but got ' + actual, - path + path, }; } @@ -67,7 +67,7 @@ function matchRecord( return { isMatched: false, message: 'not have key ' + key, - path + path, }; } } @@ -78,7 +78,7 @@ function matchRecord( return { isMatched: false, message: 'have key ' + k, - path + path, }; } if (k in METADATA_KEYS) { @@ -108,7 +108,7 @@ function matchRecord( return { isMatched: true, message: null, - path: null + path: null, }; } diff --git a/src/tools/__tests__/RelayProfiler-test.js b/src/tools/__tests__/RelayProfiler-test.js index bea72a993b8fe..5487a5faeb97d 100644 --- a/src/tools/__tests__/RelayProfiler-test.js +++ b/src/tools/__tests__/RelayProfiler-test.js @@ -69,7 +69,7 @@ describe('RelayProfiler', function() { expect(actualOrdering).toEqual([ 'beforeCallback', 'mockMethod', - 'afterCallback' + 'afterCallback', ]); }); @@ -101,7 +101,7 @@ describe('RelayProfiler', function() { '1: beforeCallback', '0: mockMethod', '1: afterCallback', - '2: afterCallback' + '2: afterCallback', ]); }); @@ -185,7 +185,7 @@ describe('RelayProfiler', function() { '1: afterCallback', '2: afterCallback', '3: afterCallback (aggregate)', - '4: afterCallback (aggregate)' + '4: afterCallback (aggregate)', ]); }); @@ -256,7 +256,7 @@ describe('RelayProfiler', function() { '2: beforeEnd', '1: beforeEnd', '1: afterEnd', - '2: afterEnd' + '2: afterEnd', ]); }); diff --git a/src/tools/__tests__/RelayTaskScheduler-test.js b/src/tools/__tests__/RelayTaskScheduler-test.js index 28cb7cfa5b758..c403e03a0903c 100644 --- a/src/tools/__tests__/RelayTaskScheduler-test.js +++ b/src/tools/__tests__/RelayTaskScheduler-test.js @@ -112,7 +112,9 @@ describe('RelayTaskScheduler', () => { RelayTaskScheduler.await( () => 'foo', - () => { throw mockError; }, + () => { + throw mockError; + }, mockCallback, ).catch(mockFailureCallback); @@ -129,7 +131,9 @@ describe('RelayTaskScheduler', () => { var mockSuccessCallback = jest.genMockFunction(); RelayTaskScheduler.await( - () => { throw mockError; }, + () => { + throw mockError; + }, ).catch(mockFailureCallback); RelayTaskScheduler.await( diff --git a/src/traversal/__tests__/checkRelayQueryData-test.js b/src/traversal/__tests__/checkRelayQueryData-test.js index c48eb7ba547e1..716d7d391af4b 100644 --- a/src/traversal/__tests__/checkRelayQueryData-test.js +++ b/src/traversal/__tests__/checkRelayQueryData-test.js @@ -17,14 +17,11 @@ RelayTestUtils.unmockRelay(); describe('checkRelayQueryData', () => { var GraphQL; var GraphQLRange; - var GraphQLStoreRangeUtils; var Relay; var RelayConnectionInterface; - var RelayQuery; var RelayRecordStore; var checkRelayQueryData; - var emptyFunction; var {getNode} = RelayTestUtils; var HAS_NEXT_PAGE, HAS_PREV_PAGE; @@ -73,7 +70,7 @@ describe('checkRelayQueryData', () => { it('returns true when node is null', () => { var records = { - 1055790163: null + 1055790163: null, }; var result = hasData(getNode( @@ -88,12 +85,12 @@ describe('checkRelayQueryData', () => { expect(result).toEqual(true); }); - it('returns true when checking basic id query', () => { + it('returns true when checking basic id query', () => { var records = { 1055790163: { id: '1055790163', __dataID__: '1055790163', - } + }, }; var result = hasData(getNode( @@ -113,7 +110,7 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - } + }, }; var result = hasData(getNode( @@ -133,7 +130,7 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - } + }, }; var result = hasData(getNode( @@ -155,7 +152,7 @@ describe('checkRelayQueryData', () => { id: '1055790163', firstName: 'Yuzhi', __dataID__: '1055790163', - } + }, }; var result = hasData(getNode( @@ -178,7 +175,7 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - } + }, }; var result = hasData(getNode( @@ -230,7 +227,7 @@ describe('checkRelayQueryData', () => { id: '1055790163', __dataID__: '1055790163', friends: { __dataID__: 'friends_id'}, - } + }, }; var result = hasData(getNode( @@ -257,7 +254,7 @@ describe('checkRelayQueryData', () => { }, friends_id: { __dataID__: 'friends_id', - } + }, }; var result = hasData(getNode( @@ -284,8 +281,8 @@ describe('checkRelayQueryData', () => { }, 'client:screenname1': { __dataID__: 'client:screenname1', - service: true - } + service: true, + }, }; var result = hasData(getNode( @@ -309,7 +306,7 @@ describe('checkRelayQueryData', () => { id: '1055790163', __dataID__: '1055790163', screennames: [{__dataID__: 'client:screenname1'}], - } + }, }; var result = hasData(getNode( @@ -336,7 +333,7 @@ describe('checkRelayQueryData', () => { }, 'client:screenname1': { __dataID__: 'client:screenname1', - } + }, }; var result = hasData(getNode( @@ -363,8 +360,8 @@ describe('checkRelayQueryData', () => { }, friends_id: { __dataID__:'friends_id', - __range__: new GraphQLRange() - } + __range__: new GraphQLRange(), + }, }; records.friends_id.__range__.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: [], @@ -397,8 +394,8 @@ describe('checkRelayQueryData', () => { }, friends_id: { __dataID__:'friends_id', - __range__: new GraphQLRange() - } + __range__: new GraphQLRange(), + }, }; records.friends_id.__range__.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: [], @@ -430,7 +427,7 @@ describe('checkRelayQueryData', () => { }, configs_id: { __dataID__: 'configs_id', - edges: [{__dataID__: 'edge_id'}] + edges: [{__dataID__: 'edge_id'}], }, edge_id: { __dataID__: 'edge_id', @@ -472,7 +469,7 @@ describe('checkRelayQueryData', () => { }, friends_id: { __dataID__:'friends_id', - __range__: new GraphQLRange() + __range__: new GraphQLRange(), }, edge_id: { __dataID__: 'edge_id', @@ -481,7 +478,7 @@ describe('checkRelayQueryData', () => { node_id: { __dataID__: 'node_id', id: 'node_id', - } + }, }; records.friends_id.__range__.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['edge_id'], @@ -514,16 +511,16 @@ describe('checkRelayQueryData', () => { }, friends_id: { __dataID__:'friends_id', - __range__: new GraphQLRange() + __range__: new GraphQLRange(), }, edge_id: { __dataID__: 'edge_id', node: {__dataID__:'node_id'}, - cursor: 'cursor' + cursor: 'cursor', }, node_id: { __dataID__: 'node_id', - } + }, }; records.friends_id.__range__.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['edge_id'], @@ -553,7 +550,7 @@ describe('checkRelayQueryData', () => { id: '1055790163', __dataID__: '1055790163', username: 'yuzhi', - } + }, }; var fragment1 = Relay.QL` diff --git a/src/traversal/__tests__/containsRelayQueryRootCall-test.js b/src/traversal/__tests__/containsRelayQueryRootCall-test.js index d116aae52d1a4..c712b14a4a6c3 100644 --- a/src/traversal/__tests__/containsRelayQueryRootCall-test.js +++ b/src/traversal/__tests__/containsRelayQueryRootCall-test.js @@ -34,7 +34,7 @@ describe('containsRelayQueryRootCall', function() { getNode(thisQuery), getNode(thatQuery) ); - } + }, }); }); diff --git a/src/traversal/__tests__/diffRelayQuery-test.js b/src/traversal/__tests__/diffRelayQuery-test.js index cac624b1a4ee8..e3e7e64d995de 100644 --- a/src/traversal/__tests__/diffRelayQuery-test.js +++ b/src/traversal/__tests__/diffRelayQuery-test.js @@ -9,24 +9,23 @@ * @emails oncall+relay */ +/* eslint no-shadow: 1 */ + 'use strict'; var RelayTestUtils = require('RelayTestUtils'); RelayTestUtils.unmockRelay(); describe('diffRelayQuery', () => { - var GraphQL; var GraphQLRange; var Relay; var RelayConnectionInterface; var RelayQuery; - var RelayQueryPath; var RelayQueryTracker; var RelayRecordStore; var diffRelayQuery; var filterRelayQuery; - var printRelayQuery; var {defer, getNode, getVerbatimNode} = RelayTestUtils; @@ -105,7 +104,7 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - name: 'Mark' + name: 'Mark', }, }; var store = new RelayRecordStore({records}); @@ -128,7 +127,7 @@ describe('diffRelayQuery', () => { __dataID__: '4', id: '4', 'profilePicture.size(32)': 'https://facebook.com', - } + }, }; var store = new RelayRecordStore({records}); var tracker = new RelayQueryTracker(); @@ -150,7 +149,7 @@ describe('diffRelayQuery', () => { __dataID__: '4', id: '4', 'profilePicture.size(32)': 'https://facebook.com', - } + }, }; var store = new RelayRecordStore({records}); var tracker = new RelayQueryTracker(); @@ -178,12 +177,12 @@ describe('diffRelayQuery', () => { var records = { 'client:viewer': { __dataID__: 'client:viewer', - actor: {__dataID__: '4808495'} + actor: {__dataID__: '4808495'}, }, '4808495': { __dataID__: '4808495', id: '4808495', - name: 'Joe' + name: 'Joe', }, }; var store = new RelayRecordStore({records}, {rootCallMap}); @@ -556,13 +555,13 @@ describe('diffRelayQuery', () => { 'client:viewer': { __dataID__: 'client:viewer', actor: { - __dataID__: 'actor' - } + __dataID__: 'actor', + }, }, 'actor': { __dataID__: 'actor', // `id` should always be fetched, but should work correctly regardless - } + }, }; store = new RelayRecordStore({records}, {rootCallMap}); tracker = new RelayQueryTracker(); @@ -606,13 +605,13 @@ describe('diffRelayQuery', () => { 'client:viewer': { __dataID__: 'client:viewer', actor: { - __dataID__: 'actor' - } + __dataID__: 'actor', + }, }, 'client:actor': { __dataID__: 'actor', - id: 'actor' - } + id: 'actor', + }, }; store = new RelayRecordStore({records}, {rootCallMap}); tracker = new RelayQueryTracker(); @@ -637,8 +636,8 @@ describe('diffRelayQuery', () => { var records = { '4': { __dataID__: '4', - id: '4' - } + id: '4', + }, }; store = new RelayRecordStore({records}); tracker = new RelayQueryTracker(); @@ -662,7 +661,7 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', friends: null, - } + }, }; var store = new RelayRecordStore({records}); var tracker = new RelayQueryTracker(); @@ -698,12 +697,12 @@ describe('diffRelayQuery', () => { var records = { 'client:viewer': { __dataID__: 'client:viewer', - actor: {__dataID__: '4808495'} + actor: {__dataID__: '4808495'}, }, '4808495': { __dataID__: '4808495', - id: '4808495' - } + id: '4808495', + }, }; var store = new RelayRecordStore({records}, {rootCallMap}); var query = getNode(Relay.QL` @@ -731,14 +730,14 @@ describe('diffRelayQuery', () => { 'client:viewer': { __dataID__: 'client:viewer', actor: { - __dataID__: '123' - } + __dataID__: '123', + }, }, '123': { __dataID__: '123', id: '123', - name: 'Name' - } + name: 'Name', + }, }; var store = new RelayRecordStore({records}, {rootCallMap}); var query = getNode(Relay.QL` @@ -799,8 +798,8 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - name: 'Mark Zuckerberg' - } + name: 'Mark Zuckerberg', + }, }; var store = new RelayRecordStore({records}); var frag = Relay.QL`fragment on Node {name}`; @@ -840,8 +839,8 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - firstName: 'Mark' - } + firstName: 'Mark', + }, }; var store = new RelayRecordStore({records}); @@ -863,8 +862,8 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - firstName: 'Mark' - } + firstName: 'Mark', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -897,8 +896,8 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - firstName: 'Mark' - } + firstName: 'Mark', + }, }; var store = new RelayRecordStore({records}); @@ -932,14 +931,14 @@ describe('diffRelayQuery', () => { __dataID__: '4', id: '4', hometown: { - __dataID__: '1234' - } + __dataID__: '1234', + }, }, '1234': { __dataID__: '1234', id: '1234', - name: 'Palo Alto, California' - } + name: 'Palo Alto, California', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -980,26 +979,26 @@ describe('diffRelayQuery', () => { actors: [ {__dataID__: '4'}, {__dataID__: '4808495'}, - {__dataID__: '1023896548'} - ] + {__dataID__: '1023896548'}, + ], }, '4': { __dataID__: '4', id: '4', name: 'Mark Zuckerberg', firstName: 'Mark', - lastName: 'Zuckerberg' + lastName: 'Zuckerberg', }, '4808495': { __dataID__: '4808495', id: '4808495', - firstName: 'Marshall' + firstName: 'Marshall', }, '1023896548': { __dataID__: '1023896548', id: '1023896548', - name: 'Laney Kuenzel' - } + name: 'Laney Kuenzel', + }, }; var store = new RelayRecordStore({records}); @@ -1067,17 +1066,17 @@ describe('diffRelayQuery', () => { id: '12345', screennames: [ {__dataID__: 'client:1'}, - {__dataID__: 'client:2'} - ] + {__dataID__: 'client:2'}, + ], }, 'client:1': { __dataID__: 'client:1', - service: 'GTALK' + service: 'GTALK', }, 'client:2': { __dataID__: 'client:2', - service: 'TWITTER' - } + service: 'TWITTER', + }, }; var store = new RelayRecordStore({records}); var expected = getNode(Relay.QL` @@ -1117,8 +1116,8 @@ describe('diffRelayQuery', () => { __dataID__: '4', id: '4', name: 'Mark Zuckerberg', - lastName: 'Zuckerberg' - } + lastName: 'Zuckerberg', + }, }; var store = new RelayRecordStore({records}); var firstNameFrag = Relay.QL` @@ -1206,8 +1205,8 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - name: 'Mark Zuckerberg' - } + name: 'Mark Zuckerberg', + }, }; var store = new RelayRecordStore({records}); @@ -1261,29 +1260,29 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - friends: {__dataID__: 'client:1'} + friends: {__dataID__: 'client:1'}, }, 'client:1': { __dataID__: 'client:1', - __range__: mockRange + __range__: mockRange, }, 'client:4:4808495': { __dataID__: 'client:4:4808495', node: {__dataID__: '4808495'}, - cursor: 'cursor1' + cursor: 'cursor1', }, '4808495': { __dataID__: '4808495', - id: '4808495' - } + id: '4808495', + }, }; var store = new RelayRecordStore({records}); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['client:4:4808495'], diffCalls: [ {name: 'after', value: 'cursor1'}, - {name: 'first', value: '4'} - ] + {name: 'first', value: '4'}, + ], }); var expected = getNode(Relay.QL` @@ -1334,31 +1333,31 @@ describe('diffRelayQuery', () => { var mockEdge = { __dataID__: 'client:4:4808495', node: {__dataID__: '4808495'}, - cursor: 'cursor1' + cursor: 'cursor1', }; var records = { '4': { __dataID__: '4', id: '4', - friends: {__dataID__: 'client:1'} + friends: {__dataID__: 'client:1'}, }, 'client:1': { __dataID__: 'client:1', - __range__: mockRange + __range__: mockRange, }, 'client:4:4808495': mockEdge, '4808495': { __dataID__: '4808495', - id: '4808495' - } + id: '4808495', + }, }; var store = new RelayRecordStore({records}); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['client:4:4808495'], diffCalls: [ {name: 'after', value: 'cursor1'}, - {name: 'first', value: '4'} - ] + {name: 'first', value: '4'}, + ], }); var expected1 = getNode(Relay.QL` @@ -1442,39 +1441,39 @@ describe('diffRelayQuery', () => { { __dataID__: 'client:4:4808495', node: {__dataID__: '4808495'}, - cursor: 'cursor1' + cursor: 'cursor1', }, { __dataID__: 'client:4:660361306', node: {__dataID__: '660361306'}, - cursor: 'cursor1' + cursor: 'cursor1', }, ]; var records = { '4': { __dataID__: '4', id: '4', - friends: {__dataID__: 'client:1'} + friends: {__dataID__: 'client:1'}, }, 'client:1': { __dataID__: 'client:1', - __range__: mockRange + __range__: mockRange, }, 'client:4:4808495': mockEdges[0], '4808495': null, 'client:4:660361306': mockEdges[1], '660361306': { __dataID__: '660361306', - id: '660361306' - } + id: '660361306', + }, }; var store = new RelayRecordStore({records}); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['client:4:4808495', 'client:4:660361306'], diffCalls: [ {name: 'after', value: 'cursor1'}, - {name: 'first', value: '4'} - ] + {name: 'first', value: '4'}, + ], }); var expected1 = getNode(Relay.QL` @@ -1557,13 +1556,13 @@ describe('diffRelayQuery', () => { var mockEdge = { __dataID__: 'client:viewer:4808495', node: {__dataID__: '4808495'}, - cursor: 'cursor1' + cursor: 'cursor1', }; var mockRange = new GraphQLRange(); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['client:viewer:4808495'], - diffCalls: null + diffCalls: null, }); var records = { @@ -1574,18 +1573,18 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - friends: {__dataID__: 'client:1'} + friends: {__dataID__: 'client:1'}, }, 'client:1': { __dataID__: 'client:1', - __range__: mockRange + __range__: mockRange, }, 'client:viewer:4808495': mockEdge, '4808495': { __dataID__: '4808495', id: '4808495', - firstName: 'Marshall' - } + firstName: 'Marshall', + }, }; var store = new RelayRecordStore({records}, {rootCallMap}); @@ -1645,27 +1644,27 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - friends: {__dataID__: 'client:1'} + friends: {__dataID__: 'client:1'}, }, 'client:1': { __dataID__: 'client:1', - __range__: mockRange + __range__: mockRange, }, 'client:4:4808495': { __dataID__: 'client:4:4808495', node: {__dataID__: '4808495'}, - cursor: 'cursor1' + cursor: 'cursor1', }, '4808495': { __dataID__: '4808495', id: '4808495', - firstName: 'Marshall' - } + firstName: 'Marshall', + }, }; var store = new RelayRecordStore({records}); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['client:4:4808495'], - diffCalls: null + diffCalls: null, }); var expected = getNode(Relay.QL` @@ -1723,29 +1722,29 @@ describe('diffRelayQuery', () => { __dataID__: 'client:4:4808495', node: {__dataID__: '4808495'}, source: {__dataID__: '4'}, - cursor: 'cursor1' + cursor: 'cursor1', }; var records = { '4': { __dataID__: '4', id: '4', name: 'Mark Zuckerberg', - friends: {__dataID__: 'client:1'} + friends: {__dataID__: 'client:1'}, }, 'client:1': { __dataID__: 'client:1', - __range__: mockRange + __range__: mockRange, }, 'client:4:4808495': mockEdge, '4808495': { __dataID__: '4808495', - id: '4808495' - } + id: '4808495', + }, }; var store = new RelayRecordStore({records}); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['client:4:4808495'], - diffCalls: null + diffCalls: null, }); var query = getNode(Relay.QL` @@ -1800,29 +1799,29 @@ describe('diffRelayQuery', () => { __dataID__: 'client:4:4808495', node: {__dataID__: '4808495'}, source: {__dataID__: '4'}, - cursor: 'cursor1' + cursor: 'cursor1', }; var records = { '4': { __dataID__: '4', id: '4', - friends: {__dataID__: 'client:1'} + friends: {__dataID__: 'client:1'}, }, 'client:1': { __dataID__: 'client:1', - __range__: mockRange + __range__: mockRange, }, 'client:4:4808495': mockEdge, '4808495': { __dataID__: '4808495', id: '4808495', - name: 'Marshall Roch' - } + name: 'Marshall Roch', + }, }; var store = new RelayRecordStore({records}); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['client:4:4808495'], - diffCalls: null + diffCalls: null, }); var expected = getNode(Relay.QL` diff --git a/src/traversal/__tests__/diffRelayQuery_connection-test.js b/src/traversal/__tests__/diffRelayQuery_connection-test.js index 5d19ab381f579..b985873bb4b17 100644 --- a/src/traversal/__tests__/diffRelayQuery_connection-test.js +++ b/src/traversal/__tests__/diffRelayQuery_connection-test.js @@ -22,7 +22,6 @@ jest describe('diffRelayQuery', () => { var Relay; var RelayConnectionInterface; - var RelayQuery; var RelayQueryTracker; var RelayRecordStore; @@ -328,231 +327,233 @@ describe('diffRelayQuery', () => { it('fetches missing `node` data via a `node()` query and missing `edges` '+ 'data via a `connection.find()` query if connection is findable', () => { - var records = {}; - var store = new RelayRecordStore({records}, {map: rootCallMap}); - var tracker = new RelayQueryTracker(); - - var alias = generateRQLFieldAlias('newsFeed.first(3)'); - var payload = { - viewer: { - [alias]: { - edges: [ - {cursor: 'c1', node: {id:'s1', message:{text:'s1'}}}, - {cursor: 'c2', node: {id:'s2', message:{text:'s1'}}}, - {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}}, - ], - [PAGE_INFO]: { - [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + var records = {}; + var store = new RelayRecordStore({records}, {map: rootCallMap}); + var tracker = new RelayQueryTracker(); + + var alias = generateRQLFieldAlias('newsFeed.first(3)'); + var payload = { + viewer: { + [alias]: { + edges: [ + {cursor: 'c1', node: {id:'s1', message:{text:'s1'}}}, + {cursor: 'c2', node: {id:'s2', message:{text:'s1'}}}, + {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}}, + ], + [PAGE_INFO]: { + [HAS_NEXT_PAGE]: true, + [HAS_PREV_PAGE]: false, + }, }, }, - }, - }; - var writeQuery = getNode(Relay.QL` - query { - viewer { - newsFeed(first:"3") { - edges { - node { - message { - text + }; + var writeQuery = getNode(Relay.QL` + query { + viewer { + newsFeed(first:"3") { + edges { + node { + message { + text + } } } } } } - } - `); - writePayload(store, writeQuery, payload, tracker); - - // node: `feedback{id}` is missing (fetch via node() query) - // edges: `sortKey` is missing (fetch via .find() query) - var fetchQuery = getNode(Relay.QL` - query { - viewer { - newsFeed(first:"3") { - edges { - sortKey, - node { - feedback { - id + `); + writePayload(store, writeQuery, payload, tracker); + + // node: `feedback{id}` is missing (fetch via node() query) + // edges: `sortKey` is missing (fetch via .find() query) + var fetchQuery = getNode(Relay.QL` + query { + viewer { + newsFeed(first:"3") { + edges { + sortKey, + node { + feedback { + id + } } } } } } - } - `); - var diffQueries = diffRelayQuery(fetchQuery, store, tracker); - expect(diffQueries.length).toBe(6); - expect(diffQueries[0]).toEqualQueryRoot(getNode(Relay.QL` - query { - node(id:"s1") { - feedback { - id + `); + var diffQueries = diffRelayQuery(fetchQuery, store, tracker); + expect(diffQueries.length).toBe(6); + expect(diffQueries[0]).toEqualQueryRoot(getNode(Relay.QL` + query { + node(id:"s1") { + feedback { + id + } } } - } - `)); - expect(diffQueries[1]).toEqualQueryRoot(getVerbatimNode(Relay.QL` - query { - viewer { - newsFeed(find:"s1") { - edges { - cursor, - node { - id - }, - sortKey, + `)); + expect(diffQueries[1]).toEqualQueryRoot(getVerbatimNode(Relay.QL` + query { + viewer { + newsFeed(find:"s1") { + edges { + cursor, + node { + id + }, + sortKey, + } } } } - } - `)); - expect(diffQueries[2]).toEqualQueryRoot(getNode(Relay.QL` - query { - node(id:"s2") { - feedback { - id + `)); + expect(diffQueries[2]).toEqualQueryRoot(getNode(Relay.QL` + query { + node(id:"s2") { + feedback { + id + } } } - } - `)); - expect(diffQueries[3]).toEqualQueryRoot(getVerbatimNode(Relay.QL` - query { - viewer { - newsFeed(find:"s2") { - edges { - cursor, - node { - id - }, - sortKey, + `)); + expect(diffQueries[3]).toEqualQueryRoot(getVerbatimNode(Relay.QL` + query { + viewer { + newsFeed(find:"s2") { + edges { + cursor, + node { + id + }, + sortKey, + } } } } - } - `)); - expect(diffQueries[4]).toEqualQueryRoot(getNode(Relay.QL` - query { - node(id:"s3") { - feedback { - id + `)); + expect(diffQueries[4]).toEqualQueryRoot(getNode(Relay.QL` + query { + node(id:"s3") { + feedback { + id + } } } - } - `)); - expect(diffQueries[5]).toEqualQueryRoot(getVerbatimNode(Relay.QL` - query { - viewer { - newsFeed(find:"s3") { - edges { - cursor, - node { - id - }, - sortKey, + `)); + expect(diffQueries[5]).toEqualQueryRoot(getVerbatimNode(Relay.QL` + query { + viewer { + newsFeed(find:"s3") { + edges { + cursor, + node { + id + }, + sortKey, + } } } } - } - `)); - }); + `)); + } + ); it('fetches missing `node` data via a `node()` query and warns about ' + 'unfetchable `edges` data if connection is not findable', () => { - var records = {}; - var store = new RelayRecordStore({records}, {map: rootCallMap}); - var tracker = new RelayQueryTracker(); - - var alias = generateRQLFieldAlias('notificationStories.first(3)'); - var payload = { - viewer: { - [alias]: { - edges: [ - {cursor: 'c1', node: {id:'s1', message:{text:'s1'}}}, - {cursor: 'c2', node: {id:'s2', message:{text:'s1'}}}, - {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}}, - ], - [PAGE_INFO]: { - [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + var records = {}; + var store = new RelayRecordStore({records}, {map: rootCallMap}); + var tracker = new RelayQueryTracker(); + + var alias = generateRQLFieldAlias('notificationStories.first(3)'); + var payload = { + viewer: { + [alias]: { + edges: [ + {cursor: 'c1', node: {id:'s1', message:{text:'s1'}}}, + {cursor: 'c2', node: {id:'s2', message:{text:'s1'}}}, + {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}}, + ], + [PAGE_INFO]: { + [HAS_NEXT_PAGE]: true, + [HAS_PREV_PAGE]: false, + }, }, }, - }, - }; - var writeQuery = getNode(Relay.QL` - query { - viewer { - notificationStories(first:"3") { - edges { - node { - message { - text + }; + var writeQuery = getNode(Relay.QL` + query { + viewer { + notificationStories(first:"3") { + edges { + node { + message { + text + } } } } } } - } - `); - writePayload(store, writeQuery, payload, tracker); - - // node: `feedback{id}` is missing (fetch via node() query) - // edges: `showBeeper` is missing but cannot be refetched because - // `notificationStories` does not support `.find()` - var fetchQuery = getNode(Relay.QL` - query { - viewer { - notificationStories(first:"3") { - edges { - showBeeper, - node { - feedback { - id + `); + writePayload(store, writeQuery, payload, tracker); + + // node: `feedback{id}` is missing (fetch via node() query) + // edges: `showBeeper` is missing but cannot be refetched because + // `notificationStories` does not support `.find()` + var fetchQuery = getNode(Relay.QL` + query { + viewer { + notificationStories(first:"3") { + edges { + showBeeper, + node { + feedback { + id + } } } } } } - } - `); - var diffQueries = diffRelayQuery(fetchQuery, store, tracker); - expect(diffQueries.length).toBe(3); - expect(diffQueries[0]).toEqualQueryRoot(getNode(Relay.QL` - query { - node(id:"s1") { - feedback { - id + `); + var diffQueries = diffRelayQuery(fetchQuery, store, tracker); + expect(diffQueries.length).toBe(3); + expect(diffQueries[0]).toEqualQueryRoot(getNode(Relay.QL` + query { + node(id:"s1") { + feedback { + id + } } } - } - `)); - expect(diffQueries[1]).toEqualQueryRoot(getNode(Relay.QL` - query { - node(id:"s2") { - feedback { - id + `)); + expect(diffQueries[1]).toEqualQueryRoot(getNode(Relay.QL` + query { + node(id:"s2") { + feedback { + id + } } } - } - `)); - expect(diffQueries[2]).toEqualQueryRoot(getNode(Relay.QL` - query { - node(id:"s3") { - feedback { - id + `)); + expect(diffQueries[2]).toEqualQueryRoot(getNode(Relay.QL` + query { + node(id:"s3") { + feedback { + id + } } } - } - `)); - expect([ - 'RelayDiffQueryBuilder: connection `edges{*}` fields can only be ' + - 'refetched if the connection supports the `find` call. Cannot ' + - 'refetch data for field `%s`.', - 'notificationStories', - ]).toBeWarnedNTimes(3); - }); + `)); + expect([ + 'RelayDiffQueryBuilder: connection `edges{*}` fields can only be ' + + 'refetched if the connection supports the `find` call. Cannot ' + + 'refetch data for field `%s`.', + 'notificationStories', + ]).toBeWarnedNTimes(3); + } + ); it('does not flatten fragments when creating new root queries', () => { var records = {}; diff --git a/src/traversal/__tests__/diffRelayQuery_scalar-test.js b/src/traversal/__tests__/diffRelayQuery_scalar-test.js index 9e03872ba6c19..2d305470875bd 100644 --- a/src/traversal/__tests__/diffRelayQuery_scalar-test.js +++ b/src/traversal/__tests__/diffRelayQuery_scalar-test.js @@ -92,8 +92,8 @@ describe('diffRelayQuery', () => { var payload = { '123': { id: '123', - firstName: 'Joe' - } + firstName: 'Joe', + }, }; writePayload(store, writeQuery, payload, tracker); diff --git a/src/traversal/__tests__/inferRelayFieldsFromData-test.js b/src/traversal/__tests__/inferRelayFieldsFromData-test.js index 15490f38f61e9..1ea5cf972d3dd 100644 --- a/src/traversal/__tests__/inferRelayFieldsFromData-test.js +++ b/src/traversal/__tests__/inferRelayFieldsFromData-test.js @@ -22,7 +22,7 @@ describe('inferRelayFieldsFromData', function() { var inferRelayFieldsFromData; var {getNode, matchers} = RelayTestUtils; - var END_CURSOR, HAS_NEXT_PAGE, HAS_PREV_PAGE, PAGE_INFO, START_CURSOR; + var HAS_NEXT_PAGE, HAS_PREV_PAGE, PAGE_INFO; beforeEach(function() { jest.resetModuleRegistry(); @@ -38,7 +38,7 @@ describe('inferRelayFieldsFromData', function() { HAS_NEXT_PAGE, HAS_PREV_PAGE, PAGE_INFO, - START_CURSOR + START_CURSOR, } = RelayConnectionInterface); jest.addMatchers({ @@ -48,7 +48,7 @@ describe('inferRelayFieldsFromData', function() { this.actual = flattenRelayQuery(expected.clone(this.actual)); // NOTE: Generated fields might get in the way. return matchers.toEqualQueryNode.call(this, expected); - } + }, }); }); @@ -106,7 +106,7 @@ describe('inferRelayFieldsFromData', function() { id: '123', screennames: [ {service: 'GTALK'}, - {service: "TWITTER"}, + {service: 'TWITTER'}, ], })).toEqualFields(Relay.QL` fragment on Actor { id, @@ -188,7 +188,7 @@ describe('inferRelayFieldsFromData', function() { node: { id: '123', name: 'name', - } + }, })).toEqualFields(Relay.QL` fragment on NodeSavedStateResponsePayload { node { id, diff --git a/src/traversal/__tests__/splitDeferredRelayQueries-test.js b/src/traversal/__tests__/splitDeferredRelayQueries-test.js index 9434f4b667d68..69d05d25030a1 100644 --- a/src/traversal/__tests__/splitDeferredRelayQueries-test.js +++ b/src/traversal/__tests__/splitDeferredRelayQueries-test.js @@ -9,6 +9,8 @@ * @emails oncall+relay */ + /* eslint no-shadow: 1 */ + 'use strict'; var RelayTestUtils = require('RelayTestUtils'); @@ -16,14 +18,11 @@ RelayTestUtils.unmockRelay(); describe('splitDeferredRelayQueries()', () => { // modules - var GraphQL; var Relay; var RelayQuery; - var RelayQueryTransform; var flattenRelayQuery; var generateRQLFieldAlias; - var printRelayQuery; var splitDeferredRelayQueries; // helper functions @@ -274,8 +273,9 @@ describe('splitDeferredRelayQueries()', () => { // field has two `node` children: // - the requisite `node{id}` // - the nested deferred fragment - expect(flattenRelayQuery(deferred[0].deferred[0].required)). - toEqualQueryRoot(flattenRelayQuery(getNode(Relay.QL` + expect( + flattenRelayQuery(deferred[0].deferred[0].required) + ).toEqualQueryRoot(flattenRelayQuery(getNode(Relay.QL` query { viewer { newsFeed { diff --git a/src/traversal/__tests__/subtractRelayQuery-test.js b/src/traversal/__tests__/subtractRelayQuery-test.js index f5a7ab8243fe9..a382646730405 100644 --- a/src/traversal/__tests__/subtractRelayQuery-test.js +++ b/src/traversal/__tests__/subtractRelayQuery-test.js @@ -504,8 +504,8 @@ describe('subtractRelayQuery', () => { `); minQuery = minQuery.clone([ minQuery.getChildren()[0].clone([ - minQuery.getChildren()[0].getChildren()[0].cloneAsRefQueryDependency() - ]) + minQuery.getChildren()[0].getChildren()[0].cloneAsRefQueryDependency(), + ]), ]); var subQuery = getNode(Relay.QL` query { diff --git a/src/traversal/__tests__/writeRelayQueryPayload_connectionField-test.js b/src/traversal/__tests__/writeRelayQueryPayload_connectionField-test.js index 9d9830c5f1b49..a9626c0e4363c 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_connectionField-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_connectionField-test.js @@ -83,8 +83,8 @@ describe('writeRelayQueryPayload()', () => { [HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false, }, - } - } + }, + }, }; var results = writePayload(store, query, payload); @@ -93,10 +93,10 @@ describe('writeRelayQueryPayload()', () => { '123': true, 'client:1': true, // `friends` connection }, - updated: {} + updated: {}, }); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 3} + {name: 'first', value: 3}, ])).toEqual({ diffCalls: [], filterCalls: [], @@ -106,7 +106,7 @@ describe('writeRelayQueryPayload()', () => { [HAS_PREV_PAGE]: false, [START_CURSOR]: undefined, }, - requestedEdges: [] + requestedEdges: [], }); }); @@ -136,8 +136,8 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123' - } + id: '123', + }, }; var alias = generateRQLFieldAlias('friends.first(3)'); payload['123'][alias] = { @@ -145,30 +145,30 @@ describe('writeRelayQueryPayload()', () => { { cursor: 'friend1', node: { - id: 'friend1ID' + id: 'friend1ID', }, source: { - id: '123' - } + id: '123', + }, }, { cursor: 'friend2', node: { - id: 'friend2ID' + id: 'friend2ID', }, source: { - id: '123' - } + id: '123', + }, }, { cursor: 'friend3', node: { - id: 'friend3ID' + id: 'friend3ID', }, source: { - id: '123' - } - } + id: '123', + }, + }, ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, @@ -187,13 +187,13 @@ describe('writeRelayQueryPayload()', () => { 'friend2ID': true, 'friend3ID': true, }, - updated: {} + updated: {}, }); expect(store.getField('friend1ID', 'id')).toBe('friend1ID'); expect(store.getField('friend2ID', 'id')).toBe('friend2ID'); expect(store.getField('friend3ID', 'id')).toBe('friend3ID'); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 3} + {name: 'first', value: 3}, ])).toEqual({ diffCalls: [], filterCalls: [], @@ -207,7 +207,7 @@ describe('writeRelayQueryPayload()', () => { {edgeID: 'client:client:1:friend1ID', nodeID: 'friend1ID'}, {edgeID: 'client:client:1:friend2ID', nodeID: 'friend2ID'}, {edgeID: 'client:client:1:friend3ID', nodeID: 'friend3ID'}, - ] + ], }); }); @@ -234,8 +234,8 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123' - } + id: '123', + }, }; var alias = generateRQLFieldAlias('friends.first(3)'); payload['123'][alias] = { @@ -248,9 +248,9 @@ describe('writeRelayQueryPayload()', () => { { cursor: 'friend3', node: { - id: 'friend3ID' + id: 'friend3ID', }, - } + }, ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, @@ -265,11 +265,11 @@ describe('writeRelayQueryPayload()', () => { 'client:client:1:friend3ID': true, // edges 'friend3ID': true, }, - updated: {} + updated: {}, }); expect(store.getField('friend3ID', 'id')).toBe('friend3ID'); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 1} + {name: 'first', value: 1}, ])).toEqual({ diffCalls: [], filterCalls: [], @@ -281,7 +281,7 @@ describe('writeRelayQueryPayload()', () => { }, requestedEdges: [ {edgeID: 'client:client:1:friend3ID', nodeID: 'friend3ID'}, - ] + ], }); }); @@ -298,8 +298,8 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - friends: {count: 5} - } + friends: {count: 5}, + }, }; writePayload(store, query, payload); @@ -326,8 +326,8 @@ describe('writeRelayQueryPayload()', () => { `); payload = { '123': { - id: '123' - } + id: '123', + }, }; var alias = generateRQLFieldAlias('friends.first(1)'); payload['123'][alias] = { @@ -335,11 +335,11 @@ describe('writeRelayQueryPayload()', () => { { cursor: 'friend1', node: { - id: 'friend1ID' + id: 'friend1ID', }, source: { - id: '123' - } + id: '123', + }, }, ], [PAGE_INFO]: { @@ -355,11 +355,11 @@ describe('writeRelayQueryPayload()', () => { }, updated: { 'client:1': true, - } + }, }); expect(store.getField('friend1ID', 'id')).toBe('friend1ID'); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 1} + {name: 'first', value: 1}, ])).toEqual({ diffCalls: [], filterCalls: [], @@ -371,7 +371,7 @@ describe('writeRelayQueryPayload()', () => { }, requestedEdges: [ {edgeID: 'client:client:1:friend1ID', nodeID: 'friend1ID'}, - ] + ], }); }); @@ -408,12 +408,12 @@ describe('writeRelayQueryPayload()', () => { { cursor: 'friend1', node: { - id: 'friend1ID' + id: 'friend1ID', }, source: { - id: '123' - } - } + id: '123', + }, + }, ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, @@ -448,16 +448,16 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123' - } + id: '123', + }, }; var alias = generateRQLFieldAlias('friends.first(1)'); payload['123'][alias] = { edges: [{ node: { - id: 'node1' + id: 'node1', }, - cursor: 'cursor1' + cursor: 'cursor1', }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, @@ -485,16 +485,16 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123' - } + id: '123', + }, }; var alias = generateRQLFieldAlias('friends.first(1).after(cursor1)'); payload['123'][alias] = { edges: [{ node: { - id: 'node2' + id: 'node2', }, - cursor: 'cursor2' + cursor: 'cursor2', }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, @@ -509,10 +509,10 @@ describe('writeRelayQueryPayload()', () => { }, updated: { 'client:1': true, // range updated - } + }, }); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 2} + {name: 'first', value: 2}, ])).toEqual({ diffCalls: [], filterCalls: [], @@ -546,17 +546,17 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123' - } + id: '123', + }, }; var alias = generateRQLFieldAlias('friends.find(node1)'); payload['123'][alias] = { edges: [{ node: { id: 'node1', - name: 'Tim' // added field + name: 'Tim', // added field }, - cursor: 'cursor1' + cursor: 'cursor1', }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, @@ -573,7 +573,7 @@ describe('writeRelayQueryPayload()', () => { }); expect(store.getField('node1', 'name')).toBe('Tim'); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 1} + {name: 'first', value: 1}, ])).toEqual({ diffCalls: [], filterCalls: [], @@ -611,8 +611,8 @@ describe('writeRelayQueryPayload()', () => { `, RelayMetaRoute.get('$RelayTest'), {}); var payload = { '123': { - id: '123' - } + id: '123', + }, }; var alias = generateRQLFieldAlias('friends.find(node1)'); payload['123'][alias] = { @@ -621,9 +621,9 @@ describe('writeRelayQueryPayload()', () => { id: 'node1', }, source: { // new edge field - id: '456' + id: '456', }, - cursor: 'cursor1' + cursor: 'cursor1', }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, @@ -641,7 +641,7 @@ describe('writeRelayQueryPayload()', () => { }, }); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 1} + {name: 'first', value: 1}, ])).toEqual({ diffCalls: [], filterCalls: [], @@ -676,16 +676,16 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123' - } + id: '123', + }, }; var alias = generateRQLFieldAlias('friends.first(1)'); payload['123'][alias] = { edges: [{ node: { - id: 'node1b' + id: 'node1b', }, - cursor: 'cursor1b' + cursor: 'cursor1b', }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, @@ -700,11 +700,11 @@ describe('writeRelayQueryPayload()', () => { }, updated: { 'client:1': true, // range updated - } + }, }); expect(store.getField('node1b', 'id')).toBe('node1b'); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 1} + {name: 'first', value: 1}, ])).toEqual({ diffCalls: [], filterCalls: [], @@ -736,16 +736,16 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123' - } + id: '123', + }, }; var alias = generateRQLFieldAlias('friends.first(1)'); payload['123'][alias] = { edges: [{ node: { - id: 'node1b' + id: 'node1b', }, - cursor: 'cursor1b' + cursor: 'cursor1b', }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, @@ -760,11 +760,11 @@ describe('writeRelayQueryPayload()', () => { }, updated: { 'client:1': true, // range updated - } + }, }); expect(store.getField('node1b', 'id')).toBe('node1b'); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 1} + {name: 'first', value: 1}, ])).toEqual({ diffCalls: [], filterCalls: [], diff --git a/src/traversal/__tests__/writeRelayQueryPayload_linkedField-test.js b/src/traversal/__tests__/writeRelayQueryPayload_linkedField-test.js index 1949d71048158..403831de23790 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_linkedField-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_linkedField-test.js @@ -176,7 +176,7 @@ describe('writeRelayQueryPayload()', () => { var payload = { viewer: { actor: { - id: actorID + id: actorID, }, }, }; @@ -198,12 +198,12 @@ describe('writeRelayQueryPayload()', () => { 'client:viewer': { __dataID__: 'client:viewer', actor: { - __dataID__: actorID - } + __dataID__: actorID, + }, }, '123': { - __dataID__: actorID - } + __dataID__: actorID, + }, }; var store = new RelayRecordStore({records}); var nextActorID = '456'; @@ -219,7 +219,7 @@ describe('writeRelayQueryPayload()', () => { var payload = { viewer: { actor: { - id: nextActorID + id: nextActorID, }, }, }; @@ -255,9 +255,9 @@ describe('writeRelayQueryPayload()', () => { id: '123', // address has no id and receives a generated client id address: { - city: 'San Francisco' - } - } + city: 'San Francisco', + }, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ @@ -279,13 +279,13 @@ describe('writeRelayQueryPayload()', () => { __dataID__: '123', id: '123', address: { - __dataID__: addressID - } + __dataID__: addressID, + }, }, 'client:1': { __dataID__: addressID, - city: 'San Francisco' - } + city: 'San Francisco', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -303,7 +303,7 @@ describe('writeRelayQueryPayload()', () => { // the address record has no id but should reuse the previously // generated client id address: { - city: 'San Francisco' + city: 'San Francisco', }, }, }; @@ -321,7 +321,7 @@ describe('writeRelayQueryPayload()', () => { 'user:1': { __dataID__: 'user:1', 'hometown': { - __dataID__: 'hometown:1' + __dataID__: 'hometown:1', }, id: 'user:1', }, @@ -344,7 +344,7 @@ describe('writeRelayQueryPayload()', () => { 'hometown': { id: 'hometown:1', name: 'World', - } + }, }, }; var results = writePayload(store, query, payload); diff --git a/src/traversal/__tests__/writeRelayQueryPayload_paths-test.js b/src/traversal/__tests__/writeRelayQueryPayload_paths-test.js index 1aebac694cb60..12b6a56781840 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_paths-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_paths-test.js @@ -82,7 +82,7 @@ describe('writePayload()', () => { 'client:viewer': true, '123': true, }, - updated: {} + updated: {}, }); // viewer has a client id and must be refetched by the original root call @@ -114,7 +114,7 @@ describe('writePayload()', () => { created: { '123': true, }, - updated: {} + updated: {}, }); expect(store.getRecordStatus('123')).toBe('EXISTENT'); diff --git a/src/traversal/__tests__/writeRelayQueryPayload_pluralLinkedField-test.js b/src/traversal/__tests__/writeRelayQueryPayload_pluralLinkedField-test.js index d8e7e75dafa1c..51e4313b4c1b4 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_pluralLinkedField-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_pluralLinkedField-test.js @@ -38,7 +38,7 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - } + }, }; var store = new RelayRecordStore({records}); @@ -57,14 +57,14 @@ describe('writeRelayQueryPayload()', () => { '123': { id: '123', allPhones: [], - } + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { '123': true, - } + }, }); var phoneIDs = store.getLinkedRecordIDs('123', 'allPhones'); expect(phoneIDs).toEqual([]); @@ -75,15 +75,15 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - } + }, }; var store = new RelayRecordStore({records}); var phone = { isVerified: true, phoneNumber: { displayNumber: '1-800-555-1212', // directory assistance - countryCode: '1' - } + countryCode: '1', + }, }; var query = getNode(Relay.QL` query { @@ -101,8 +101,8 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - allPhones: [phone] - } + allPhones: [phone], + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ @@ -112,7 +112,7 @@ describe('writeRelayQueryPayload()', () => { }, updated: { '123': true, - } + }, }); var phoneIDs = store.getLinkedRecordIDs('123', 'allPhones'); expect(phoneIDs).toEqual(['client:1']); @@ -133,36 +133,36 @@ describe('writeRelayQueryPayload()', () => { isVerified: true, phoneNumber: { displayNumber: '1-800-555-1212', - countryCode: '1' - } + countryCode: '1', + }, }; var records = { '123': { __dataID__: '123', id: '123', allPhones: [ - {__dataID__: 'client:1'} - ] + {__dataID__: 'client:1'}, + ], }, 'client:1': { isVerified: true, phoneNumber: { - __dataID__: 'client:2' - } + __dataID__: 'client:2', + }, }, 'client:2': { __dataID__: 'client:2', displayNumber: phone.phoneNumber.displayNumber, countryCode: phone.phoneNumber.countryCode, - } + }, }; var store = new RelayRecordStore({records}); var newPhone = { isVerified: true, phoneNumber: { displayNumber: '1-800-555-1212', - countryCode: '*' // *changed* - } + countryCode: '*', // *changed* + }, }; var query = getNode(Relay.QL` query { @@ -180,8 +180,8 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - allPhones: [newPhone] - } + allPhones: [newPhone], + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ @@ -189,7 +189,7 @@ describe('writeRelayQueryPayload()', () => { updated: { // intermediate phone object has no changes 'client:2': true, - } + }, }); var phoneIDs = store.getLinkedRecordIDs('123', 'allPhones'); expect(phoneIDs).toEqual(['client:1']); @@ -210,28 +210,28 @@ describe('writeRelayQueryPayload()', () => { isVerified: true, phoneNumber: { displayNumber: '1-800-555-1212', - countryCode: '1' - } + countryCode: '1', + }, }; var records = { '123': { __dataID__: '123', id: '123', allPhones: [ - {__dataID__: 'client:1'} - ] + {__dataID__: 'client:1'}, + ], }, 'client:1': { isVerified: true, phoneNumber: { - __dataID__: 'client:2' - } + __dataID__: 'client:2', + }, }, 'client:2': { __dataID__: 'client:2', displayNumber: phone.phoneNumber.displayNumber, countryCode: phone.phoneNumber.countryCode, - } + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -250,13 +250,13 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - allPhones: [phone] - } + allPhones: [phone], + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, - updated: {} + updated: {}, }); var phoneIDs = store.getLinkedRecordIDs('123', 'allPhones'); expect(phoneIDs).toEqual(['client:1']); @@ -278,7 +278,7 @@ describe('writeRelayQueryPayload()', () => { __dataID__: '123', id: '123', allPhones: [], - } + }, }; var store = new RelayRecordStore({records}); @@ -297,7 +297,7 @@ describe('writeRelayQueryPayload()', () => { '123': { id: '123', allPhones: [], - } + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ diff --git a/src/traversal/__tests__/writeRelayQueryPayload_pluralScalarField-test.js b/src/traversal/__tests__/writeRelayQueryPayload_pluralScalarField-test.js index c7211f45366a9..fa770ab826079 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_pluralScalarField-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_pluralScalarField-test.js @@ -39,8 +39,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - emailAddresses: [email] - } + emailAddresses: [email], + }, }; var store = new RelayRecordStore({records}); var newEmail = 'user2@example.com'; @@ -54,15 +54,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - emailAddresses: [newEmail] - } + emailAddresses: [newEmail], + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true - } + '123': true, + }, }); expect(store.getField('123', 'emailAddresses')).toEqual([newEmail]); }); @@ -73,8 +73,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - emailAddresses: [email] - } + emailAddresses: [email], + }, }; var store = new RelayRecordStore({records}); var newEmail = 'user2@example.com'; @@ -88,15 +88,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - emailAddresses: [newEmail, email] - } + emailAddresses: [newEmail, email], + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true - } + '123': true, + }, }); expect(store.getField('123', 'emailAddresses')) .toEqual([newEmail, email]); @@ -108,8 +108,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - emailAddresses: [email] - } + emailAddresses: [email], + }, }; var store = new RelayRecordStore({records}); var newEmail = 'user2@example.com'; @@ -123,15 +123,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - emailAddresses: [email, newEmail] - } + emailAddresses: [email, newEmail], + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true - } + '123': true, + }, }); expect(store.getField('123', 'emailAddresses')) .toEqual([email, newEmail]); @@ -143,8 +143,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - emailAddresses: [email] - } + emailAddresses: [email], + }, }; var store = new RelayRecordStore({records}); @@ -158,13 +158,13 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - emailAddresses: [email] - } + emailAddresses: [email], + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, - updated: {} + updated: {}, }); expect(store.getField('123', 'emailAddresses')).toEqual([email]); }); diff --git a/src/traversal/__tests__/writeRelayQueryPayload_rootRecord-test.js b/src/traversal/__tests__/writeRelayQueryPayload_rootRecord-test.js index b89781b07a56f..a8cba79f308ba 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_rootRecord-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_rootRecord-test.js @@ -224,8 +224,8 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123' - } + id: '123', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -330,8 +330,8 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123' - } + id: '123', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -367,13 +367,13 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123' + id: '123', }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - '123': true + '123': true, }, updated: {}, }); @@ -397,7 +397,7 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123' + id: '123', }, }; var results = writePayload(store, query, payload); @@ -413,7 +413,7 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - name: 'Joe' + name: 'Joe', }, }; var store = new RelayRecordStore({records}); @@ -428,7 +428,7 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: 'Joseph' + name: 'Joseph', }, }; var results = writePayload(store, query, payload); @@ -460,7 +460,7 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: 'Joseph' + name: 'Joseph', }, }; var results = writePayload(store, query, payload); diff --git a/src/traversal/__tests__/writeRelayQueryPayload_scalarField-test.js b/src/traversal/__tests__/writeRelayQueryPayload_scalarField-test.js index 48c2345d2d7c8..777ee6853dc81 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_scalarField-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_scalarField-test.js @@ -47,15 +47,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: null - } + name: null, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { '123': true, }, - updated: {} + updated: {}, }); expect(store.getField('123', 'name')).toBe(null); }); @@ -65,7 +65,7 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - } + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -78,15 +78,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: null - } + name: null, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { '123': true, - } + }, }); expect(store.getField('123', 'name')).toBe(null); }); @@ -96,8 +96,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - name: 'Joe' - } + name: 'Joe', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -110,15 +110,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: null - } + name: null, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { '123': true, - } + }, }); expect(store.getField('123', 'name')).toBe(null); }); @@ -136,8 +136,8 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: undefined - } + name: undefined, + }, }; writePayload(store, query, payload); expect(store.getField('123', 'id')).toBe('123'); @@ -149,7 +149,7 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - } + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -162,8 +162,8 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: undefined - } + name: undefined, + }, }; writePayload(store, query, payload); expect(store.getField('123', 'id')).toBe('123'); @@ -175,8 +175,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - name: 'Joe' - } + name: 'Joe', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -189,8 +189,8 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: undefined - } + name: undefined, + }, }; writePayload(store, query, payload); expect(store.getField('123', 'name')).toBe('Joe'); @@ -201,8 +201,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - name: 'Joe' - } + name: 'Joe', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -215,15 +215,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: 'Joseph' - } + name: 'Joseph', + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true - } + '123': true, + }, }); expect(store.getField('123', 'name')).toBe('Joseph'); }); diff --git a/src/traversal/__tests__/writeRelayUpdatePayload-test.js b/src/traversal/__tests__/writeRelayUpdatePayload-test.js index 4a375c437737e..8397d96cb2c99 100644 --- a/src/traversal/__tests__/writeRelayUpdatePayload-test.js +++ b/src/traversal/__tests__/writeRelayUpdatePayload-test.js @@ -657,7 +657,7 @@ describe('writePayload()', () => { var payload = { [RelayConnectionInterface.CLIENT_MUTATION_ID]: input[RelayConnectionInterface.CLIENT_MUTATION_ID], - deletedRequestIds: [firstRequestID, secondRequestID] + deletedRequestIds: [firstRequestID, secondRequestID], }; // write to the base store @@ -829,7 +829,7 @@ describe('writePayload()', () => { message: { text: 'Hello!', ranges: [], - } + }, }; var mutation = getNode(Relay.QL` @@ -934,7 +934,7 @@ describe('writePayload()', () => { [{name: 'first', value: '2'}] ).requestedEdges.map(edge => edge.edgeID)).toEqual([ nextEdgeID, - edgeID + edgeID, ]); // base records are not modified @@ -946,7 +946,7 @@ describe('writePayload()', () => { connectionID, [{name: 'first', value: '2'}] ).requestedEdges.map(edge => edge.edgeID)).toEqual([ - edgeID + edgeID, ]); }); @@ -959,7 +959,7 @@ describe('writePayload()', () => { message: { text: 'Hello!', ranges: [], - } + }, }; var mutation = getNode(Relay.QL` @@ -1064,7 +1064,7 @@ describe('writePayload()', () => { [{name: 'first', value: '2'}] ).requestedEdges.map(edge => edge.edgeID)).toEqual([ nextEdgeID, - edgeID + edgeID, ]); }); }); diff --git a/src/traversal/checkRelayQueryData.js b/src/traversal/checkRelayQueryData.js index ccf0125b6ce19..c7e51509fdb88 100644 --- a/src/traversal/checkRelayQueryData.js +++ b/src/traversal/checkRelayQueryData.js @@ -145,7 +145,7 @@ class RelayQueryChecker extends RelayQueryVisitor { return; } if (dataIDs) { - for (var ii = 0; ii < dataIDs.length; ii++){ + for (var ii = 0; ii < dataIDs.length; ii++) { if (!state.result) { break; } @@ -192,8 +192,8 @@ class RelayQueryChecker extends RelayQueryVisitor { return; } var edges = rangeInfo.requestedEdges; - for (var ii = 0; ii < edges.length; ii++){ - if (!state.result){ + for (var ii = 0; ii < edges.length; ii++) { + if (!state.result) { break; } var nextState = { diff --git a/src/traversal/containsRelayQueryRootCall.js b/src/traversal/containsRelayQueryRootCall.js index b821fd615f603..3b4acfc0776f6 100644 --- a/src/traversal/containsRelayQueryRootCall.js +++ b/src/traversal/containsRelayQueryRootCall.js @@ -59,7 +59,7 @@ function containsRelayQueryRootCall( var canonicalRootCalls = { 'nodes': 'node', - 'usernames': 'username' + 'usernames': 'username', }; /** diff --git a/src/traversal/diffRelayQuery.js b/src/traversal/diffRelayQuery.js index c663307f95e7c..5f22b717b6a63 100644 --- a/src/traversal/diffRelayQuery.js +++ b/src/traversal/diffRelayQuery.js @@ -11,6 +11,8 @@ * @typechecks */ + /* eslint consistent-return: 1 */ + 'use strict'; var GraphQLStoreDataHandler = require('GraphQLStoreDataHandler'); @@ -211,7 +213,7 @@ class RelayDiffQueryBuilder { return rangeInfo.diffCalls.length > 0 ? { diffNode: node, - trackedNode: null + trackedNode: null, } : null; } @@ -521,7 +523,7 @@ class RelayDiffQueryBuilder { return { diffNode, - trackedNode + trackedNode, }; } @@ -562,7 +564,7 @@ class RelayDiffQueryBuilder { if (diffNode) { var { edges: diffEdgesField, - node: diffNodeField + node: diffNodeField, } = splitNodeAndEdgesFields(diffNode); // split missing `node` fields into a `node(id)` root query diff --git a/src/traversal/flattenRelayQuery.js b/src/traversal/flattenRelayQuery.js index 40cca57ed7283..cba332cf134dc 100644 --- a/src/traversal/flattenRelayQuery.js +++ b/src/traversal/flattenRelayQuery.js @@ -65,7 +65,7 @@ class RelayQueryFlattener extends RelayQueryVisitor { if (!flattenedField) { flattenedField = { node, - flattenedFieldMap: {} + flattenedFieldMap: {}, }; state.flattenedFieldMap[serializationKey] = flattenedField; } diff --git a/src/traversal/splitDeferredRelayQueries.js b/src/traversal/splitDeferredRelayQueries.js index 7ff361a0a4045..7fefa584ca039 100644 --- a/src/traversal/splitDeferredRelayQueries.js +++ b/src/traversal/splitDeferredRelayQueries.js @@ -123,7 +123,7 @@ function wrapNode( node.getChildren(), { isDeferred: true, - rootArg: node.getRootCallArgument() + rootArg: node.getRootCallArgument(), }, node.getName() ); diff --git a/src/traversal/subtractRelayQuery.js b/src/traversal/subtractRelayQuery.js index 78ff24c8c6c1d..38fcb413cde69 100644 --- a/src/traversal/subtractRelayQuery.js +++ b/src/traversal/subtractRelayQuery.js @@ -168,7 +168,7 @@ class RelayQuerySubtractor extends RelayQueryTransform { return node.clone(node.getChildren().map(child => { var childState = { isEmpty: true, - subtrahend: state.subtrahend + subtrahend: state.subtrahend, }; var diff = this.visit(child, childState); state.isEmpty = state.isEmpty && childState.isEmpty; diff --git a/src/traversal/writeRelayUpdatePayload.js b/src/traversal/writeRelayUpdatePayload.js index 2a3a7412fc202..f6b5d656af031 100644 --- a/src/traversal/writeRelayUpdatePayload.js +++ b/src/traversal/writeRelayUpdatePayload.js @@ -326,8 +326,8 @@ function handleRangeAdd( cursor: cursor, node: { ...edge.node, - id: nodeID - } + id: nodeID, + }, }; // add the node to every connection for this field From 0b9647e4cb4fff4738b669933e05b166a33d911a Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Thu, 13 Aug 2015 23:16:22 +0100 Subject: [PATCH 02/14] remove no-shadow rule from eslint and fix code --- .eslintrc | 1 - src/__forks__/container/RelayContainerProxy.js | 2 -- src/container/RelayContainer.js | 1 - src/store/__mocks__/observeAllRelayQueryData.js | 3 +-- src/store/__mocks__/observeRelayQueryData.js | 3 +-- src/store/__tests__/RelayStoreGarbageCollector-test.js | 2 -- src/store/__tests__/observeAllRelayQueryData-test.js | 2 -- src/store/observeAllRelayQueryData.js | 1 - src/tools/RelayProfiler.js | 2 -- src/tools/__mocks__/RelayTestUtils.js | 2 -- src/traversal/__tests__/diffRelayQuery-test.js | 2 -- src/traversal/__tests__/splitDeferredRelayQueries-test.js | 2 -- src/traversal/diffRelayQuery.js | 4 +--- 13 files changed, 3 insertions(+), 24 deletions(-) diff --git a/.eslintrc b/.eslintrc index 72601abdc8adb..e64b20a7cb608 100644 --- a/.eslintrc +++ b/.eslintrc @@ -41,7 +41,6 @@ rules: consistent-return: 2 no-unused-vars: [2, args: none] quotes: [2, single, avoid-escape] - no-shadow: 2 no-multi-spaces: 2 # WISHLIST. One day... diff --git a/src/__forks__/container/RelayContainerProxy.js b/src/__forks__/container/RelayContainerProxy.js index 12be926316075..d05646643e859 100644 --- a/src/__forks__/container/RelayContainerProxy.js +++ b/src/__forks__/container/RelayContainerProxy.js @@ -11,8 +11,6 @@ * @flow */ - /* eslint no-shadow: 1 */ - 'use strict'; import type {RelayContainer} from 'RelayTypes'; diff --git a/src/container/RelayContainer.js b/src/container/RelayContainer.js index 6621d249c584c..06a05338fb0da 100644 --- a/src/container/RelayContainer.js +++ b/src/container/RelayContainer.js @@ -11,7 +11,6 @@ * @flow */ -/* eslint no-shadow: 1 */ /* eslint no-unused-expressions: 1 */ 'use strict'; diff --git a/src/store/__mocks__/observeAllRelayQueryData.js b/src/store/__mocks__/observeAllRelayQueryData.js index 900729d3ebdcd..7fc015f3d7f49 100644 --- a/src/store/__mocks__/observeAllRelayQueryData.js +++ b/src/store/__mocks__/observeAllRelayQueryData.js @@ -7,9 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - /* eslint no-shadow: 1 */ - 'use strict'; + var actualImplementation = require.requireActual('observeAllRelayQueryData'); var mockImplementation = jest.genMockFunction().mockImplementation( diff --git a/src/store/__mocks__/observeRelayQueryData.js b/src/store/__mocks__/observeRelayQueryData.js index 16cb136ce3ffa..1d9eb07797a13 100644 --- a/src/store/__mocks__/observeRelayQueryData.js +++ b/src/store/__mocks__/observeRelayQueryData.js @@ -7,9 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - /* eslint no-shadow: 1 */ - 'use strict'; + var actualImplementation = require.requireActual('observeRelayQueryData'); var mockImplementation = jest.genMockFunction().mockImplementation( diff --git a/src/store/__tests__/RelayStoreGarbageCollector-test.js b/src/store/__tests__/RelayStoreGarbageCollector-test.js index 7b860332a32da..4472eb7df26a4 100644 --- a/src/store/__tests__/RelayStoreGarbageCollector-test.js +++ b/src/store/__tests__/RelayStoreGarbageCollector-test.js @@ -9,8 +9,6 @@ * @emails oncall+relay */ -/* eslint no-shadow: 1 */ - 'use strict'; jest diff --git a/src/store/__tests__/observeAllRelayQueryData-test.js b/src/store/__tests__/observeAllRelayQueryData-test.js index 6689ce7c2760f..e8eeb9f90fd62 100644 --- a/src/store/__tests__/observeAllRelayQueryData-test.js +++ b/src/store/__tests__/observeAllRelayQueryData-test.js @@ -9,8 +9,6 @@ * @emails oncall+relay */ - /* eslint no-shadow: 1 */ - 'use strict'; var RelayTestUtils = require('RelayTestUtils'); diff --git a/src/store/observeAllRelayQueryData.js b/src/store/observeAllRelayQueryData.js index 52f8bfb1e1875..7b6f67d72133b 100644 --- a/src/store/observeAllRelayQueryData.js +++ b/src/store/observeAllRelayQueryData.js @@ -11,7 +11,6 @@ * @flow */ - /* eslint no-shadow: 1 */ /* eslint no-unused-expressions: 1 */ 'use strict'; diff --git a/src/tools/RelayProfiler.js b/src/tools/RelayProfiler.js index a2bec4c6860b5..a12cbf2d0a3b4 100644 --- a/src/tools/RelayProfiler.js +++ b/src/tools/RelayProfiler.js @@ -11,8 +11,6 @@ * @flow */ -/* eslint no-shadow: 1 */ - 'use strict'; var emptyFunction = require('emptyFunction'); diff --git a/src/tools/__mocks__/RelayTestUtils.js b/src/tools/__mocks__/RelayTestUtils.js index 1048bf8b5920a..a827d51a2c811 100644 --- a/src/tools/__mocks__/RelayTestUtils.js +++ b/src/tools/__mocks__/RelayTestUtils.js @@ -7,8 +7,6 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - /* eslint no-shadow: 1 */ - 'use strict'; /** diff --git a/src/traversal/__tests__/diffRelayQuery-test.js b/src/traversal/__tests__/diffRelayQuery-test.js index e3e7e64d995de..043755c9132a2 100644 --- a/src/traversal/__tests__/diffRelayQuery-test.js +++ b/src/traversal/__tests__/diffRelayQuery-test.js @@ -9,8 +9,6 @@ * @emails oncall+relay */ -/* eslint no-shadow: 1 */ - 'use strict'; var RelayTestUtils = require('RelayTestUtils'); diff --git a/src/traversal/__tests__/splitDeferredRelayQueries-test.js b/src/traversal/__tests__/splitDeferredRelayQueries-test.js index 69d05d25030a1..107f1076e9ddc 100644 --- a/src/traversal/__tests__/splitDeferredRelayQueries-test.js +++ b/src/traversal/__tests__/splitDeferredRelayQueries-test.js @@ -9,8 +9,6 @@ * @emails oncall+relay */ - /* eslint no-shadow: 1 */ - 'use strict'; var RelayTestUtils = require('RelayTestUtils'); diff --git a/src/traversal/diffRelayQuery.js b/src/traversal/diffRelayQuery.js index 5f22b717b6a63..4b0a34d45a280 100644 --- a/src/traversal/diffRelayQuery.js +++ b/src/traversal/diffRelayQuery.js @@ -11,8 +11,6 @@ * @typechecks */ - /* eslint consistent-return: 1 */ - 'use strict'; var GraphQLStoreDataHandler = require('GraphQLStoreDataHandler'); @@ -549,7 +547,7 @@ class RelayDiffQueryBuilder { '`%s`.', connectionField.getStorageKey() ); - return; + return {}; } var hasSplitQueries = false; From e8920fbfeea7e9074218234233a3dd775e35ffd3 Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Fri, 14 Aug 2015 12:10:00 +0100 Subject: [PATCH 03/14] fix comma-dangle in code --- .eslintignore | 1 + .eslintrc | 2 +- src/RelayPublic.js | 2 +- src/__forks__/Relay.js | 2 +- .../container/RelayContainerProxy.js | 2 +- .../interface/RelayConnectionInterface.js | 6 +- src/__forks__/interface/RelayNodeInterface.js | 2 +- .../interface/__mocks__/RelayNodeInterface.js | 2 +- .../__tests__/printRelayQuery-test.js | 12 +- src/container/RelayContainer.js | 22 +- src/container/RelayContainerComparators.js | 2 +- src/container/RelayPropTypes.js | 4 +- src/container/RelayRootContainer.js | 16 +- .../__tests__/RelayContainer-test.js | 64 +-- .../RelayContainer_Component-test.js | 6 +- .../RelayContainer_hasFragmentData-test.js | 4 +- ...RelayContainer_hasOptimisticUpdate-test.js | 2 +- .../RelayContainer_setVariables-test.js | 64 +-- .../__tests__/RelayRootContainer-test.js | 52 +-- .../__tests__/getRelayQueries-test.js | 16 +- .../__tests__/isRelayContainer-test.js | 4 +- .../mutation/GraphQLMutatorConstants.js | 2 +- src/legacy/query/GraphQL_EXPERIMENTAL.js | 32 +- src/legacy/store/DliteFetchModeConstants.js | 2 +- .../store/GraphQLDeferredQueryTracker.js | 8 +- src/legacy/store/GraphQLQueryRunner.js | 8 +- src/legacy/store/GraphQLRange.js | 36 +- src/legacy/store/GraphQLSegment.js | 22 +- src/legacy/store/GraphQLStoreChangeEmitter.js | 6 +- src/legacy/store/GraphQLStoreDataHandler.js | 4 +- src/legacy/store/GraphQLStoreQueryResolver.js | 2 +- src/legacy/store/GraphQLStoreRangeUtils.js | 4 +- .../store/__mocks__/GraphQLQueryRunner.js | 6 +- .../__mocks__/GraphQLStoreQueryResolver.js | 4 +- .../store/__mocks__/GraphQLStoreTestUtils.js | 6 +- .../GraphQLDeferredQueryTracker-test.js | 4 +- .../__tests__/GraphQLFragmentPointer-test.js | 2 +- .../__tests__/GraphQLQueryRunner-test.js | 58 +-- .../store/__tests__/GraphQLRange-test.js | 414 +++++++++--------- .../store/__tests__/GraphQLSegment-test.js | 44 +- .../GraphQLStoreQueryResolver-test.js | 28 +- src/mutation/RelayMutation.js | 4 +- src/mutation/RelayMutationQuery.js | 18 +- src/mutation/RelayMutationTransaction.js | 8 +- .../RelayMutationTransactionStatus.js | 2 +- src/mutation/RelayMutationType.js | 2 +- src/mutation/__tests__/RelayMutation-test.js | 6 +- .../__tests__/RelayMutationQuery-test.js | 106 ++--- .../RelayMutationTransaction-test.js | 12 +- .../default/RelayDefaultNetworkLayer.js | 12 +- .../RelayDefaultNetworkLayer-test.js | 52 +-- src/network/RelayNetworkLayer.js | 2 +- src/network/__mocks__/fetchRelayQuery.js | 2 +- .../__tests__/RelayNetworkLayer-test.js | 2 +- src/query/RelayQL.js | 2 +- src/query/RelayQuery.js | 6 +- src/query/RelayQueryPath.js | 2 +- src/query/RelayQuerySerializer.js | 10 +- .../__tests__/RelayFragmentReference-test.js | 16 +- .../RelayQuery-getCallsWithValues-test.js | 48 +- src/query/__tests__/RelayQuery-test.js | 76 ++-- src/query/__tests__/RelayQueryPath-test.js | 26 +- .../__tests__/RelayQuerySerializer-test.js | 68 +-- .../__tests__/RelayQueryTransform-test.js | 2 +- src/query/__tests__/RelayQueryVisitor-test.js | 2 +- src/query/__tests__/buildRQL-test.js | 10 +- src/query/__tests__/callsToGraphQL-test.js | 8 +- src/query/__tests__/stableStringify-test.js | 8 +- src/query/__tests__/toGraphQL-test.js | 6 +- src/query/buildRQL.js | 2 +- src/query/fromGraphQL.js | 4 +- src/query/toGraphQL.js | 6 +- src/route/RelayMetaRoute.js | 2 +- src/route/RelayRoute.js | 12 +- src/route/__tests__/RelayRoute-test.js | 8 +- src/store/RelayBufferedNeglectionStateMap.js | 8 +- src/store/RelayChangeTracker.js | 4 +- src/store/RelayMutationTracker.js | 2 +- src/store/RelayNeglectionStateMap.js | 4 +- src/store/RelayPendingQueryTracker.js | 4 +- src/store/RelayQueryTracker.js | 2 +- src/store/RelayQueryWriter.js | 14 +- src/store/RelayRecordStatus.js | 2 +- src/store/RelayRecordStore.js | 20 +- src/store/RelayStore.js | 2 +- src/store/RelayStoreData.js | 6 +- src/store/RelayStoreGarbageCollector.js | 6 +- .../RelayBufferedNeglectionStateMap.js | 2 +- src/store/__mocks__/RelayMockCacheManager.js | 4 +- .../__mocks__/RelayNeglectionStateMap.js | 2 +- src/store/__mocks__/RelayStore.js | 8 +- .../__tests__/RelayNeglectionStateMap-test.js | 4 +- .../RelayPendingQueryTracker-test.js | 12 +- src/store/__tests__/RelayRecordStore-test.js | 190 ++++---- .../__tests__/RelayRecordStore_write-test.js | 58 +-- src/store/__tests__/RelayStoreData-test.js | 42 +- .../RelayStoreData_cacheManager-test.js | 180 ++++---- .../RelayStoreGarbageCollector-test.js | 50 +-- .../__tests__/filterExclusiveKeys-test.js | 10 +- .../observeAllRelayQueryData-test.js | 36 +- .../__tests__/observeRelayQueryData-test.js | 36 +- .../__tests__/readRelayQueryData-test.js | 368 ++++++++-------- .../__tests__/validateRelayReadQuery-test.js | 2 +- src/store/filterExclusiveKeys.js | 2 +- src/store/observeAllRelayQueryData.js | 8 +- src/store/observeRelayQueryData.js | 4 +- src/store/readRelayQueryData.js | 12 +- src/tools/RelayDeprecated.js | 14 +- src/tools/RelayError.js | 2 +- src/tools/RelayGarbageCollection.js | 2 +- src/tools/RelayProfiler.js | 4 +- src/tools/RelayTaskScheduler.js | 2 +- src/tools/__mocks__/RelayProfiler.js | 4 +- src/tools/__mocks__/RelayTestUtils.js | 14 +- src/tools/__mocks__/matchRecord.js | 16 +- src/tools/__tests__/RelayProfiler-test.js | 18 +- .../__tests__/checkRelayQueryData-test.js | 108 ++--- .../containsRelayQueryRootCall-test.js | 2 +- .../__tests__/diffRelayQuery-test.js | 266 +++++------ .../diffRelayQuery_connection-test.js | 76 ++-- .../__tests__/diffRelayQuery_scalar-test.js | 4 +- .../flattenSplitRelayQueries-test.js | 28 +- .../inferRelayFieldsFromData-test.js | 42 +- .../__tests__/printRelayQueryCall-test.js | 20 +- .../__tests__/refragmentRelayQuery-test.js | 2 +- .../splitDeferredRelayQueries-test.js | 4 +- .../__tests__/subtractRelayQuery-test.js | 4 +- ...eRelayQueryPayload_connectionField-test.js | 280 ++++++------ ...writeRelayQueryPayload_linkedField-test.js | 114 ++--- .../writeRelayQueryPayload_paths-test.js | 144 +++--- ...elayQueryPayload_pluralLinkedField-test.js | 90 ++-- ...elayQueryPayload_pluralScalarField-test.js | 46 +- .../writeRelayQueryPayload_rootRecord-test.js | 118 ++--- ...writeRelayQueryPayload_scalarField-test.js | 64 +-- .../__tests__/writeRelayUpdatePayload-test.js | 218 ++++----- src/traversal/checkRelayQueryData.js | 12 +- src/traversal/containsRelayQueryRootCall.js | 2 +- src/traversal/diffRelayQuery.js | 30 +- src/traversal/flattenRelayQuery.js | 2 +- src/traversal/inferRelayFieldsFromData.js | 2 +- src/traversal/splitDeferredRelayQueries.js | 8 +- src/traversal/subtractRelayQuery.js | 8 +- src/traversal/writeRelayUpdatePayload.js | 6 +- 143 files changed, 2205 insertions(+), 2206 deletions(-) diff --git a/.eslintignore b/.eslintignore index 9e7436c5c2d20..097fc6005174d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,3 +7,4 @@ scripts/ # for disable website but should be done as well website/ *.md +eslint-rules/ diff --git a/.eslintrc b/.eslintrc index e64b20a7cb608..c24006e1d6014 100644 --- a/.eslintrc +++ b/.eslintrc @@ -31,7 +31,7 @@ rules: brace-style: 2 space-after-keywords: 2 strict: [2, global] - comma-dangle: [2, always-multiline] + comma-dangle: [2, never] # Make this a warning for now. We do this in a few places so we might need to # disable no-unused-expressions: 2 diff --git a/src/RelayPublic.js b/src/RelayPublic.js index a90ad366f6ebe..dfdfd840473cf 100644 --- a/src/RelayPublic.js +++ b/src/RelayPublic.js @@ -42,7 +42,7 @@ var RelayPublic = { getQueries: getRelayQueries, injectNetworkLayer: RelayNetworkLayer.injectNetworkLayer, injectTaskScheduler: RelayTaskScheduler.injectScheduler, - isContainer: isRelayContainer, + isContainer: isRelayContainer }; module.exports = RelayPublic; diff --git a/src/__forks__/Relay.js b/src/__forks__/Relay.js index 8b0c2e8e6a6e0..324d941895c0f 100644 --- a/src/__forks__/Relay.js +++ b/src/__forks__/Relay.js @@ -22,5 +22,5 @@ RelayPublic.injectNetworkLayer(new RelayDefaultNetworkLayer('/graphql')); module.exports = { ...RelayPublic, // Expose the default network layer to allow convenient re-configuration. - DefaultNetworkLayer: RelayDefaultNetworkLayer, + DefaultNetworkLayer: RelayDefaultNetworkLayer }; diff --git a/src/__forks__/container/RelayContainerProxy.js b/src/__forks__/container/RelayContainerProxy.js index d05646643e859..7e49fc8327d48 100644 --- a/src/__forks__/container/RelayContainerProxy.js +++ b/src/__forks__/container/RelayContainerProxy.js @@ -22,7 +22,7 @@ var RelayContainerProxy = { proxyMethods( RelayContainer: RelayContainer, Component: ReactClass - ): void {}, + ): void {} }; module.exports = RelayContainerProxy; diff --git a/src/__forks__/interface/RelayConnectionInterface.js b/src/__forks__/interface/RelayConnectionInterface.js index 835871afd0586..2beed348acf34 100644 --- a/src/__forks__/interface/RelayConnectionInterface.js +++ b/src/__forks__/interface/RelayConnectionInterface.js @@ -21,12 +21,12 @@ var CONNECTION_CALLS = { 'find': true, 'first': true, 'last': true, - 'surrounds': true, + 'surrounds': true }; var REQUIRED_RANGE_CALLS = { 'find': true, 'first': true, - 'last': true, + 'last': true }; /** @@ -77,7 +77,7 @@ var RelayConnectionInterface = { pageInfo[RelayConnectionInterface.HAS_NEXT_PAGE] = false; pageInfo[RelayConnectionInterface.HAS_PREV_PAGE] = false; return pageInfo; - }, + } }; module.exports = RelayConnectionInterface; diff --git a/src/__forks__/interface/RelayNodeInterface.js b/src/__forks__/interface/RelayNodeInterface.js index fcb36b4fcd245..db660df3bcba7 100644 --- a/src/__forks__/interface/RelayNodeInterface.js +++ b/src/__forks__/interface/RelayNodeInterface.js @@ -94,7 +94,7 @@ var RelayNodeInterface = { } return results; - }, + } }; function getPayloadRecords( diff --git a/src/__forks__/interface/__mocks__/RelayNodeInterface.js b/src/__forks__/interface/__mocks__/RelayNodeInterface.js index cda7eb1a36455..6e4867d38dc9f 100644 --- a/src/__forks__/interface/__mocks__/RelayNodeInterface.js +++ b/src/__forks__/interface/__mocks__/RelayNodeInterface.js @@ -91,7 +91,7 @@ var RelayNodeInterface = { } return results; - }, + } }; function getBatchCallResult( diff --git a/src/__forks__/traversal/__tests__/printRelayQuery-test.js b/src/__forks__/traversal/__tests__/printRelayQuery-test.js index 2341538067a16..84200f03076a3 100644 --- a/src/__forks__/traversal/__tests__/printRelayQuery-test.js +++ b/src/__forks__/traversal/__tests__/printRelayQuery-test.js @@ -149,7 +149,7 @@ describe('printRelayQuery', () => { }, } `, { - env: value, + env: value }); expect(printRelayQuery(query)).toEqual(trimQuery(` query FooQuery { @@ -169,7 +169,7 @@ describe('printRelayQuery', () => { } } `, { - q: value, + q: value }); expect(printRelayQuery(query)).toEqual(trimQuery(` @@ -187,12 +187,12 @@ describe('printRelayQuery', () => { new GraphQL.BatchCallVariable('q0', '$.*.actor.id'), [ RelayQuery.Node.buildField('id'), - RelayQuery.Node.buildField('name'), + RelayQuery.Node.buildField('name') ], { isDeferred: true, rootArg: RelayNodeInterface.ID, - type: RelayNodeInterface.NODE_TYPE, + type: RelayNodeInterface.NODE_TYPE }, 'RefQueryName' ); @@ -327,7 +327,7 @@ describe('printRelayQuery', () => { var alias = generateRQLFieldAlias('profilePicture.size(32,64)'); var variables = { height: 64, - width: 32, + width: 32 }; var fragment = getNode(Relay.QL` fragment on Actor { @@ -364,7 +364,7 @@ describe('printRelayQuery', () => { `, { first: 10, orderby: ['name'], - isViewerFriend: false, + isViewerFriend: false }); var alias = fragment.getChildren()[0].getSerializationKey(); expect(printRelayQuery(fragment)).toEqual(trimQuery(` diff --git a/src/container/RelayContainer.js b/src/container/RelayContainer.js index 06a05338fb0da..674c922bb734f 100644 --- a/src/container/RelayContainer.js +++ b/src/container/RelayContainer.js @@ -80,7 +80,7 @@ GraphQLStoreChangeEmitter.injectBatchingStrategy( ); var containerContextTypes = { - route: RelayPropTypes.QueryConfig.isRequired, + route: RelayPropTypes.QueryConfig.isRequired }; var nextContainerID = 0; @@ -163,7 +163,7 @@ function createContainerComponent( this.pending = null; this.state = { variables: {}, - queryData: {}, + queryData: {} }; } @@ -258,7 +258,7 @@ function createContainerComponent( var completeProfiler = RelayProfiler.profile( 'RelayContainer.setVariables', { containerName, - nextVariables, + nextVariables } ); @@ -318,7 +318,7 @@ function createContainerComponent( variables: nextVariables, request: forceFetch ? RelayStore.forceFetch(querySet, onReadyStateChange) : - RelayStore.primeCache(querySet, onReadyStateChange), + RelayStore.primeCache(querySet, onReadyStateChange) }; this.pending = current; } @@ -450,7 +450,7 @@ function createContainerComponent( fragmentID, { onSuccess: this._handleDeferredSuccess.bind(this), - onFailure: this._handleDeferredFailure.bind(this), + onFailure: this._handleDeferredFailure.bind(this) } ); } @@ -476,7 +476,7 @@ function createContainerComponent( this.setState({ queryData, - variables, + variables }); } @@ -495,7 +495,7 @@ function createContainerComponent( this._updateQueryResolvers(); return { variables, - queryData: this._getQueryData(nextProps), + queryData: this._getQueryData(nextProps) }; }); @@ -778,7 +778,7 @@ function createContainerComponent( hasOptimisticUpdate: this.hasOptimisticUpdate, route: this.context.route, setVariables: this.setVariables, - variables: this.state.variables, + variables: this.state.variables }; return ( Relay.QL`fragment on Node @relay(plural:true){id,name}` - ), - }, + ) + } }); MockContainer.mock = {render}; @@ -100,8 +100,8 @@ describe('RelayContainer', function() { it('throws if container defines invalid `Relay.QL` fragment', () => { var BadContainer = Relay.createContainer(MockComponent, { fragments: { - viewer: () => Relay.QL`query{node(id:"123"){id}}`, - }, + viewer: () => Relay.QL`query{node(id:"123"){id}}` + } }); var badFragmentReference = BadContainer.getFragment('viewer'); expect(() => { @@ -118,7 +118,7 @@ describe('RelayContainer', function() { var TEST_PHOTO_SIZE = 100; var MockProfilePhoto = Relay.createContainer(MockComponent, { initialVariables: { - testPhotoSize: TEST_PHOTO_SIZE, + testPhotoSize: TEST_PHOTO_SIZE }, fragments: { photo: variables => Relay.QL` @@ -127,8 +127,8 @@ describe('RelayContainer', function() { uri } } - `, - }, + ` + } }); var fragment = getNode( MockProfilePhoto.getQuery('photo'), @@ -144,7 +144,7 @@ describe('RelayContainer', function() { ), new GraphQL.Field( 'id', null, null, null, null, null, {generated: true} - ), + ) ]) )); }); @@ -159,8 +159,8 @@ describe('RelayContainer', function() { name, ${MockProfileLink.getQuery('user')} } - `, - }, + ` + } }); var MockProfileLink = Relay.createContainer(anotherComponent, { fragments: { @@ -169,8 +169,8 @@ describe('RelayContainer', function() { id, url } - `, - }, + ` + } }); var fragment = getNode( MockProfile.getQuery('user'), @@ -179,12 +179,12 @@ describe('RelayContainer', function() { expect(fragment).toEqualQueryNode(getNode( new GraphQL.QueryFragment('Test', 'Actor', [ new GraphQL.Field('id'), - new GraphQL.Field('name'), + new GraphQL.Field('name') ], [ new GraphQL.QueryFragment('Test', 'Actor', [ new GraphQL.Field('id'), - new GraphQL.Field('url'), - ]), + new GraphQL.Field('url') + ]) ]) )); }); @@ -201,34 +201,34 @@ describe('RelayContainer', function() { fragment on Viewer { newsFeed, } - `, - }, + ` + } }); sideshowFragment = new GraphQL.QueryFragment('Test', 'Viewer'); feedFragment = new GraphQL.QueryFragment('Test', 'Viewer', [ - new GraphQL.Field('newsFeed'), + new GraphQL.Field('newsFeed') ]); }); it('can conditionally include a fragment based on variables', () => { var MockSideshow = Relay.createContainer(MockComponent, { initialVariables: { - hasSideshow: null, + hasSideshow: null }, fragments: { viewer: variables => Relay.QL` fragment on Viewer { ${MockFeed.getQuery('viewer').if(variables.hasSideshow)}, } - `, - }, + ` + } }); // hasSideshow: true var fragment = getNode( MockSideshow.getQuery('viewer', { - hasSideshow: new GraphQL.CallVariable('sideshow'), + hasSideshow: new GraphQL.CallVariable('sideshow') }), {sideshow: true} ); @@ -242,7 +242,7 @@ describe('RelayContainer', function() { // hasSideshow: false fragment = getNode( MockSideshow.getQuery('viewer', { - hasSideshow: new GraphQL.CallVariable('sideshow'), + hasSideshow: new GraphQL.CallVariable('sideshow') }), {sideshow: false} ); @@ -252,7 +252,7 @@ describe('RelayContainer', function() { it('can conditionally exclude a fragment based on variables', () => { var MockSideshow = Relay.createContainer(MockComponent, { initialVariables: { - hasSideshow: null, + hasSideshow: null }, fragments: { viewer: variables => Relay.QL` @@ -261,8 +261,8 @@ describe('RelayContainer', function() { .getQuery('viewer') .unless(variables.hasSideshow)}, } - `, - }, + ` + } }); // hasSideshow: true @@ -422,7 +422,7 @@ describe('RelayContainer', function() { 'you are purposely passing in mock data that conforms to ' + 'the shape of this component\'s fragment.', 'foo', - 'MockComponent', + 'MockComponent' ]).toBeWarnedNTimes(1); }); @@ -443,7 +443,7 @@ describe('RelayContainer', function() { 'a prop from the parent. Pass an explicit `null` if this is ' + 'intentional.', 'bar', - 'MockComponent', + 'MockComponent' ]).toBeWarnedNTimes(1); }); @@ -509,7 +509,7 @@ describe('RelayContainer', function() { it('re-renders if props resolve to different objects', () => { var mockDataList = [ {__dataID__: '42', id: '42', name: 'Tim', ...mockFooPointer}, - {__dataID__: '42', id: '42', name: 'Tee', ...mockFooPointer}, + {__dataID__: '42', id: '42', name: 'Tee', ...mockFooPointer} ]; GraphQLStoreQueryResolver.mockResolveImplementation(0, function() { @@ -538,7 +538,7 @@ describe('RelayContainer', function() { var mockDataSet = { '42': {__dataID__: '42', name: 'Tim'}, '43': {__dataID__: '43', name: 'Tee'}, - '44': {__dataID__: '44', name: 'Toe'}, + '44': {__dataID__: '44', name: 'Toe'} }; var render = jest.genMockFunction().mockImplementation(() =>
); var shouldComponentUpdate = jest.genMockFunction(); @@ -549,8 +549,8 @@ describe('RelayContainer', function() { fragments: { foo: jest.genMockFunction().mockImplementation( () => Relay.QL`fragment on Node{id,name}` - ), - }, + ) + } }); GraphQLStoreQueryResolver.mockResolveImplementation(0, (pointer) => { diff --git a/src/container/__tests__/RelayContainer_Component-test.js b/src/container/__tests__/RelayContainer_Component-test.js index c5e2681910620..565fa2f3dedac 100644 --- a/src/container/__tests__/RelayContainer_Component-test.js +++ b/src/container/__tests__/RelayContainer_Component-test.js @@ -37,7 +37,7 @@ describe('RelayContainer', function() { reactComponentExpect = require('reactComponentExpect'); MockComponent = React.createClass({ - render: jest.genMockFunction().mockImplementation(() =>
), + render: jest.genMockFunction().mockImplementation(() =>
) }); mockCreateContainer = component => { @@ -46,8 +46,8 @@ describe('RelayContainer', function() { fragments: { foo: jest.genMockFunction().mockImplementation( variables => Relay.QL`fragment on Node{id,url(site:$site)}` - ), - }, + ) + } }); }; diff --git a/src/container/__tests__/RelayContainer_hasFragmentData-test.js b/src/container/__tests__/RelayContainer_hasFragmentData-test.js index eff8df66c1e0c..e546fb4839b6f 100644 --- a/src/container/__tests__/RelayContainer_hasFragmentData-test.js +++ b/src/container/__tests__/RelayContainer_hasFragmentData-test.js @@ -41,8 +41,8 @@ describe('RelayContainer.hasFragmentData', function() { fragments: { foo: jest.genMockFunction().mockImplementation( variables => Relay.QL`fragment on Node{id,url(site:$site)}` - ), - }, + ) + } }); MockContainer.mock = {render}; diff --git a/src/container/__tests__/RelayContainer_hasOptimisticUpdate-test.js b/src/container/__tests__/RelayContainer_hasOptimisticUpdate-test.js index 5e6e95919b395..1e65fa1489e37 100644 --- a/src/container/__tests__/RelayContainer_hasOptimisticUpdate-test.js +++ b/src/container/__tests__/RelayContainer_hasOptimisticUpdate-test.js @@ -39,7 +39,7 @@ describe('RelayContainer.hasOptimisticUpdate', () => { } } MockContainer = Relay.createContainer(MockComponent, { - fragments: {foo: () => Relay.QL`fragment on Node{id}`}, + fragments: {foo: () => Relay.QL`fragment on Node{id}`} }); RelayTestRenderer = RelayTestUtils.createRenderer(); diff --git a/src/container/__tests__/RelayContainer_setVariables-test.js b/src/container/__tests__/RelayContainer_setVariables-test.js index 72ca6e5a04086..12d35f4ffbba0 100644 --- a/src/container/__tests__/RelayContainer_setVariables-test.js +++ b/src/container/__tests__/RelayContainer_setVariables-test.js @@ -52,9 +52,9 @@ describe('RelayContainer.setVariables', function() { var createContainer = Relay.createContainer; MockContainer = createContainer(MockComponent, { fragments: { - entity: entityQuery, + entity: entityQuery }, - initialVariables: {site: 'mobile'}, + initialVariables: {site: 'mobile'} }); GraphQLStoreQueryResolver.mockDefaultResolveImplementation(pointer => { @@ -64,8 +64,8 @@ describe('RelayContainer.setVariables', function() { id: '42', url: '//url', profilePicture: { - uri: '//url', - }, + uri: '//url' + } }; }); defaultState = { @@ -74,7 +74,7 @@ describe('RelayContainer.setVariables', function() { error: null, mounted: true, ready: false, - stale: false, + stale: false }; domContainer = document.createElement('div'); mockInstance = RelayTestUtils.createRenderer(domContainer).render( @@ -96,8 +96,8 @@ describe('RelayContainer.setVariables', function() { id: '42', url: '//url', profilePicture: { - uri: '//url', - }, + uri: '//url' + } }]; }); var pluralEntityQuery = jest.genMockFunction().mockImplementation( @@ -105,9 +105,9 @@ describe('RelayContainer.setVariables', function() { ); MockContainer = Relay.createContainer(MockComponent, { fragments: { - entity: pluralEntityQuery, + entity: pluralEntityQuery }, - initialVariables: {site: 'mobile'}, + initialVariables: {site: 'mobile'} }); // Return an array @@ -119,17 +119,17 @@ describe('RelayContainer.setVariables', function() { id: '21', url: '//url', profilePicture: { - uri: '//url', - }, + uri: '//url' + } }, { __dataID__: '42', id: '42', url: '//url', profilePicture: { - uri: '//url', - }, - }, + uri: '//url' + } + } ]; }); @@ -157,7 +157,7 @@ describe('RelayContainer.setVariables', function() { it('creates queries only for records with dataIDs', () => { var updatedQueryData = [ {__dataID__: '21', id: '21', url: '//www'}, - {id:'1336', name: 'Fake data', url: '//www'}, + {id:'1336', name: 'Fake data', url: '//www'} ]; GraphQLStoreQueryResolver.mockDefaultResolveImplementation(pointer => { return updatedQueryData; @@ -178,7 +178,7 @@ describe('RelayContainer.setVariables', function() { var updatedQueryData = [ {__dataID__: '21', id: '21', url: '//www'}, - {__dataID__: '42', id: '42', url: '//www'}, + {__dataID__: '42', id: '42', url: '//www'} ]; GraphQLStoreQueryResolver.mockDefaultResolveImplementation(pointer => { expect(pointer.getFragment().getVariables()).toEqual({site: 'www'}); @@ -355,7 +355,7 @@ describe('RelayContainer.setVariables', function() { expect(mockFunction.mock.calls).toEqual([ [{...defaultState, done: false, ready: false}], - [{...defaultState, done: true, ready: true}], + [{...defaultState, done: true, ready: true}] ]); }); @@ -413,10 +413,10 @@ describe('RelayContainer.setVariables', function() { var createContainer = Relay.createContainer; MockContainer = createContainer(MockComponent, { fragments: { - entity: entityQuery, + entity: entityQuery }, initialVariables: {site: 'mobile'}, - prepareVariables, + prepareVariables }); mockInstance = RelayTestUtils.createRenderer(domContainer).render( genMockPointer => @@ -474,7 +474,7 @@ describe('RelayContainer.setVariables', function() { }).not.toThrow(); expect(mockCallback.mock.calls).toEqual([ - [{...defaultState, aborted: true, mounted: false}], + [{...defaultState, aborted: true, mounted: false}] ]); }); }); @@ -489,9 +489,9 @@ describe('RelayContainer.setVariables', function() { var MockInnerContainer = Relay.createContainer(MockInnerComponent, { fragments: { - entity: variables => Relay.QL`fragment on Node{url(site:$site)}`, + entity: variables => Relay.QL`fragment on Node{url(site:$site)}` }, - initialVariables: {site: undefined}, + initialVariables: {site: undefined} }); class MockWrapperComponent extends React.Component { @@ -510,9 +510,9 @@ describe('RelayContainer.setVariables', function() { fragments: { entity: variables => Relay.QL` fragment on Node{ ${MockInnerContainer.getFragment('entity', {site: variables.site})} - }`, + }` }, - initialVariables: {site: 'mobile'}, + initialVariables: {site: 'mobile'} }); mockInstance = RelayTestUtils.createRenderer(domContainer).render( @@ -543,12 +543,12 @@ describe('RelayContainer.setVariables', function() { profilePicture(size:$size) { uri, }, - }`, + }` }, initialVariables: { site: undefined, - size: 48, - }, + size: 48 + } }); class MockWrapperComponent extends React.Component { @@ -567,9 +567,9 @@ describe('RelayContainer.setVariables', function() { fragments: { entity: variables => Relay.QL` fragment on Actor { ${MockInnerContainer.getFragment('entity', {site: variables.site})} - }`, + }` }, - initialVariables: {site: 'mobile'}, + initialVariables: {site: 'mobile'} }); mockInstance = RelayTestUtils.createRenderer(domContainer).render( @@ -583,7 +583,7 @@ describe('RelayContainer.setVariables', function() { Relay.Store.primeCache.mock.requests[0].succeed(); expect(innerComponent.state.variables).toEqual({ site: 'mobile', - size: 32, + size: 32 }); mockInstance.setVariables({site: 'www'}); @@ -591,12 +591,12 @@ describe('RelayContainer.setVariables', function() { Relay.Store.primeCache.mock.requests[1].succeed(); expect(mockInstance.state.variables).toEqual({ - site: 'www', + site: 'www' }); expect(innerComponent.state.variables).toEqual({ site: 'www', - size: 48, + size: 48 }); }); }); diff --git a/src/container/__tests__/RelayRootContainer-test.js b/src/container/__tests__/RelayRootContainer-test.js index 1498bec9ad46c..38c89e28fc08f 100644 --- a/src/container/__tests__/RelayRootContainer-test.js +++ b/src/container/__tests__/RelayRootContainer-test.js @@ -47,7 +47,7 @@ describe('RelayRootContainer', function() { ReactComponent = React.createClass({render: () =>
}); RelayContainer = Relay.createContainer(ReactComponent, { - fragments: {}, + fragments: {} }); ShallowRenderer = ReactTestUtils.createRenderer(); @@ -60,7 +60,7 @@ describe('RelayRootContainer', function() { }, toBeShallowRenderedChild() { return ShallowRenderer.getRenderOutput().props.children === this.actual; - }, + } }); }); @@ -71,12 +71,12 @@ describe('RelayRootContainer', function() { /* jslint validthis: true */ RouteAwareComponent = React.createClass({ contextTypes: { - route: Relay.PropTypes.QueryConfig.isRequired, + route: Relay.PropTypes.QueryConfig.isRequired }, render: function() { this.props.onRender.call(this); return null; - }, + } }); var container = document.createElement('div'); jest.addMatchers({ @@ -96,7 +96,7 @@ describe('RelayRootContainer', function() { var mockRequests = RelayStore.primeCache.mock.requests; mockRequests[mockRequests.length - 1].block(); return context.route === childRoute; - }, + } }); }); @@ -247,14 +247,14 @@ describe('RelayRootContainer', function() { it('creates and primes queries when `Component` changes', () => { var AnotherComponent = React.createClass({render: () =>
}); var AnotherContainer = Relay.createContainer(AnotherComponent, { - fragments: {}, + fragments: {} }); ShallowRenderer.render( ); expect(getRelayQueries.mock.calls).toEqual([ [RelayContainer, route], - [AnotherContainer, route], + [AnotherContainer, route] ]); expect(RelayStore.primeCache.mock.calls.length).toBe(2); }); @@ -266,7 +266,7 @@ describe('RelayRootContainer', function() { ); expect(getRelayQueries.mock.calls).toEqual([ [RelayContainer, route], - [RelayContainer, anotherRoute], + [RelayContainer, anotherRoute] ]); expect(RelayStore.primeCache.mock.calls.length).toBe(2); }); @@ -363,7 +363,7 @@ describe('RelayRootContainer', function() { var index = RelayStore.primeCache.mock.calls.length - 1; return { abort: RelayStore.primeCache.mock.abort[index], - request: RelayStore.primeCache.mock.requests[index], + request: RelayStore.primeCache.mock.requests[index] }; } jest.addMatchers({ @@ -378,7 +378,7 @@ describe('RelayRootContainer', function() { this.actual(request); ShallowRenderer.unmount(); return abort.mock.calls.length > 0; - }, + } }); }); @@ -438,12 +438,12 @@ describe('RelayRootContainer', function() { elements = { loading:
, resolve:
, - failure:
, + failure:
}; callbacks = { renderLoading: jest.genMockFunction().mockReturnValue(elements.loading), renderFetched: jest.genMockFunction().mockReturnValue(elements.resolve), - renderFailure: jest.genMockFunction().mockReturnValue(elements.failure), + renderFailure: jest.genMockFunction().mockReturnValue(elements.failure) }; }); @@ -521,7 +521,7 @@ describe('RelayRootContainer', function() { var MockRoute = RelayRoute.genMock(); route = new MockRoute({ routeParam: '42', - viewer: 'this-will-be-overwritten', + viewer: 'this-will-be-overwritten' }); var data = null; @@ -563,16 +563,16 @@ describe('RelayRootContainer', function() { expect(callbacks.renderFetched.mock.calls.map(args => args[1])).toEqual([ { done: false, - stale: true, + stale: true }, { done: false, - stale: false, + stale: false }, { done: true, - stale: false, - }, + stale: false + } ]); }); @@ -663,7 +663,7 @@ describe('RelayRootContainer', function() { error: null, mounted: true, ready: false, - stale: false, + stale: false }; onReadyStateChange = jest.genMockFunction(); ShallowRenderer.render( @@ -683,7 +683,7 @@ describe('RelayRootContainer', function() { RelayStore.primeCache.mock.requests[0].block(); expect(onReadyStateChange.mock.calls).toEqual([ - [{...defaultState}], + [{...defaultState}] ]); }); @@ -693,7 +693,7 @@ describe('RelayRootContainer', function() { expect(onReadyStateChange.mock.calls).toEqual([ [{...defaultState, ready: false}], - [{...defaultState, ready: true}], + [{...defaultState, ready: true}] ]); }); @@ -705,7 +705,7 @@ describe('RelayRootContainer', function() { expect(onReadyStateChange.mock.calls).toEqual([ [{...defaultState, done: false, ready: false}], [{...defaultState, done: false, ready: true}], - [{...defaultState, done: true, ready: true}], + [{...defaultState, done: true, ready: true}] ]); }); @@ -715,7 +715,7 @@ describe('RelayRootContainer', function() { expect(onReadyStateChange.mock.calls).toEqual([ [{...defaultState, done: false, ready: true}], - [{...defaultState, done: true, ready: true}], + [{...defaultState, done: true, ready: true}] ]); }); @@ -728,7 +728,7 @@ describe('RelayRootContainer', function() { expect(onReadyStateChange.mock.calls).toEqual([ [{...defaultState, error: null, ready: false}], [{...defaultState, error: null, ready: true}], - [{...defaultState, error, ready: true}], + [{...defaultState, error, ready: true}] ]); }); @@ -739,7 +739,7 @@ describe('RelayRootContainer', function() { expect(onReadyStateChange.mock.calls).toEqual([ [{...defaultState, error: null}], - [{...defaultState, error}], + [{...defaultState, error}] ]); }); @@ -748,7 +748,7 @@ describe('RelayRootContainer', function() { RelayStore.primeCache.mock.requests[0].fail(error); expect(onReadyStateChange.mock.calls).toEqual([ - [{...defaultState, error}], + [{...defaultState, error}] ]); }); @@ -771,7 +771,7 @@ describe('RelayRootContainer', function() { jest.runAllTimers(); expect(onReadyStateChange.mock.calls).toEqual([ - [{...defaultState, aborted: true, mounted: false}], + [{...defaultState, aborted: true, mounted: false}] ]); }); }); diff --git a/src/container/__tests__/getRelayQueries-test.js b/src/container/__tests__/getRelayQueries-test.js index 50824933a978d..52493cef80a26 100644 --- a/src/container/__tests__/getRelayQueries-test.js +++ b/src/container/__tests__/getRelayQueries-test.js @@ -43,8 +43,8 @@ describe('getRelayQueries', () => { MockPageContainer = Relay.createContainer(MockPageComponent, { fragments: { first: () => Relay.QL`fragment on Node{id,firstName}`, - last: () => Relay.QL`fragment on Node{id,lastName}`, - }, + last: () => Relay.QL`fragment on Node{id,lastName}` + } }); makeRoute = function() { @@ -54,8 +54,8 @@ describe('getRelayQueries', () => { MockRoute.paramDefinitions = { id: { type: 'String', - id: true, - }, + id: true + } }; MockRoute.queries = { first: (Component, params) => Relay.QL` @@ -71,7 +71,7 @@ describe('getRelayQueries', () => { ${Component.getFragment('last')} } } - `, + ` }; return MockRoute; }; @@ -86,7 +86,7 @@ describe('getRelayQueries', () => { var expected = { first: getNode(Relay.QL`query{node(id:"123"){${Relay.QL`fragment on Node{id,firstName}`}}}`), - last: getNode(Relay.QL`query{node(id:"123"){${Relay.QL`fragment on Node{id,lastName}`}}}`), + last: getNode(Relay.QL`query{node(id:"123"){${Relay.QL`fragment on Node{id,lastName}`}}}`) }; expect(queries.first).toEqualQueryRoot(expected.first); @@ -103,7 +103,7 @@ describe('getRelayQueries', () => { expect(queries).toEqual({ first: null, - last: null, + last: null }); }); @@ -111,7 +111,7 @@ describe('getRelayQueries', () => { class BadRoute extends Relay.Route {} BadRoute.routeName = 'BadRoute'; BadRoute.queries = { - first: () => Relay.QL`fragment on Node{id}`, + first: () => Relay.QL`fragment on Node{id}` }; var badRoute = new BadRoute({}); diff --git a/src/container/__tests__/isRelayContainer-test.js b/src/container/__tests__/isRelayContainer-test.js index 7f04c54196ba5..08a01e5aed0ee 100644 --- a/src/container/__tests__/isRelayContainer-test.js +++ b/src/container/__tests__/isRelayContainer-test.js @@ -25,11 +25,11 @@ describe('isRelayContainer', function() { Relay = require('Relay'); MockComponent = React.createClass({ - render: () =>
, + render: () =>
}); MockContainer = Relay.createContainer(MockComponent, { - fragments: {}, + fragments: {} }); }); diff --git a/src/legacy/mutation/GraphQLMutatorConstants.js b/src/legacy/mutation/GraphQLMutatorConstants.js index f566fe9f01847..ca4247535304c 100644 --- a/src/legacy/mutation/GraphQLMutatorConstants.js +++ b/src/legacy/mutation/GraphQLMutatorConstants.js @@ -29,7 +29,7 @@ var GraphQLMutatorConstants = { UPDATE_TYPES: {}, - RANGE_OPERATIONS: {}, + RANGE_OPERATIONS: {} }; GraphQLMutatorConstants.HANDLER_TYPES diff --git a/src/legacy/query/GraphQL_EXPERIMENTAL.js b/src/legacy/query/GraphQL_EXPERIMENTAL.js index 75786edc40e84..c3f47258ea21e 100644 --- a/src/legacy/query/GraphQL_EXPERIMENTAL.js +++ b/src/legacy/query/GraphQL_EXPERIMENTAL.js @@ -45,7 +45,7 @@ var JSON_TYPES = { BATCH_VARIABLE: 7, MUTATION: 8, QUERY_WITH_VALUES: 9, - SUBSCRIPTION: 10, + SUBSCRIPTION: 10 }; /** @@ -108,7 +108,7 @@ class GraphQLCallvNode { JSON_TYPES.CALL, this.name, this.value, - this.metadata === EMPTY_OBJECT ? null : this.metadata, + this.metadata === EMPTY_OBJECT ? null : this.metadata ]); } } @@ -139,7 +139,7 @@ class GraphQLCallValue { toJSON() { return [ JSON_TYPES.CALL_VALUE, - this.callValue, + this.callValue ]; } } @@ -188,7 +188,7 @@ class GraphQLBatchCallVariable { return [ JSON_TYPES.BATCH_VARIABLE, this.sourceQueryID, - this.jsonPath, + this.jsonPath ]; } } @@ -225,7 +225,7 @@ class GraphQLCallVariable { toJSON() { return [ JSON_TYPES.CALL_VARIABLE, - this.callVariableName, + this.callVariableName ]; } } @@ -267,7 +267,7 @@ class GraphQLFieldNode extends GraphQLNode { isPlural: !!metadata.plural, isRequisite: !!metadata.requisite, isUnionOrInterface: !!metadata.dynamic, - parentType: metadata.parentType, + parentType: metadata.parentType }; } @@ -284,7 +284,7 @@ class GraphQLFieldNode extends GraphQLNode { calls, alias, condition, - metadata, + metadata ] = descriptor; invariant(type === JSON_TYPES.FIELD, 'Expected field descriptor'); return new GraphQLFieldNode( @@ -307,7 +307,7 @@ class GraphQLFieldNode extends GraphQLNode { this.calls.length ? this._calls : null, this.alias, this.condition, - this.__metadata__ === EMPTY_OBJECT ? null : this.__metadata__, + this.__metadata__ === EMPTY_OBJECT ? null : this.__metadata__ ]); } } @@ -357,7 +357,7 @@ class GraphQLQueryFragment extends GraphQLNode { this.type, this.fields.length ? this.fields : null, this.fragments.length ? this.fragments : null, - this.metadata, + this.metadata ]); } } @@ -386,7 +386,7 @@ class GraphQLQuery extends GraphQLNode { this.kind = QUERY; this.metadata = { ...this.__metadata__, - rootArg, + rootArg }; this.name = queryName; this.fieldName = rootCall; @@ -424,7 +424,7 @@ class GraphQLQuery extends GraphQLNode { this.fields.length ? this.fields : null, this.fragments.length ? this.fragments : null, this.__metadata__ !== EMPTY_OBJECT ? this.__metadata__ : null, - this.name || null, + this.name || null ]); } } @@ -470,7 +470,7 @@ class GraphQLQueryWithValues { return trimArray([ JSON_TYPES.QUERY_WITH_VALUES, this.query, - this.values, + this.values ]); } } @@ -500,7 +500,7 @@ class GraphQLOperation extends GraphQLNode { this.calls[0], this.fields.length ? this.fields : null, this.fragments.length ? this.fragments : null, - this.metadata === EMPTY_OBJECT ? null : this.metadata, + this.metadata === EMPTY_OBJECT ? null : this.metadata ]); } } @@ -526,7 +526,7 @@ class GraphQLMutation extends GraphQLOperation { mutationCall, fields, fragments, - metadata, + metadata ] = descriptor; invariant(type === JSON_TYPES.MUTATION, 'Expected mutation descriptor'); return new GraphQLMutation( @@ -568,7 +568,7 @@ class GraphQLSubscription extends GraphQLOperation { subscriptionCall, fields, fragments, - metadata, + metadata ] = descriptor; invariant( type === JSON_TYPES.SUBSCRIPTION, @@ -750,7 +750,7 @@ var GraphQL = { isMutation, isQuery, isQueryWithValues, - isSubscription, + isSubscription }; module.exports = GraphQL; diff --git a/src/legacy/store/DliteFetchModeConstants.js b/src/legacy/store/DliteFetchModeConstants.js index 85b1915b329aa..b555f232e0308 100644 --- a/src/legacy/store/DliteFetchModeConstants.js +++ b/src/legacy/store/DliteFetchModeConstants.js @@ -17,7 +17,7 @@ var keyMirror = require('keyMirror'); var DliteFetchModeConstants = keyMirror({ FETCH_MODE_CLIENT: null, FETCH_MODE_PRELOAD: null, - FETCH_MODE_REFETCH: null, + FETCH_MODE_REFETCH: null }); module.exports = DliteFetchModeConstants; diff --git a/src/legacy/store/GraphQLDeferredQueryTracker.js b/src/legacy/store/GraphQLDeferredQueryTracker.js index a75c88f257af0..5ac920b2298c2 100644 --- a/src/legacy/store/GraphQLDeferredQueryTracker.js +++ b/src/legacy/store/GraphQLDeferredQueryTracker.js @@ -101,7 +101,7 @@ var GraphQLDeferredQueryTracker = { var subscriber = { callbacks, dataID, - fragmentID, + fragmentID }; subscribers.push(subscriber); return { @@ -112,7 +112,7 @@ var GraphQLDeferredQueryTracker = { 'remove() can only be called once' ); subscribers[index] = null; - }, + } }; }, @@ -219,7 +219,7 @@ var GraphQLDeferredQueryTracker = { rootCallToFragmentNameMap = new Map(); subscribers = []; broadcastItems = null; - }, + } }; /** @@ -399,7 +399,7 @@ function processBroadcasts() { var { dataID, error, - fragmentID, + fragmentID } = broadcastItems[jj]; var method; var args; diff --git a/src/legacy/store/GraphQLQueryRunner.js b/src/legacy/store/GraphQLQueryRunner.js index 8f86d742e1400..111a03f963171 100644 --- a/src/legacy/store/GraphQLQueryRunner.js +++ b/src/legacy/store/GraphQLQueryRunner.js @@ -121,7 +121,7 @@ var GraphQLQueryRunner = { var fetchMode = DliteFetchModeConstants.FETCH_MODE_REFETCH; return runQueries(queries, callback, fetchMode, profiler); - }, + } }; @@ -179,7 +179,7 @@ function runQueries( done: false, error: null, ready: false, - stale: false, + stale: false }; var scheduled = false; function setReadyState(partial: PartialReadyState): void { @@ -198,7 +198,7 @@ function runQueries( done: partial.done != null ? partial.done : readyState.done, error: partial.error != null ? partial.error : readyState.error, ready: partial.ready != null ? partial.ready : readyState.ready, - stale: partial.stale != null ? partial.stale : readyState.stale, + stale: partial.stale != null ? partial.stale : readyState.stale }; if (scheduled) { return; @@ -292,7 +292,7 @@ function runQueries( return { abort(): void { setReadyState({aborted: true}); - }, + } }; } diff --git a/src/legacy/store/GraphQLRange.js b/src/legacy/store/GraphQLRange.js index a2b5d31122545..190800dd490d6 100644 --- a/src/legacy/store/GraphQLRange.js +++ b/src/legacy/store/GraphQLRange.js @@ -26,7 +26,7 @@ var { END_CURSOR, HAS_NEXT_PAGE, HAS_PREV_PAGE, - START_CURSOR, + START_CURSOR } = RelayConnectionInterface; /** @@ -176,7 +176,7 @@ class GraphQLRange { // the range (i.e. last(N)). this._orderedSegments = [ new GraphQLSegment(), - new GraphQLSegment(), + new GraphQLSegment() ]; // GraphQLRange nodes can also support static queries like surrounds, @@ -247,7 +247,7 @@ class GraphQLRange { this._staticQueriesMap[calls] = { edgeIDs: edgeIDsToStore, - cursors: cursorsToStore, + cursors: cursorsToStore }; } @@ -756,7 +756,7 @@ class GraphQLRange { return { requestedEdgeIDs: [], diffCalls: [], - pageInfo: RelayConnectionInterface.getDefaultPageInfo(), + pageInfo: RelayConnectionInterface.getDefaultPageInfo() }; } if ((calls.first && calls.before) || (calls.last && calls.after)) { @@ -768,7 +768,7 @@ class GraphQLRange { return { requestedEdgeIDs: [], diffCalls: [], - pageInfo: RelayConnectionInterface.getDefaultPageInfo(), + pageInfo: RelayConnectionInterface.getDefaultPageInfo() }; } if (!isValidRangeCallValues(calls)) { @@ -779,7 +779,7 @@ class GraphQLRange { return { requestedEdgeIDs: [], diffCalls: [], - pageInfo: RelayConnectionInterface.getDefaultPageInfo(), + pageInfo: RelayConnectionInterface.getDefaultPageInfo() }; } if (calls.first) { @@ -811,8 +811,8 @@ class GraphQLRange { [START_CURSOR]: storedInfo.cursors[0], [END_CURSOR]: storedInfo.cursors[storedInfo.cursors.length - 1], [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: true, - }, + [HAS_PREV_PAGE]: true + } }; } @@ -821,7 +821,7 @@ class GraphQLRange { return { requestedEdgeIDs: [], diffCalls: queryCalls, - pageInfo: RelayConnectionInterface.getDefaultPageInfo(), + pageInfo: RelayConnectionInterface.getDefaultPageInfo() }; } @@ -846,7 +846,7 @@ class GraphQLRange { var segment; var segmentIndex; var pageInfo = { - ...RelayConnectionInterface.getDefaultPageInfo(), + ...RelayConnectionInterface.getDefaultPageInfo() }; var afterCursor = calls.after; @@ -860,7 +860,7 @@ class GraphQLRange { return { requestedEdgeIDs: [], diffCalls: [], - pageInfo: pageInfo, + pageInfo: pageInfo }; } segment = this._orderedSegments[segmentIndex]; @@ -925,7 +925,7 @@ class GraphQLRange { return { requestedEdgeIDs: requestedEdgeIDs, diffCalls: diffCalls, - pageInfo: pageInfo, + pageInfo: pageInfo }; } @@ -949,7 +949,7 @@ class GraphQLRange { var segment; var segmentIndex; var pageInfo = { - ...RelayConnectionInterface.getDefaultPageInfo(), + ...RelayConnectionInterface.getDefaultPageInfo() }; var beforeCursor = calls.before; @@ -963,7 +963,7 @@ class GraphQLRange { return { requestedEdgeIDs: [], diffCalls: [], - pageInfo: pageInfo, + pageInfo: pageInfo }; } segment = this._orderedSegments[segmentIndex]; @@ -1028,7 +1028,7 @@ class GraphQLRange { return { requestedEdgeIDs: requestedEdgeIDs, diffCalls: diffCalls, - pageInfo: pageInfo, + pageInfo: pageInfo }; } @@ -1037,7 +1037,7 @@ class GraphQLRange { hasFirst, hasLast, staticQueriesMap, - orderedSegments, + orderedSegments ] = descriptor; var range = new GraphQLRange(); range._hasFirst = hasFirst; @@ -1053,13 +1053,13 @@ class GraphQLRange { this._hasFirst, this._hasLast, this._staticQueriesMap, - this._orderedSegments, + this._orderedSegments ]; } __debug() { return { - orderedSegments: this._orderedSegments, + orderedSegments: this._orderedSegments }; } diff --git a/src/legacy/store/GraphQLSegment.js b/src/legacy/store/GraphQLSegment.js index ab67479f6b18d..e8386d8f09476 100644 --- a/src/legacy/store/GraphQLSegment.js +++ b/src/legacy/store/GraphQLSegment.js @@ -161,7 +161,7 @@ class GraphQLSegment { if (!this.getLength()) { return { edgeIDs: [], - cursors: [], + cursors: [] }; } var currentIndex = this._minIndex; @@ -171,7 +171,7 @@ class GraphQLSegment { console.error('This segment does not have a cursor %s', cursor); return { edgeIDs: [], - cursors: [], + cursors: [] }; } currentIndex = index + 1; @@ -191,7 +191,7 @@ class GraphQLSegment { } return { edgeIDs: edgeIDs, - cursors: cursors, + cursors: cursors }; } @@ -205,7 +205,7 @@ class GraphQLSegment { if (!this.getLength()) { return { edgeIDs: [], - cursors: [], + cursors: [] }; } var currentIndex = this._maxIndex; @@ -215,7 +215,7 @@ class GraphQLSegment { console.error('This segment does not have a cursor %s', cursor); return { edgeIDs: [], - cursors: [], + cursors: [] }; } currentIndex = index - 1; @@ -236,7 +236,7 @@ class GraphQLSegment { // Reverse edges because larger index were added first return { edgeIDs: edgeIDs.reverse(), - cursors: cursors.reverse(), + cursors: cursors.reverse() }; } @@ -281,7 +281,7 @@ class GraphQLSegment { this._indexToMetadataMap[index] = { edgeID: edgeID, cursor: cursor, - deleted: false, + deleted: false }; this._idToIndicesMap[edgeID] = this._idToIndicesMap[edgeID] || []; this._idToIndicesMap[edgeID].unshift(index); @@ -495,7 +495,7 @@ class GraphQLSegment { return { count: this._count, maxIndex: this._maxIndex, - minIndex: this._minIndex, + minIndex: this._minIndex }; } @@ -600,7 +600,7 @@ class GraphQLSegment { this._cursorToIndexMap, this._minIndex, this._maxIndex, - this._count, + this._count ]; } @@ -611,7 +611,7 @@ class GraphQLSegment { cursorToIndexMap, minIndex, maxIndex, - count, + count ] = descriptor; var segment = new GraphQLSegment(); segment._indexToMetadataMap = indexToMetadataMap; @@ -627,7 +627,7 @@ class GraphQLSegment { return { metadata: this._indexToMetadataMap, idToIndices: this._idToIndicesMap, - cursorToIndex: this._cursorToIndexMap, + cursorToIndex: this._cursorToIndexMap }; } diff --git a/src/legacy/store/GraphQLStoreChangeEmitter.js b/src/legacy/store/GraphQLStoreChangeEmitter.js index 314c5864db479..9ba80667374e7 100644 --- a/src/legacy/store/GraphQLStoreChangeEmitter.js +++ b/src/legacy/store/GraphQLStoreChangeEmitter.js @@ -59,7 +59,7 @@ var GraphQLStoreChangeEmitter = { return { remove: function() { delete subscribers[index]; - }, + } }; }, @@ -81,7 +81,7 @@ var GraphQLStoreChangeEmitter = { * Exposed for profiling reasons. * @private */ - _processSubscribers: processSubscribers, + _processSubscribers: processSubscribers }; @@ -131,7 +131,7 @@ function getBroadcastID(id: string): string { RelayProfiler.instrumentMethods(GraphQLStoreChangeEmitter, { addListenerForIDs: 'GraphQLStoreChangeEmitter.addListenerForIDs', broadcastChangeForID: 'GraphQLStoreChangeEmitter.broadcastChangeForID', - _processSubscribers: 'GraphQLStoreChangeEmitter.processSubscribers', + _processSubscribers: 'GraphQLStoreChangeEmitter.processSubscribers' }); module.exports = GraphQLStoreChangeEmitter; diff --git a/src/legacy/store/GraphQLStoreDataHandler.js b/src/legacy/store/GraphQLStoreDataHandler.js index c93d13cf91cbb..8bd3be6afc8f3 100644 --- a/src/legacy/store/GraphQLStoreDataHandler.js +++ b/src/legacy/store/GraphQLStoreDataHandler.js @@ -16,7 +16,7 @@ var METADATA_KEYS = { __dataID__: true, __range__: true, - __status__: true, + __status__: true }; /** @@ -54,7 +54,7 @@ var GraphQLStoreDataHandler = { */ isMetadataKey: function(key: string): boolean { return METADATA_KEYS[key] || false; - }, + } }; module.exports = GraphQLStoreDataHandler; diff --git a/src/legacy/store/GraphQLStoreQueryResolver.js b/src/legacy/store/GraphQLStoreQueryResolver.js index 45cd2cf7f8236..b45e7a9d28343 100644 --- a/src/legacy/store/GraphQLStoreQueryResolver.js +++ b/src/legacy/store/GraphQLStoreQueryResolver.js @@ -281,7 +281,7 @@ function getCanonicalID(id: DataID): DataID { } RelayProfiler.instrumentMethods(GraphQLStoreQueryResolver.prototype, { - resolve: 'GraphQLStoreQueryResolver.resolve', + resolve: 'GraphQLStoreQueryResolver.resolve' }); module.exports = GraphQLStoreQueryResolver; diff --git a/src/legacy/store/GraphQLStoreRangeUtils.js b/src/legacy/store/GraphQLStoreRangeUtils.js index 307271c494520..8d5a8fe238c56 100644 --- a/src/legacy/store/GraphQLStoreRangeUtils.js +++ b/src/legacy/store/GraphQLStoreRangeUtils.js @@ -67,7 +67,7 @@ var GraphQLStoreRangeUtils = { rangeData[key] = { dataID: dataID, calls: calls, - callValues: callValues, + callValues: callValues }; } return key; @@ -93,7 +93,7 @@ var GraphQLStoreRangeUtils = { */ getCanonicalClientID: function(dataID) { return rangeData[dataID] ? rangeData[dataID].dataID : dataID; - }, + } }; module.exports = GraphQLStoreRangeUtils; diff --git a/src/legacy/store/__mocks__/GraphQLQueryRunner.js b/src/legacy/store/__mocks__/GraphQLQueryRunner.js index 4ece8b4e9290a..e770a240e6dee 100644 --- a/src/legacy/store/__mocks__/GraphQLQueryRunner.js +++ b/src/legacy/store/__mocks__/GraphQLQueryRunner.js @@ -45,7 +45,7 @@ function genMockRequest(args) { }, fail(error) { args[1]({aborted: false, done: false, error, ready, stale: false}); - }, + } }; } @@ -56,7 +56,7 @@ GraphQLQueryRunner.run.mockImplementation((...args) => { var returnValue = { abort: jest.genMockFunction().mockImplementation(() => { resolveImmediate(request.abort); - }), + }) }; GraphQLQueryRunner.run.mock.abort.push(returnValue.abort); GraphQLQueryRunner.run.mock.requests.push(request); @@ -70,7 +70,7 @@ GraphQLQueryRunner.forceFetch.mockImplementation((...args) => { var returnValue = { abort: jest.genMockFunction().mockImplementation(() => { resolveImmediate(request.abort); - }), + }) }; GraphQLQueryRunner.forceFetch.mock.abort.push(returnValue.abort); GraphQLQueryRunner.forceFetch.mock.requests.push(request); diff --git a/src/legacy/store/__mocks__/GraphQLStoreQueryResolver.js b/src/legacy/store/__mocks__/GraphQLStoreQueryResolver.js index 690735b7a64a1..18d40932b503b 100644 --- a/src/legacy/store/__mocks__/GraphQLStoreQueryResolver.js +++ b/src/legacy/store/__mocks__/GraphQLStoreQueryResolver.js @@ -16,7 +16,7 @@ class GraphQLStoreQueryResolver { this.mock = { callback, index: mockInstances.length, - queryFragment, + queryFragment }; this.resolve = jest.genMockFunction().mockImplementation((...args) => { var mockConstructor = GraphQLStoreQueryResolver.mock; @@ -42,7 +42,7 @@ class GraphQLStoreQueryResolver { GraphQLStoreQueryResolver.mock = { instances: [], resolveImplementations: [], - defaultResolveImplementation: () => undefined, + defaultResolveImplementation: () => undefined }; module.exports = GraphQLStoreQueryResolver; diff --git a/src/legacy/store/__mocks__/GraphQLStoreTestUtils.js b/src/legacy/store/__mocks__/GraphQLStoreTestUtils.js index 34b2c6b3526aa..9ae89420ab479 100644 --- a/src/legacy/store/__mocks__/GraphQLStoreTestUtils.js +++ b/src/legacy/store/__mocks__/GraphQLStoreTestUtils.js @@ -92,7 +92,7 @@ var GraphQLStoreTestUtils = { for (var ii = 0; ii < actualFragments.length; ii++) { var context = { - actual: actualFragments[ii], + actual: actualFragments[ii] }; var matches = GraphQLStoreTestUtils.matchers.toMatchQueryFragment.call( context, @@ -107,7 +107,7 @@ var GraphQLStoreTestUtils = { } return true; - }, + } }, /** * @param {GraphQLNode} node @@ -154,7 +154,7 @@ var GraphQLStoreTestUtils = { jest .dontMock('GraphQL_EXPERIMENTAL') .dontMock('GraphQLFragmentPointer'); - }, + } }; module.exports = GraphQLStoreTestUtils; diff --git a/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js b/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js index 212e3d5ab05b4..1fc6aa148d988 100644 --- a/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js +++ b/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js @@ -68,7 +68,7 @@ describe('GraphQLDeferredQueryTracker', () => { fragmentID, { onSuccess: onSuccess, - onFailure: onFailure, + onFailure: onFailure } ); GraphQLDeferredQueryTracker.recordQuery(mockDeferred); @@ -103,7 +103,7 @@ describe('GraphQLDeferredQueryTracker', () => { dataID, fragmentID, { - onSuccess: onSuccess, + onSuccess: onSuccess } ); GraphQLDeferredQueryTracker.recordQuery(mockDeferred); diff --git a/src/legacy/store/__tests__/GraphQLFragmentPointer-test.js b/src/legacy/store/__tests__/GraphQLFragmentPointer-test.js index 642e9952d735a..f0f865cbe4052 100644 --- a/src/legacy/store/__tests__/GraphQLFragmentPointer-test.js +++ b/src/legacy/store/__tests__/GraphQLFragmentPointer-test.js @@ -31,7 +31,7 @@ describe('GraphQLFragmentPointer', () => { jest.addMatchers({ toEqualPointer(expected) { return this.actual.equals(expected); - }, + } }); }); diff --git a/src/legacy/store/__tests__/GraphQLQueryRunner-test.js b/src/legacy/store/__tests__/GraphQLQueryRunner-test.js index 66ac15ce3a5f4..e50744925e881 100644 --- a/src/legacy/store/__tests__/GraphQLQueryRunner-test.js +++ b/src/legacy/store/__tests__/GraphQLQueryRunner-test.js @@ -61,7 +61,7 @@ describe('GraphQLQueryRunner', () => { splitDeferredRelayQueries.mockImplementation( query => ({ required: query, - deferred: [], + deferred: [] }) ); } @@ -85,14 +85,14 @@ describe('GraphQLQueryRunner', () => { warning = require('warning'); RelayNetworkLayer.injectNetworkLayer({ - supports: () => true, + supports: () => true }); mockCallback = jest.genMockFunction(); mockQuerySet = { foo: getNode(Relay.QL`query{viewer{actor{id,name}}}`), bar: getNode(Relay.QL`query{node(id:"4"){id,name}}`), - baz: null, + baz: null }; jest.addMatchers(RelayTestUtils.matchers); @@ -104,7 +104,7 @@ describe('GraphQLQueryRunner', () => { expect(mockCallback).not.toBeCalled(); jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: false, done: true, error: null, ready: true, stale: false}], + [{aborted: false, done: true, error: null, ready: true, stale: false}] ]); }); @@ -119,7 +119,7 @@ describe('GraphQLQueryRunner', () => { expect(diffQueryCalls[0][0]).toEqualQueryNode(mockQuerySet.foo); expect(diffQueryCalls[1][0]).toEqualQueryNode(mockQuerySet.bar); expect(mockCallback.mock.calls).toEqual([ - [{aborted: false, done: true, error: null, ready: true, stale: false}], + [{aborted: false, done: true, error: null, ready: true, stale: false}] ]); }); @@ -127,12 +127,12 @@ describe('GraphQLQueryRunner', () => { diffRelayQuery.mockImplementation(query => [query]); checkRelayQueryData.mockImplementation(() => false); RelayNetworkLayer.injectNetworkLayer({ - supports: () => false, + supports: () => false }); var fragment = Relay.QL`fragment on Node{id}`; var querySet = { - foo: getNode(Relay.QL`query{node(id:"123"){${defer(fragment)}}}`), + foo: getNode(Relay.QL`query{node(id:"123"){${defer(fragment)}}}`) }; warning.mockClear(); @@ -148,7 +148,7 @@ describe('GraphQLQueryRunner', () => { 'Relay: Query `%s` contains a deferred fragment (e.g. ' + '`getFragment(\'foo\').defer()`) which is not supported by the ' + 'default network layer. This query will be sent without deferral.', - querySet.foo.getName(), + querySet.foo.getName() ]); }); @@ -163,7 +163,7 @@ describe('GraphQLQueryRunner', () => { jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: false, done: false, error: null, ready: false, stale: false}], + [{aborted: false, done: false, error: null, ready: false, stale: false}] ]); }); @@ -191,7 +191,7 @@ describe('GraphQLQueryRunner', () => { RelayPendingQueryTracker.add.mock.fetches[0].resolve(); jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: false, done: false, error: null, ready: false, stale: false}], + [{aborted: false, done: false, error: null, ready: false, stale: false}] ]); RelayPendingQueryTracker.add.mock.fetches[1].resolve(); @@ -223,15 +223,15 @@ describe('GraphQLQueryRunner', () => { required: null, deferred: [{ required: deferQuery(query), - deferred: [], - }], + deferred: [] + }] })); GraphQLQueryRunner.run(mockQuerySet, mockCallback); jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: false, done: false, error: null, ready: true, stale: false}], + [{aborted: false, done: false, error: null, ready: true, stale: false}] ]); }); @@ -241,7 +241,7 @@ describe('GraphQLQueryRunner', () => { if (query.getRootCall().name === 'viewer') { return { required: query, - deferred: [], + deferred: [] }; } else { // Treat `mockQuerySet.bar` as deferred. @@ -249,8 +249,8 @@ describe('GraphQLQueryRunner', () => { query: null, deferred: [{ required: deferQuery(query), - deferred: [], - }], + deferred: [] + }] }; } }); @@ -263,7 +263,7 @@ describe('GraphQLQueryRunner', () => { expect(mockCallback.mock.calls).toEqual([ [{aborted: false, done: false, error: null, ready: false, stale: false}], - [{aborted: false, done: false, error: null, ready: true, stale: false}], + [{aborted: false, done: false, error: null, ready: true, stale: false}] ]); RelayPendingQueryTracker.add.mock.fetches[1].resolve(); @@ -282,7 +282,7 @@ describe('GraphQLQueryRunner', () => { jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: false, done: false, error: null, ready: false, stale: false}], + [{aborted: false, done: false, error: null, ready: false, stale: false}] ]); RelayPendingQueryTracker.add.mock.fetches[0].resolve(); @@ -291,7 +291,7 @@ describe('GraphQLQueryRunner', () => { expect(mockCallback.mock.calls).toEqual([ [{aborted: false, done: false, error: null, ready: false, stale: false}], - [{aborted: false, done: true, error: null, ready: true, stale: false}], + [{aborted: false, done: true, error: null, ready: true, stale: false}] ]); }); @@ -319,7 +319,7 @@ describe('GraphQLQueryRunner', () => { jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: true, done: false, error: null, ready: false, stale: false}], + [{aborted: true, done: false, error: null, ready: false, stale: false}] ]); }); @@ -335,7 +335,7 @@ describe('GraphQLQueryRunner', () => { jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: true, done: false, error: null, ready: false, stale: false}], + [{aborted: true, done: false, error: null, ready: false, stale: false}] ]); }); @@ -372,7 +372,7 @@ describe('GraphQLQueryRunner', () => { jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: true, done: false, error: null, ready: false, stale: false}], + [{aborted: true, done: false, error: null, ready: false, stale: false}] ]); }); @@ -402,7 +402,7 @@ describe('GraphQLQueryRunner', () => { expect(mockCallback.mock.calls).toEqual([ [{aborted: false, done: false, error: null, ready: false, stale: false}], - [{aborted: false, done: false, error: null, ready: true, stale: true}], + [{aborted: false, done: false, error: null, ready: true, stale: true}] ]); expect(RelayPendingQueryTracker.add.mock.calls.length).toBe(1); @@ -452,11 +452,11 @@ describe('GraphQLQueryRunner', () => { query { viewer{actor{id,lastName}} } - `, + ` ].map(query => ({ required: deferQuery(getNode(query)), - deferred: [], - })), + deferred: [] + })) }; splitDeferredRelayQueries.mockImplementation(query => { @@ -482,13 +482,13 @@ describe('GraphQLQueryRunner', () => { done: false, error: null, ready: false, - stale: false, + stale: false }; // Only called once after both splitQuery#0 and splitQuery#1. expect(mockCallback.mock.calls).toEqual([ [{...defaultState}], - [{...defaultState, ready: true}], + [{...defaultState, ready: true}] ]); resolveSplitQueryByIndex(2); @@ -499,7 +499,7 @@ describe('GraphQLQueryRunner', () => { expect(mockCallback.mock.calls).toEqual([ [{...defaultState, ready: false}], [{...defaultState, ready: true}], - [{...defaultState, ready: true}], + [{...defaultState, ready: true}] ]); resolveSplitQueryByIndex(4); diff --git a/src/legacy/store/__tests__/GraphQLRange-test.js b/src/legacy/store/__tests__/GraphQLRange-test.js index e095237036475..b119d31e72f0b 100644 --- a/src/legacy/store/__tests__/GraphQLRange-test.js +++ b/src/legacy/store/__tests__/GraphQLRange-test.js @@ -33,7 +33,7 @@ function mockEdge(id, hasNullCursor) { var edge = { __dataID__: dataID, node: {__dataID__: 'id' + id}, - cursor: (hasNullCursor ? null : 'cursor' + id), + cursor: (hasNullCursor ? null : 'cursor' + id) }; return edge; } @@ -107,11 +107,11 @@ describe('GraphQLRange', () => { it('should add for first() query', () => { var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -128,11 +128,11 @@ describe('GraphQLRange', () => { it('should add for after().first() query', () => { var queryCalls = [ {name: 'after', value: null}, - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems( @@ -144,12 +144,12 @@ describe('GraphQLRange', () => { var incrementalEdges = [edge4, edge5]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; queryCalls = [ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '2'}, + {name: 'first', value: '2'} ]; range.addItems( queryCalls, @@ -160,7 +160,7 @@ describe('GraphQLRange', () => { // Request the full set queryCalls = [ {name: 'after', value: null}, - {name: 'first', value: '5'}, + {name: 'first', value: '5'} ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -169,7 +169,7 @@ describe('GraphQLRange', () => { edge2.__dataID__, edge3.__dataID__, edge4.__dataID__, - edge5.__dataID__, + edge5.__dataID__ ]); expect(result.diffCalls.length).toBe(0); @@ -177,23 +177,23 @@ describe('GraphQLRange', () => { it('should add for after().first() query in last segment', () => { var queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems(queryCalls, last3Edges, pageInfo); var incrementalQueryCall = [ {name: 'after', value: 'cursor100'}, - {name: 'first', value: '2'}, + {name: 'first', value: '2'} ]; var incrementalEdges = [edge101, edge102]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems( @@ -204,7 +204,7 @@ describe('GraphQLRange', () => { // Request the full set queryCalls = [ - {name: 'last', value: '5'}, + {name: 'last', value: '5'} ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -213,7 +213,7 @@ describe('GraphQLRange', () => { edge99.__dataID__, edge100.__dataID__, edge101.__dataID__, - edge102.__dataID__, + edge102.__dataID__ ]); expect(result.diffCalls.length).toBe(0); @@ -221,25 +221,25 @@ describe('GraphQLRange', () => { it('should add for before().first() query', () => { var queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, first3Edges, pageInfo); var incrementalQueryCall = [ {name: 'before', value: 'cursor1'}, - {name: 'first', value: '2'}, + {name: 'first', value: '2'} ]; var incrementalEdges = [edgeNeg1, edge0]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems( incrementalQueryCall, @@ -248,7 +248,7 @@ describe('GraphQLRange', () => { ); // Request the full set to make sure it is stitched properly queryCalls = [ - {name: 'last', value: '5'}, + {name: 'last', value: '5'} ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -257,7 +257,7 @@ describe('GraphQLRange', () => { edge0.__dataID__, edge1.__dataID__, edge2.__dataID__, - edge3.__dataID__, + edge3.__dataID__ ]); expect(result.diffCalls.length).toBe(0); @@ -265,25 +265,25 @@ describe('GraphQLRange', () => { it('should add for before().first() query with gap', () => { var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, first3Edges, pageInfo); var incrementalQueryCall = [ {name: 'before', value: 'cursor1'}, - {name: 'first', value: '2'}, + {name: 'first', value: '2'} ]; var incrementalEdges = [edgeNeg10, edgeNeg9]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems( incrementalQueryCall, @@ -292,7 +292,7 @@ describe('GraphQLRange', () => { ); // Request super set queryCalls = [ - {name: 'first', value: '5'}, + {name: 'first', value: '5'} ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -302,19 +302,19 @@ describe('GraphQLRange', () => { expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor-9'}, {name: 'before', value: 'cursor1'}, - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]); }); it('should add for last() query', () => { var queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems(queryCalls, last3Edges, pageInfo); @@ -330,26 +330,26 @@ describe('GraphQLRange', () => { it('should add for before().last() query', () => { var queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems(queryCalls, last3Edges, pageInfo); var incrementalQueryCall = [ {name: 'before', value: 'cursor98'}, - {name: 'last', value: '2'}, + {name: 'last', value: '2'} ]; var incrementalEdges = [edge96, edge97]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems( @@ -360,7 +360,7 @@ describe('GraphQLRange', () => { // Request the full set queryCalls = [ - {name: 'last', value: '5'}, + {name: 'last', value: '5'} ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -369,32 +369,32 @@ describe('GraphQLRange', () => { edge97.__dataID__, edge98.__dataID__, edge99.__dataID__, - edge100.__dataID__, + edge100.__dataID__ ]); expect(result.diffCalls.length).toBe(0); }); it('should add for before().last() query in first segment', () => { var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, first3Edges, pageInfo); var incrementalQueryCall = [ {name: 'before', value: 'cursor1'}, - {name: 'last', value: '2'}, + {name: 'last', value: '2'} ]; var incrementalEdges = [edgeNeg1, edge0]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems( @@ -405,7 +405,7 @@ describe('GraphQLRange', () => { // Request the full set queryCalls = [ - {name: 'first', value: '5'}, + {name: 'first', value: '5'} ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -414,31 +414,31 @@ describe('GraphQLRange', () => { edge0.__dataID__, edge1.__dataID__, edge2.__dataID__, - edge3.__dataID__, + edge3.__dataID__ ]); expect(result.diffCalls.length).toBe(0); }); it('should add for after().last() query', () => { var queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems(queryCalls, last3Edges, pageInfo); var incrementalQueryCall = [ {name: 'after', value: 'cursor100'}, - {name: 'last', value: '2'}, + {name: 'last', value: '2'} ]; var incrementalEdges = [edge101, edge102]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems( @@ -449,7 +449,7 @@ describe('GraphQLRange', () => { // Request the full set queryCalls = [ - {name: 'last', value: '5'}, + {name: 'last', value: '5'} ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -458,7 +458,7 @@ describe('GraphQLRange', () => { edge99.__dataID__, edge100.__dataID__, edge101.__dataID__, - edge102.__dataID__, + edge102.__dataID__ ]); expect(result.diffCalls.length).toBe(0); @@ -467,19 +467,19 @@ describe('GraphQLRange', () => { it('should add for after().last() with gap', () => { var queryCalls = [ {name: 'after', value: null}, - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems(queryCalls, last3Edges, pageInfo); queryCalls = [ {name: 'after', value: 'cursor100'}, - {name: 'last', value: '2'}, + {name: 'last', value: '2'} ]; range.addItems( queryCalls, @@ -490,7 +490,7 @@ describe('GraphQLRange', () => { // Request the super set queryCalls = [ {name: 'after', value: null}, - {name: 'last', value: '5'}, + {name: 'last', value: '5'} ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -500,14 +500,14 @@ describe('GraphQLRange', () => { expect(result.diffCalls).toEqual([ {name: 'before', value: 'cursor110'}, {name: 'after', value: 'cursor100'}, - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]); }); it('should error for invalid call value', () => { console.error = jest.genMockFunction(); var queryCalls = [ - {name: 'first', value: '0'}, + {name: 'first', value: '0'} ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -515,7 +515,7 @@ describe('GraphQLRange', () => { expect(console.error.mock.calls.length).toBe(1); expect(console.error.mock.calls[0]).toEqual([ 'GraphQLRange only supports first() or last() ' + - 'where count is greater than 0', + 'where count is greater than 0' ]); expect(result.requestedEdgeIDs).toEqual([]); expect(result.diffCalls.length).toBe(0); @@ -523,7 +523,7 @@ describe('GraphQLRange', () => { it('should retrieve for first() queries', () => { var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; // Request from empty range @@ -536,7 +536,7 @@ describe('GraphQLRange', () => { var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -553,7 +553,7 @@ describe('GraphQLRange', () => { // Request a subset queryCalls = [ - {name: 'first', value: '2'}, + {name: 'first', value: '2'} ]; result = range.retrieveRangeInfoForQuery(queryCalls); @@ -566,7 +566,7 @@ describe('GraphQLRange', () => { // Request a superset queryCalls = [ - {name: 'first', value: '5'}, + {name: 'first', value: '5'} ]; result = range.retrieveRangeInfoForQuery(queryCalls); @@ -575,7 +575,7 @@ describe('GraphQLRange', () => { ); expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '2'}, + {name: 'first', value: '2'} ]); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(false); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(true); @@ -585,12 +585,12 @@ describe('GraphQLRange', () => { it('should retrieve for after().first() queries', () => { var queryCalls = [ {name: 'after', value: null}, - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems( @@ -602,7 +602,7 @@ describe('GraphQLRange', () => { // Request a subset with after queryCalls = [ {name: 'after', value: 'cursor1'}, - {name: 'first', value: '2'}, + {name: 'first', value: '2'} ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -616,7 +616,7 @@ describe('GraphQLRange', () => { // Request a superset with after queryCalls = [ {name: 'after', value: 'cursor1'}, - {name: 'first', value: '5'}, + {name: 'first', value: '5'} ]; result = range.retrieveRangeInfoForQuery(queryCalls); @@ -625,7 +625,7 @@ describe('GraphQLRange', () => { ); expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(false); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(true); @@ -633,14 +633,14 @@ describe('GraphQLRange', () => { // Request a non-intersecting superset with after queryCalls = [ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '2'}, + {name: 'first', value: '2'} ]; result = range.retrieveRangeInfoForQuery(queryCalls); expect(result.requestedEdgeIDs).toEqual([]); expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '2'}, + {name: 'first', value: '2'} ]); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(false); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(true); @@ -648,7 +648,7 @@ describe('GraphQLRange', () => { it('should retrieve for last() queries', () => { var queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; // Request the from empty range @@ -661,7 +661,7 @@ describe('GraphQLRange', () => { var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems(queryCalls, last3Edges, pageInfo); @@ -696,7 +696,7 @@ describe('GraphQLRange', () => { ); expect(result.diffCalls).toEqual([ {name: 'before', value: 'cursor98'}, - {name: 'last', value: '2'}, + {name: 'last', value: '2'} ]); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(true); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(false); @@ -704,12 +704,12 @@ describe('GraphQLRange', () => { it('should retrieve for before().last() queries', () => { var queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems(queryCalls, last3Edges, pageInfo); @@ -717,7 +717,7 @@ describe('GraphQLRange', () => { // Request a subset with before var result = range.retrieveRangeInfoForQuery([ {name: 'before', value: 'cursor100'}, - {name: 'last', value: '2'}, + {name: 'last', value: '2'} ]); expect(result.requestedEdgeIDs).toEqual( @@ -730,7 +730,7 @@ describe('GraphQLRange', () => { // Request a superset with before result = range.retrieveRangeInfoForQuery([ {name: 'before', value: 'cursor100'}, - {name: 'last', value: '5'}, + {name: 'last', value: '5'} ]); expect(result.requestedEdgeIDs).toEqual( @@ -738,7 +738,7 @@ describe('GraphQLRange', () => { ); expect(result.diffCalls).toEqual([ {name: 'before', value: 'cursor98'}, - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(true); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(false); @@ -746,13 +746,13 @@ describe('GraphQLRange', () => { // Request a non-intersecting superset with before result = range.retrieveRangeInfoForQuery([ {name: 'before', value: 'cursor98'}, - {name: 'last', value: '2'}, + {name: 'last', value: '2'} ]); expect(result.requestedEdgeIDs).toEqual([]); expect(result.diffCalls).toEqual([ {name: 'before', value: 'cursor98'}, - {name: 'last', value: '2'}, + {name: 'last', value: '2'} ]); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(true); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(false); @@ -761,19 +761,19 @@ describe('GraphQLRange', () => { it('should retrieve for after().first() from last segment', () => { var queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems(queryCalls, last3Edges, pageInfo); // Request a subset with after var result = range.retrieveRangeInfoForQuery([ {name: 'after', value: 'cursor98'}, - {name: 'first', value: '1'}, + {name: 'first', value: '1'} ]); expect(result.requestedEdgeIDs).toEqual([edge99.__dataID__]); @@ -784,7 +784,7 @@ describe('GraphQLRange', () => { // Request a superset with after result = range.retrieveRangeInfoForQuery([ {name: 'after', value: 'cursor98'}, - {name: 'first', value: '5'}, + {name: 'first', value: '5'} ]); expect(result.requestedEdgeIDs).toEqual( @@ -797,7 +797,7 @@ describe('GraphQLRange', () => { // Request a non-intersecting superset with after result = range.retrieveRangeInfoForQuery([ {name: 'after', value: 'cursor100'}, - {name: 'first', value: '2'}, + {name: 'first', value: '2'} ]); expect(result.requestedEdgeIDs).toEqual([]); @@ -809,12 +809,12 @@ describe('GraphQLRange', () => { it('should retrieve for before().last() from first segment', () => { var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -822,7 +822,7 @@ describe('GraphQLRange', () => { // Request a subset with before var result = range.retrieveRangeInfoForQuery([ {name: 'before', value: 'cursor3'}, - {name: 'last', value: '1'}, + {name: 'last', value: '1'} ]); expect(result.requestedEdgeIDs).toEqual([edge2.__dataID__]); @@ -833,7 +833,7 @@ describe('GraphQLRange', () => { // Request a superset with before result = range.retrieveRangeInfoForQuery([ {name: 'before', value: 'cursor3'}, - {name: 'last', value: '5'}, + {name: 'last', value: '5'} ]); expect(result.requestedEdgeIDs).toEqual( @@ -846,7 +846,7 @@ describe('GraphQLRange', () => { // Request a non-intersecting superset with before result = range.retrieveRangeInfoForQuery([ {name: 'before', value: 'cursor1'}, - {name: 'last', value: '2'}, + {name: 'last', value: '2'} ]); expect(result.requestedEdgeIDs).toEqual([]); @@ -859,12 +859,12 @@ describe('GraphQLRange', () => { it('should support calls with no arguments', () => { var queryCalls = [ {name: 'first', value: '3'}, - {name: 'dummy_call', value: null}, + {name: 'dummy_call', value: null} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -872,7 +872,7 @@ describe('GraphQLRange', () => { // Request the full set var result = range.retrieveRangeInfoForQuery([ {name: 'first', value: '3'}, - {name: 'dummy_call', value: null}, + {name: 'dummy_call', value: null} ]); expect(result.requestedEdgeIDs).toEqual( @@ -883,31 +883,31 @@ describe('GraphQLRange', () => { it('should support nodes with null cursors', () => { var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; var first3EdgesWithNullCursors = [ edgeWithNullCursor1, edgeWithNullCursor2, - edgeWithNullCursor3, + edgeWithNullCursor3 ]; range.addItems(queryCalls, first3EdgesWithNullCursors, pageInfo); // Request the full set var result = range.retrieveRangeInfoForQuery([ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]); expect(result.requestedEdgeIDs).toEqual([ 'edgeWithNullCursor1', 'edgeWithNullCursor2', - 'edgeWithNullCursor3', + 'edgeWithNullCursor3' ]); expect(result.diffCalls.length).toBe(0); }); @@ -916,7 +916,7 @@ describe('GraphQLRange', () => { // Prepend on new range range.prependEdge(edge2); var result = range.retrieveRangeInfoForQuery([ - {name: 'first', value: '1'}, + {name: 'first', value: '1'} ]); expect(result.requestedEdgeIDs).toEqual([edge2.__dataID__]); expect(result.diffCalls.length).toBe(0); @@ -924,7 +924,7 @@ describe('GraphQLRange', () => { // Prepend on range that already has edge range.prependEdge(edge1); result = range.retrieveRangeInfoForQuery([ - {name: 'first', value: '2'}, + {name: 'first', value: '2'} ]); expect(result.requestedEdgeIDs).toEqual( [edge1.__dataID__, edge2.__dataID__] @@ -936,7 +936,7 @@ describe('GraphQLRange', () => { // Append on new range range.appendEdge(edge1); var result = range.retrieveRangeInfoForQuery([ - {name: 'last', value: '1'}, + {name: 'last', value: '1'} ]); expect(result.requestedEdgeIDs).toEqual([edge1.__dataID__]); expect(result.diffCalls.length).toBe(0); @@ -944,7 +944,7 @@ describe('GraphQLRange', () => { // Append on range that already has an edge range.appendEdge(edge2); result = range.retrieveRangeInfoForQuery([ - {name: 'last', value: '2'}, + {name: 'last', value: '2'} ]); expect(result.requestedEdgeIDs).toEqual( [edge1.__dataID__, edge2.__dataID__] @@ -954,19 +954,19 @@ describe('GraphQLRange', () => { it('should support bumping', () => { var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, first3Edges, pageInfo); var afterQueryCalls = [ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '1'}, + {name: 'first', value: '1'} ]; // Testing add after: adding id2 to end of range @@ -986,19 +986,19 @@ describe('GraphQLRange', () => { expect(result.diffCalls.length).toBe(0); queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems(queryCalls, last3Edges, pageInfo); var beforeQueryCalls = [ {name: 'before', value: 'cursor98'}, - {name: 'last', value: '1'}, + {name: 'last', value: '1'} ]; // Testing add before: adding id99 to end of range @@ -1020,16 +1020,16 @@ describe('GraphQLRange', () => { it('should not generate diff query when range is empty', () => { var queryFirstCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var queryLastCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; // Add empty first edges @@ -1052,16 +1052,16 @@ describe('GraphQLRange', () => { it('should collesce segments when we reach end', () => { var queryFirstCalls = [ - {name: 'first', value: '1'}, + {name: 'first', value: '1'} ]; var queryLastCalls = [ - {name: 'last', value: '1'}, + {name: 'last', value: '1'} ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryFirstCalls, [edge1], pageInfo); @@ -1077,16 +1077,16 @@ describe('GraphQLRange', () => { it('should not generate diff query when there is no more', () => { var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; var beforeQueryCalls = [ {name: 'before', value: 'cursor1'}, - {name: 'last', value: '1'}, + {name: 'last', value: '1'} ]; range.addItems(queryCalls, first3Edges, pageInfo); @@ -1095,16 +1095,16 @@ describe('GraphQLRange', () => { expect(result.diffCalls.length).toBe(0); queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; var afterQueryCalls = [ {name: 'after', value: 'cursor100'}, - {name: 'first', value: '1'}, + {name: 'first', value: '1'} ]; range.addItems(queryCalls, last3Edges, pageInfo); @@ -1115,12 +1115,12 @@ describe('GraphQLRange', () => { it('should add and retrieve for surrounds() query', () => { var queryCalls = [ - {name: 'surrounds', value: ['id2', 1]}, + {name: 'surrounds', value: ['id2', 1]} ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -1134,18 +1134,18 @@ describe('GraphQLRange', () => { it('should not return surrounds query data for first query', () => { var surroundQueryCalls = [ - {name: 'surrounds', value: ['id2', 1]}, + {name: 'surrounds', value: ['id2', 1]} ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(surroundQueryCalls, first3Edges, pageInfo); var firstQueryCalls = [ - {name: 'first', value: '5'}, + {name: 'first', value: '5'} ]; var resultForFirstQuery = range.retrieveRangeInfoForQuery( @@ -1160,12 +1160,12 @@ describe('GraphQLRange', () => { console.error = jest.genMockFunction(); var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, [edge1, edge2, edge3], pageInfo); @@ -1175,7 +1175,7 @@ describe('GraphQLRange', () => { expect([ 'Relay was unable to reconcile edges on a connection. This most ' + 'likely occurred while trying to handle a server response that ' + - 'includes connection edges with nodes that lack an `id` field.', + 'includes connection edges with nodes that lack an `id` field.' ]).toBeWarnedNTimes(1); var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -1188,12 +1188,12 @@ describe('GraphQLRange', () => { console.error = jest.genMockFunction(); var queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; // Add items twice @@ -1204,7 +1204,7 @@ describe('GraphQLRange', () => { expect([ 'Relay was unable to reconcile edges on a connection. This most ' + 'likely occurred while trying to handle a server response that ' + - 'includes connection edges with nodes that lack an `id` field.', + 'includes connection edges with nodes that lack an `id` field.' ]).toBeWarnedNTimes(1); var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -1218,12 +1218,12 @@ describe('GraphQLRange', () => { console.warn = jest.genMockFunction(); var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; // Add items twice @@ -1239,12 +1239,12 @@ describe('GraphQLRange', () => { ); queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; // Add items twice @@ -1265,18 +1265,18 @@ describe('GraphQLRange', () => { console.warn = jest.genMockFunction(); var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, first3Edges, pageInfo); queryCalls = [ - {name: 'first', value: '5'}, + {name: 'first', value: '5'} ]; range.addItems(queryCalls, first5Edges, pageInfo); @@ -1289,22 +1289,22 @@ describe('GraphQLRange', () => { edge2.__dataID__, edge3.__dataID__, edge4.__dataID__, - edge5.__dataID__, + edge5.__dataID__ ]); queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems(queryCalls, last3Edges, pageInfo); queryCalls = [ - {name: 'last', value: '5'}, + {name: 'last', value: '5'} ]; range.addItems(queryCalls, last5Edges, pageInfo); @@ -1317,21 +1317,21 @@ describe('GraphQLRange', () => { edge97.__dataID__, edge98.__dataID__, edge99.__dataID__, - edge100.__dataID__, + edge100.__dataID__ ]); }); it('should stitch first and last segment', () => { var firstQueryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var lastQueryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(firstQueryCalls, first3Edges, pageInfo); @@ -1339,12 +1339,12 @@ describe('GraphQLRange', () => { expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor3'}, - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]); pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(result.diffCalls, last3Edges, pageInfo); result = range.retrieveRangeInfoForQuery( @@ -1357,7 +1357,7 @@ describe('GraphQLRange', () => { edge3.__dataID__, edge98.__dataID__, edge99.__dataID__, - edge100.__dataID__, + edge100.__dataID__ ]); result = range.retrieveRangeInfoForQuery( [{name: 'last', value: '6'}], @@ -1369,14 +1369,14 @@ describe('GraphQLRange', () => { edge3.__dataID__, edge98.__dataID__, edge99.__dataID__, - edge100.__dataID__, + edge100.__dataID__ ]); range = new GraphQLRange(); pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems(lastQueryCalls, last3Edges, pageInfo); @@ -1384,12 +1384,12 @@ describe('GraphQLRange', () => { expect(result.diffCalls).toEqual([ {name: 'before', value: 'cursor98'}, - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]); pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(result.diffCalls, first3Edges, pageInfo); @@ -1403,7 +1403,7 @@ describe('GraphQLRange', () => { edge3.__dataID__, edge98.__dataID__, edge99.__dataID__, - edge100.__dataID__, + edge100.__dataID__ ]); result = range.retrieveRangeInfoForQuery( [{name: 'last', value: '6'}], @@ -1415,19 +1415,19 @@ describe('GraphQLRange', () => { edge3.__dataID__, edge98.__dataID__, edge99.__dataID__, - edge100.__dataID__, + edge100.__dataID__ ]); }); it('should stitch up gap in first segment', () => { // Add initial edges var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -1437,12 +1437,12 @@ describe('GraphQLRange', () => { // Create gap var incrementalQueryCall = [ {name: 'before', value: 'cursor1'}, - {name: 'first', value: '2'}, + {name: 'first', value: '2'} ]; var incrementalEdges = [edgeNeg3, edgeNeg2]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems( incrementalQueryCall, @@ -1451,32 +1451,32 @@ describe('GraphQLRange', () => { ); result = range.retrieveRangeInfoForQuery([ - {name: 'first', value: '5'}, + {name: 'first', value: '5'} ]); var diffCalls = result.diffCalls; expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor-2'}, {name: 'before', value: 'cursor1'}, - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]); // Fill in gap var gapEdges = [edgeNeg1, edge0]; pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(diffCalls, gapEdges, pageInfo); result = range.retrieveRangeInfoForQuery([ - {name: 'first', value: '5'}, + {name: 'first', value: '5'} ]); expect(result.requestedEdgeIDs).toEqual([ edgeNeg3.__dataID__, edgeNeg2.__dataID__, edgeNeg1.__dataID__, edge0.__dataID__, - edge1.__dataID__, + edge1.__dataID__ ]); expect(result.diffCalls.length).toBe(0); }); @@ -1484,11 +1484,11 @@ describe('GraphQLRange', () => { it('should stitch up gap in last segment', () => { // Add initial edges var queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems(queryCalls, last3Edges, pageInfo); @@ -1497,13 +1497,13 @@ describe('GraphQLRange', () => { // Create gap var incrementalQueryCall = [ {name: 'after', value: 'cursor100'}, - {name: 'last', value: '2'}, + {name: 'last', value: '2'} ]; var incrementalEdges = [edge103, edge104]; var incrementalPageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems( incrementalQueryCall, @@ -1512,50 +1512,50 @@ describe('GraphQLRange', () => { ); result = range.retrieveRangeInfoForQuery([ - {name: 'last', value: '5'}, + {name: 'last', value: '5'} ]); var diffCalls = result.diffCalls; expect(result.diffCalls).toEqual([ {name: 'before', value: 'cursor103'}, {name: 'after', value: 'cursor100'}, - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]); // Fill in gap var gapEdges = [edge101, edge102]; pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(diffCalls, gapEdges, pageInfo); result = range.retrieveRangeInfoForQuery([ - {name: 'last', value: '5'}, + {name: 'last', value: '5'} ]); expect(result.requestedEdgeIDs).toEqual([ edge100.__dataID__, edge101.__dataID__, edge102.__dataID__, edge103.__dataID__, - edge104.__dataID__, + edge104.__dataID__ ]); expect(result.diffCalls.length).toBe(0); }); it('should refetch for whole ranges for null cursor', () => { var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; var nullCursorEdges = [ edgeWithNullCursor1, edgeWithNullCursor2, - edgeWithNullCursor3, + edgeWithNullCursor3 ]; range.addItems(queryCalls, nullCursorEdges, pageInfo); @@ -1564,24 +1564,24 @@ describe('GraphQLRange', () => { expect(result.requestedEdgeIDs).toEqual([ 'edgeWithNullCursor1', 'edgeWithNullCursor2', - 'edgeWithNullCursor3', + 'edgeWithNullCursor3' ]); expect(result.diffCalls).toEqual(five); }); it('replaces whole first() ranges when working with null cursors', () => { var queryCalls = [ - {name: 'first', value: '1'}, + {name: 'first', value: '1'} ]; var pageInfo = { - [HAS_NEXT_PAGE]: true, + [HAS_NEXT_PAGE]: true }; var nullCursorEdges = [ edgeWithNullCursor1, edgeWithNullCursor2, - edgeWithNullCursor3, + edgeWithNullCursor3 ]; // we don't replace empty ranges @@ -1604,7 +1604,7 @@ describe('GraphQLRange', () => { var cursorEdges = [ edge0, edge1, - edge2, + edge2 ]; range = new GraphQLRange(); segment = getFirstSegment(range); @@ -1616,17 +1616,17 @@ describe('GraphQLRange', () => { it('replaces whole last() ranges when working with null cursors', () => { var queryCalls = [ - {name: 'last', value: '1'}, + {name: 'last', value: '1'} ]; var pageInfo = { - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; var nullCursorEdges = [ edgeWithNullCursor1, edgeWithNullCursor2, - edgeWithNullCursor3, + edgeWithNullCursor3 ]; // we don't replace empty ranges @@ -1649,7 +1649,7 @@ describe('GraphQLRange', () => { var cursorEdges = [ edge0, edge1, - edge2, + edge2 ]; range = new GraphQLRange(); segment = getLastSegment(range); @@ -1665,20 +1665,20 @@ describe('GraphQLRange', () => { var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; var nullCursorEdges = [ edgeWithNullCursor1, edgeWithNullCursor2, - edgeWithNullCursor3, + edgeWithNullCursor3 ]; range.addItems(three, nullCursorEdges, pageInfo); var result = range.retrieveRangeInfoForQuery(two); expect(result.requestedEdgeIDs).toEqual([ 'edgeWithNullCursor1', - 'edgeWithNullCursor2', + 'edgeWithNullCursor2' ]); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(true); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(false); @@ -1687,7 +1687,7 @@ describe('GraphQLRange', () => { expect(result.requestedEdgeIDs).toEqual([ 'edgeWithNullCursor1', 'edgeWithNullCursor2', - 'edgeWithNullCursor3', + 'edgeWithNullCursor3' ]); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(false); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(false); @@ -1695,12 +1695,12 @@ describe('GraphQLRange', () => { it('should delete', () => { var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -1711,18 +1711,18 @@ describe('GraphQLRange', () => { ); expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '1'}, + {name: 'first', value: '1'} ]); }); it('should not retrieve deleted bumped edges', () => { var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -1731,7 +1731,7 @@ describe('GraphQLRange', () => { // bump the second edge var afterQueryCalls = [ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '1'}, + {name: 'first', value: '1'} ]; range.addItems(afterQueryCalls, [first3Edges[1]], pageInfo); @@ -1744,10 +1744,10 @@ describe('GraphQLRange', () => { ); expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '1'}, + {name: 'first', value: '1'} ]); var queryCallsWithSession = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; result = range.retrieveRangeInfoForQuery(queryCallsWithSession); expect(result.requestedEdgeIDs).toEqual( @@ -1755,18 +1755,18 @@ describe('GraphQLRange', () => { ); expect(result.diffCalls).toEqual([ {name: 'after', value: 'cursor3'}, - {name: 'first', value: '1'}, + {name: 'first', value: '1'} ]); }); it('should retrieve info for first() query given optimistic data', () => { var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -1805,7 +1805,7 @@ describe('GraphQLRange', () => { result = range.retrieveRangeInfoForQuery( [{name: 'first', value: '2'}], { - 'remove': [edge1.__dataID__], + 'remove': [edge1.__dataID__] } ); @@ -1818,7 +1818,7 @@ describe('GraphQLRange', () => { [{name: 'first', value: '3'}], { 'prepend': [edge4.__dataID__, edge5.__dataID__], - 'remove': [edge4.__dataID__, edge1.__dataID__], + 'remove': [edge4.__dataID__, edge1.__dataID__] } ); @@ -1830,12 +1830,12 @@ describe('GraphQLRange', () => { it('should retrieve info for last() query given optimistic data', () => { var queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }; range.addItems(queryCalls, last3Edges, pageInfo); @@ -1885,7 +1885,7 @@ describe('GraphQLRange', () => { [{name: 'last', value: '3'}], { 'append': [edge97.__dataID__, edge96.__dataID__], - 'remove': [edge100.__dataID__, edge96.__dataID__], + 'remove': [edge100.__dataID__, edge96.__dataID__] } ); @@ -1897,11 +1897,11 @@ describe('GraphQLRange', () => { it('should toJSON', () => { var queryCalls = [ - {name: 'first', value: '3'}, + {name: 'first', value: '3'} ]; var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(queryCalls, first3Edges, pageInfo); @@ -1930,17 +1930,17 @@ describe('GraphQLRange', () => { it('returns the DataIDs of all edges', () => { // Add a static edges var surroundQueryCalls = [ - {name: 'surrounds', value: ['id2', 1]}, + {name: 'surrounds', value: ['id2', 1]} ]; var pageInfo = { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; range.addItems(surroundQueryCalls, first3Edges, pageInfo); // Non-static edges var queryCalls = [ - {name: 'last', value: '3'}, + {name: 'last', value: '3'} ]; range.addItems(queryCalls, last3Edges, pageInfo); // Sorting the IDs to make testing easier. @@ -1950,7 +1950,7 @@ describe('GraphQLRange', () => { edge2.__dataID__, edge3.__dataID__, edge98.__dataID__, - edge99.__dataID__, + edge99.__dataID__ ]); }); }); diff --git a/src/legacy/store/__tests__/GraphQLSegment-test.js b/src/legacy/store/__tests__/GraphQLSegment-test.js index ada4461f8ca4d..cf4c5ec941e1c 100644 --- a/src/legacy/store/__tests__/GraphQLSegment-test.js +++ b/src/legacy/store/__tests__/GraphQLSegment-test.js @@ -24,76 +24,76 @@ var edges = [ { __dataID__:'edge1', node: {__dataID__: 'id1'}, - cursor: 'cursor1', + cursor: 'cursor1' }, { __dataID__:'edge2', node: {__dataID__: 'id2'}, - cursor: 'cursor2', + cursor: 'cursor2' }, { __dataID__:'edge3', node: {__dataID__: 'id3'}, - cursor: 'cursor3', - }, + cursor: 'cursor3' + } ]; var moreEdges = [ { __dataID__:'edge4', node: {__dataID__: 'id4'}, - cursor: 'cursor4', + cursor: 'cursor4' }, { __dataID__:'edge5', node: {__dataID__: 'id5'}, - cursor: 'cursor5', + cursor: 'cursor5' }, { __dataID__:'edge6', node: {__dataID__: 'id6'}, - cursor: 'cursor6', - }, + cursor: 'cursor6' + } ]; var lastEdges = [ { __dataID__:'edge98', node: {__dataID__: 'id98'}, - cursor: 'cursor98', + cursor: 'cursor98' }, { __dataID__:'edge99', node: {__dataID__: 'id99'}, - cursor: 'cursor99', + cursor: 'cursor99' }, { __dataID__:'edge100', node: {__dataID__: 'id100'}, - cursor: 'cursor100', - }, + cursor: 'cursor100' + } ]; var beforeLastEdges = [ { __dataID__:'edge95', node: {__dataID__: 'id95'}, - cursor: 'cursor95', + cursor: 'cursor95' }, { __dataID__:'edge96', node: {__dataID__: 'id96'}, - cursor: 'cursor96', + cursor: 'cursor96' }, { __dataID__:'edge97', node: {__dataID__: 'id97'}, - cursor: 'cursor97', - }, + cursor: 'cursor97' + } ]; var oneEdge = { __dataID__:'edgeOneEdge', node: {__dataID__: 'idOneEdge'}, - cursor: 'cursorOneEdge', + cursor: 'cursorOneEdge' }; var anotherEdge = { __dataID__:'edgeAnotherEdge', node: {__dataID__: 'idAnotherEdge'}, - cursor: 'cursorAnotherEdge', + cursor: 'cursorAnotherEdge' }; /** @@ -421,16 +421,16 @@ describe('GraphQLSegment', () => { { __dataID__: 'edge3', node: {__dataID__: 'id3'}, - cursor: 'cursor3', + cursor: 'cursor3' }, { __dataID__: 'edge4', node: {__dataID__: 'id4'}, - cursor: 'cursor4', + cursor: 'cursor4' }, { __dataID__: 'edge5', node: {__dataID__: 'id5'}, - cursor: 'cursor5', - }, + cursor: 'cursor5' + } ]; // deleted edge in the original segment diff --git a/src/legacy/store/__tests__/GraphQLStoreQueryResolver-test.js b/src/legacy/store/__tests__/GraphQLStoreQueryResolver-test.js index 61c1fc43a2429..3a995dcdaa9eb 100644 --- a/src/legacy/store/__tests__/GraphQLStoreQueryResolver-test.js +++ b/src/legacy/store/__tests__/GraphQLStoreQueryResolver-test.js @@ -34,7 +34,7 @@ describe('GraphQLStoreQueryResolver', () => { readRelayQueryData.mockImplementation((_, __, dataID) => { return { dataIDs: {[dataID]: true}, - data: mockResult[dataID], + data: mockResult[dataID] }; }); } @@ -83,7 +83,7 @@ describe('GraphQLStoreQueryResolver', () => { mockQueryFragment ); var mockResult = { - '1038750002': {__dataID__: '1038750002', id: '1038750002', name: 'Tim'}, + '1038750002': {__dataID__: '1038750002', id: '1038750002', name: 'Tim'} }; mockReader(mockResult); @@ -135,7 +135,7 @@ describe('GraphQLStoreQueryResolver', () => { ); mockReader({ - [mockResultA.id]: mockResultA, + [mockResultA.id]: mockResultA }); var resolvedA = resolver.resolve(fragmentPointer); @@ -143,7 +143,7 @@ describe('GraphQLStoreQueryResolver', () => { callback(['1038750002']); mockReader({ - [mockResultB.id]: mockResultB, + [mockResultB.id]: mockResultB }); var resolvedB = resolver.resolve(fragmentPointer); @@ -158,7 +158,7 @@ describe('GraphQLStoreQueryResolver', () => { mockQueryFragment ); var mockResult = { - '1038750002': {__dataID__: '1038750002', id: '1038750002', name: 'Tim'}, + '1038750002': {__dataID__: '1038750002', id: '1038750002', name: 'Tim'} }; var resolver = new GraphQLStoreQueryResolver( @@ -182,7 +182,7 @@ describe('GraphQLStoreQueryResolver', () => { ); var mockResults = { '1': {__dataID__: '1', name: 'One'}, - '2': {__dataID__: '2', name: 'Two'}, + '2': {__dataID__: '2', name: 'Two'} }; mockReader(mockResults); @@ -211,7 +211,7 @@ describe('GraphQLStoreQueryResolver', () => { ); var mockResults = { '1': {__dataID__: '1', name: 'One'}, - '2': {__dataID__: '2', name: 'Two'}, + '2': {__dataID__: '2', name: 'Two'} }; mockReader(mockResults); @@ -233,7 +233,7 @@ describe('GraphQLStoreQueryResolver', () => { ); var mockResults = { '1': {__dataID__: '1', name: 'One'}, - '2': {__dataID__: '2', name: 'Two'}, + '2': {__dataID__: '2', name: 'Two'} }; mockReader(mockResults); @@ -271,7 +271,7 @@ describe('GraphQLStoreQueryResolver', () => { ); var mockResults = { '1': {__dataID__: '1', name: 'One'}, - '2': {__dataID__: '2', name: 'Two'}, + '2': {__dataID__: '2', name: 'Two'} }; mockReader(mockResults); @@ -348,11 +348,11 @@ describe('GraphQLStoreQueryResolver', () => { ); var mockResult = { __dataID__: 'chris', - address: {__dataID__: 'address', city: 'menlo park'}, + address: {__dataID__: 'address', city: 'menlo park'} }; readRelayQueryData.mockReturnValue({ data: mockResult, - dataIDs: { chris: true, address: true }, + dataIDs: { chris: true, address: true } }); var resolver = new GraphQLStoreQueryResolver( @@ -367,17 +367,17 @@ describe('GraphQLStoreQueryResolver', () => { // On first resolve we get data for all added ids expect(getIncreaseSubscriptionsParameters(2)).toEqual([ 'address', - 'chris', + 'chris' ]); // New mock data for the resolve mockResult = { __dataID__: 'chris', - birthdate: {__dataID__: 'date', day: 15}, + birthdate: {__dataID__: 'date', day: 15} }; readRelayQueryData.mockReturnValue({ data: mockResult, - dataIDs: { chris: true, date: true }, + dataIDs: { chris: true, date: true } }); // Notify resolve that data has changed callback(['chris']); diff --git a/src/mutation/RelayMutation.js b/src/mutation/RelayMutation.js index 5c7ffc7cc5679..2ec0937738614 100644 --- a/src/mutation/RelayMutation.js +++ b/src/mutation/RelayMutation.js @@ -332,7 +332,7 @@ class RelayMutation { if (processQueryParams && !this.prepareVariables) { RelayDeprecated.warn({ was: this.name + '.getQuery', - now: this.name + '.getFragment', + now: this.name + '.getFragment' }); this.prepareVariables = (prevVariables, route) => processQueryParams(route, prevVariables); @@ -360,7 +360,7 @@ class RelayMutation { static getQuery(): RelayFragmentReference { RelayDeprecated.warn({ was: this.name + '.getQuery', - now: this.name + '.getFragment', + now: this.name + '.getFragment' }); return this.getFragment.apply(this, arguments); } diff --git a/src/mutation/RelayMutationQuery.js b/src/mutation/RelayMutationQuery.js index fe732ba51f4f1..088078062bf18 100644 --- a/src/mutation/RelayMutationQuery.js +++ b/src/mutation/RelayMutationQuery.js @@ -11,8 +11,6 @@ * @flow */ -/* eslint comma-dangle: 1 */ - 'use strict'; import type GraphQL from 'GraphQL_EXPERIMENTAL'; @@ -271,8 +269,8 @@ var RelayMutationQuery = { var children = [ nullthrows(RelayMutationQuery.buildFragmentForOptimisticUpdate({ response, - fatQuery, - })), + fatQuery + })) ]; // TODO: Can this method ever return null? Task #7705258. return nullthrows(flattenRelayQuery(RelayQuery.Node.buildMutation( @@ -312,7 +310,7 @@ var RelayMutationQuery = { null, null, {'requisite':true} - ), + ) ]; configs.forEach(config => { @@ -335,7 +333,7 @@ var RelayMutationQuery = { parentID: config.parentID, parentName: config.parentName, rangeBehaviors: config.rangeBehaviors, - tracker, + tracker })); break; @@ -346,7 +344,7 @@ var RelayMutationQuery = { fatQuery, parentID: config.parentID, parentName: config.parentName, - tracker, + tracker })); children.push(RelayQuery.Node.buildField(config.deletedIDFieldName)); break; @@ -355,7 +353,7 @@ var RelayMutationQuery = { children.push(RelayMutationQuery.buildFragmentForFields({ fatQuery, fieldIDs: config.fieldIDs, - tracker, + tracker })); break; } @@ -369,7 +367,7 @@ var RelayMutationQuery = { children, mutation.metadata ))); - }, + } }; function getFieldFromFatQuery( @@ -419,7 +417,7 @@ function buildEdgeField( edgeFields: Array ): RelayQuery.Field { var fields = [ - RelayQuery.Node.buildField('cursor'), + RelayQuery.Node.buildField('cursor') ]; if (RelayConnectionInterface.EDGES_HAVE_SOURCE_FIELD && !GraphQLStoreDataHandler.isClientID(parentID)) { diff --git a/src/mutation/RelayMutationTransaction.js b/src/mutation/RelayMutationTransaction.js index f29e9d7fc088a..160c601f62286 100644 --- a/src/mutation/RelayMutationTransaction.js +++ b/src/mutation/RelayMutationTransaction.js @@ -197,7 +197,7 @@ class RelayMutationTransaction { configs: this._getConfigs(), fatQuery: this._getFatQuery(), mutationName: this._mutation.constructor.name, - mutation: this._getMutationNode(), + mutation: this._getMutationNode() }); } return this._query; @@ -208,7 +208,7 @@ class RelayMutationTransaction { var input = { ...this._mutation.getVariables(), /* $FlowIssue #7728187 - Computed Property */ - [CLIENT_MUTATION_ID]: this._id, + [CLIENT_MUTATION_ID]: this._id }; this._variables = {input}; } @@ -239,14 +239,14 @@ class RelayMutationTransaction { configs: optimisticConfigs, fatQuery: this._getFatQuery(), mutationName: this._mutation.constructor.name, - mutation: this._getMutationNode(), + mutation: this._getMutationNode() }); } else { this._optimisticQuery = RelayMutationQuery.buildQueryForOptimisticUpdate({ response: optimisticResponse, fatQuery: this._getFatQuery(), - mutation: this._getMutationNode(), + mutation: this._getMutationNode() }); } } else { diff --git a/src/mutation/RelayMutationTransactionStatus.js b/src/mutation/RelayMutationTransactionStatus.js index c42fd4cbec078..03d1926d91352 100644 --- a/src/mutation/RelayMutationTransactionStatus.js +++ b/src/mutation/RelayMutationTransactionStatus.js @@ -43,7 +43,7 @@ var RelayMutationTransactionStatus = { /** * Transaction was sent to the server for comitting but was failed. */ - COMMIT_FAILED: 'COMMIT_FAILED', + COMMIT_FAILED: 'COMMIT_FAILED' }; module.exports = RelayMutationTransactionStatus; diff --git a/src/mutation/RelayMutationType.js b/src/mutation/RelayMutationType.js index 144985fa99a83..5d8695a3aa715 100644 --- a/src/mutation/RelayMutationType.js +++ b/src/mutation/RelayMutationType.js @@ -18,7 +18,7 @@ var RelayMutationType = { NODE_DELETE: 'NODE_DELETE', RANGE_ADD: 'RANGE_ADD', RANGE_DELETE: 'RANGE_DELETE', - REQUIRED_CHILDREN: 'REQUIRED_CHILDREN', + REQUIRED_CHILDREN: 'REQUIRED_CHILDREN' }; module.exports = RelayMutationType; diff --git a/src/mutation/__tests__/RelayMutation-test.js b/src/mutation/__tests__/RelayMutation-test.js index 25633f71a30da..0976503c5971d 100644 --- a/src/mutation/__tests__/RelayMutation-test.js +++ b/src/mutation/__tests__/RelayMutation-test.js @@ -50,7 +50,7 @@ describe('RelayMutation', function() { fragment on Node { id, } - `, + ` }; return MockMutationClass; }; @@ -69,7 +69,7 @@ describe('RelayMutation', function() { it('resolves props', () => { new MockMutation({ bar: mockBarPointer, - foo: mockFooPointer, + foo: mockFooPointer }); expect(Relay.Store.read.mock.calls.length).toBe(2); @@ -84,7 +84,7 @@ describe('RelayMutation', function() { it('throws if mutation defines invalid `Relay.QL` fragment', () => { class BadMutation extends Relay.Mutation {} BadMutation.fragments = { - foo: () => Relay.QL`query{node(id:"123"){id}}`, + foo: () => Relay.QL`query{node(id:"123"){id}}` }; var badFragmentReference = BadMutation.getFragment('foo'); expect(() => { diff --git a/src/mutation/__tests__/RelayMutationQuery-test.js b/src/mutation/__tests__/RelayMutationQuery-test.js index f61113d468f62..53022d6c03d03 100644 --- a/src/mutation/__tests__/RelayMutationQuery-test.js +++ b/src/mutation/__tests__/RelayMutationQuery-test.js @@ -76,8 +76,8 @@ describe('RelayMutationQuery', () => { fatQuery, tracker, fieldIDs: { - unsubscribee: '4', - }, + unsubscribee: '4' + } }); }).toFailInvariant( 'RelayMutationQuery: Invalid field name on fat query, `unsubscribee`.' @@ -103,8 +103,8 @@ describe('RelayMutationQuery', () => { fatQuery, tracker, fieldIDs: { - feedback: '123', - }, + feedback: '123' + } }); var expected = getNodeWithoutSource(Relay.QL` fragment on FeedbackLikeResponsePayload { @@ -116,7 +116,7 @@ describe('RelayMutationQuery', () => { expect(flattenRelayQuery(node)) .toEqualQueryNode(flattenRelayQuery(expected)); expect(tracker.getTrackedChildrenForID.mock.calls).toEqual([ - ['123'], + ['123'] ]); }); @@ -140,8 +140,8 @@ describe('RelayMutationQuery', () => { fatQuery, tracker, fieldIDs: { - stories: ['123'], - }, + stories: ['123'] + } }); var expected = getNodeWithoutSource(Relay.QL` fragment on ViewerNotificationsUpdateAllSeenStateResponsePayload { @@ -153,7 +153,7 @@ describe('RelayMutationQuery', () => { expect(flattenRelayQuery(node)) .toEqualQueryNode(flattenRelayQuery(expected)); expect(tracker.getTrackedChildrenForID.mock.calls).toEqual([ - ['123'], + ['123'] ]); }); @@ -180,7 +180,7 @@ describe('RelayMutationQuery', () => { }, seenState } - `), + `) }; tracker.getTrackedChildrenForID.mockImplementation( dataID => [trackedNodes[dataID]] @@ -189,8 +189,8 @@ describe('RelayMutationQuery', () => { fatQuery, tracker, fieldIDs: { - stories: ['123', '456'], - }, + stories: ['123', '456'] + } }); var node = intersectRelayQuery.mock.calls[0][0]; var expected = getNodeWithoutSource(Relay.QL` @@ -209,7 +209,7 @@ describe('RelayMutationQuery', () => { .toEqualQueryNode(flattenRelayQuery(expected)); expect(tracker.getTrackedChildrenForID.mock.calls).toEqual([ ['123'], - ['456'], + ['456'] ]); }); }); @@ -234,7 +234,7 @@ describe('RelayMutationQuery', () => { tracker, connectionName: 'comments', parentID: '123', - parentName: 'story', + parentName: 'story' }); }).toFailInvariant( 'RelayMutationQuery: Invalid field name on fat query, `story`.' @@ -262,7 +262,7 @@ describe('RelayMutationQuery', () => { tracker, connectionName: 'comments', parentID: '123', - parentName: 'feedback', + parentName: 'feedback' }); var expected = getNodeWithoutSource(Relay.QL` fragment on CommentDeleteResponsePayload { @@ -276,7 +276,7 @@ describe('RelayMutationQuery', () => { expect(flattenRelayQuery(node)) .toEqualQueryNode(flattenRelayQuery(expected)); expect(tracker.getTrackedChildrenForID.mock.calls).toEqual([ - ['123'], + ['123'] ]); }); }); @@ -303,7 +303,7 @@ describe('RelayMutationQuery', () => { `); rangeBehaviors = { '': GraphQLMutatorConstants.PREPEND, - 'orderby(toplevel)': GraphQLMutatorConstants.PREPEND, + 'orderby(toplevel)': GraphQLMutatorConstants.PREPEND }; }); @@ -327,7 +327,7 @@ describe('RelayMutationQuery', () => { connectionName: 'comments', parentID: '123', edgeName: 'feedbackCommentEdge', - rangeBehaviors, + rangeBehaviors }); var expected = getNodeWithoutSource(Relay.QL` fragment on CommentCreateResponsePayload { @@ -348,7 +348,7 @@ describe('RelayMutationQuery', () => { expect(flattenRelayQuery(node)) .toEqualQueryNode(flattenRelayQuery(expected)); expect(tracker.getTrackedChildrenForID.mock.calls).toEqual([ - ['123'], + ['123'] ]); }); @@ -382,7 +382,7 @@ describe('RelayMutationQuery', () => { connectionName: 'comments', parentID: '123', edgeName: 'feedbackCommentEdge', - rangeBehaviors, + rangeBehaviors }); var expected = getNodeWithoutSource(Relay.QL` fragment on CommentCreateResponsePayload { @@ -437,7 +437,7 @@ describe('RelayMutationQuery', () => { connectionName: 'comments', parentID: '123', edgeName: 'feedbackCommentEdge', - rangeBehaviors, + rangeBehaviors }); var expected = getNodeWithoutSource(Relay.QL` fragment on CommentCreateResponsePayload { @@ -480,7 +480,7 @@ describe('RelayMutationQuery', () => { parentID: '123', edgeName: 'feedbackCommentEdge', parentName: 'feedback', - rangeBehaviors, + rangeBehaviors }); var expected = getNodeWithoutSource(Relay.QL` fragment on CommentCreateResponsePayload { @@ -516,7 +516,7 @@ describe('RelayMutationQuery', () => { parentID: '123', edgeName: 'feedbackCommentEdge', parentName: 'feedback', - rangeBehaviors, + rangeBehaviors }); var expected = getNodeWithoutSource(Relay.QL` fragment on CommentCreateResponsePayload { @@ -547,7 +547,7 @@ describe('RelayMutationQuery', () => { parentID: '123', edgeName: 'feedbackCommentEdge', parentName: 'story', - rangeBehaviors, + rangeBehaviors }); }).toFailInvariant( 'RelayMutationQuery: Invalid field name on fat query, `story`.' @@ -575,7 +575,7 @@ describe('RelayMutationQuery', () => { var mockData = {}; RelayMutationQuery.buildFragmentForOptimisticUpdate({ response: mockData, - fatQuery, + fatQuery }); expect(inferRelayFieldsFromData.mock.calls.length).toBe(1); @@ -600,12 +600,12 @@ describe('RelayMutationQuery', () => { doesViewerLike: true, id: '1', likers: { - count: 4, - }, - }, + count: 4 + } + } }, fatQuery, - mutation, + mutation }); var variables = {input: ''}; @@ -662,7 +662,7 @@ describe('RelayMutationQuery', () => { var connectionName = 'comments'; var edgeName = 'feedbackCommentEdge'; var rangeBehaviors = { - '': GraphQLMutatorConstants.PREPEND, + '': GraphQLMutatorConstants.PREPEND }; var configs = [ { @@ -671,8 +671,8 @@ describe('RelayMutationQuery', () => { parentID, connectionName, edgeName, - rangeBehaviors, - }, + rangeBehaviors + } ]; var mutation = Relay.QL`mutation{commentCreate(input:$input)}`; @@ -683,7 +683,7 @@ describe('RelayMutationQuery', () => { fatQuery, configs, mutationName, - mutation, + mutation }); var expectedMutationQuery = getNodeWithoutSource(Relay.QL` @@ -745,8 +745,8 @@ describe('RelayMutationQuery', () => { parentName, parentID, connectionName, - deletedIDFieldName, - }, + deletedIDFieldName + } ]; var mutation = Relay.QL`mutation{commentDelete(input:$input)}`; @@ -757,7 +757,7 @@ describe('RelayMutationQuery', () => { fatQuery, configs, mutationName, - mutation, + mutation }); var expectedMutationQuery = getNodeWithoutSource(Relay.QL` @@ -808,8 +808,8 @@ describe('RelayMutationQuery', () => { parentName, parentID, connectionName, - deletedIDFieldName, - }, + deletedIDFieldName + } ]; var mutation = Relay.QL`mutation{commentDelete(input:$input)}`; @@ -820,7 +820,7 @@ describe('RelayMutationQuery', () => { fatQuery, configs, mutationName, - mutation, + mutation }); var expectedMutationQuery = getNodeWithoutSource(Relay.QL` @@ -855,13 +855,13 @@ describe('RelayMutationQuery', () => { } `); var fieldIDs = { - feedback: '123', + feedback: '123' }; var configs = [ { type: RelayMutationType.FIELDS_CHANGE, - fieldIDs, - }, + fieldIDs + } ]; var mutation = Relay.QL`mutation{feedbackLike(input:$input)}`; @@ -872,7 +872,7 @@ describe('RelayMutationQuery', () => { fatQuery, configs, mutationName, - mutation, + mutation }); var expectedMutationQuery = getNodeWithoutSource(Relay.QL` @@ -923,7 +923,7 @@ describe('RelayMutationQuery', () => { var connectionName = 'comments'; var edgeName = 'feedbackCommentEdge'; var rangeBehaviors = { - '': GraphQLMutatorConstants.PREPEND, + '': GraphQLMutatorConstants.PREPEND }; var configs = [ { @@ -932,7 +932,7 @@ describe('RelayMutationQuery', () => { parentID, connectionName, edgeName, - rangeBehaviors, + rangeBehaviors }, { type: RelayMutationType.REQUIRED_CHILDREN, @@ -942,8 +942,8 @@ describe('RelayMutationQuery', () => { doesViewerLike, }, } - `], - }, + `] + } ]; var mutation = Relay.QL`mutation{commentCreate(input:$input)}`; @@ -954,7 +954,7 @@ describe('RelayMutationQuery', () => { fatQuery, configs, mutationName, - mutation, + mutation }); var expectedMutationQuery = getNodeWithoutSource(Relay.QL` @@ -1022,10 +1022,10 @@ describe('RelayMutationQuery', () => { var connectionName = 'comments'; var edgeName = 'feedbackCommentEdge'; var rangeBehaviors = { - '': GraphQLMutatorConstants.PREPEND, + '': GraphQLMutatorConstants.PREPEND }; var fieldIDs = { - feedback: '123', + feedback: '123' }; var configs = [ { @@ -1034,12 +1034,12 @@ describe('RelayMutationQuery', () => { parentID, connectionName, edgeName, - rangeBehaviors, + rangeBehaviors }, { type: RelayMutationType.FIELDS_CHANGE, - fieldIDs, - }, + fieldIDs + } ]; var mutation = Relay.QL`mutation{commentCreate(input:$input)}`; @@ -1050,7 +1050,7 @@ describe('RelayMutationQuery', () => { fatQuery, configs, mutationName, - mutation, + mutation }); var expectedMutationQuery = getNodeWithoutSource(Relay.QL` diff --git a/src/mutation/__tests__/RelayMutationTransaction-test.js b/src/mutation/__tests__/RelayMutationTransaction-test.js index 9d31e743e9955..68be451021d22 100644 --- a/src/mutation/__tests__/RelayMutationTransaction-test.js +++ b/src/mutation/__tests__/RelayMutationTransaction-test.js @@ -85,12 +85,12 @@ describe('RelayMutationTransaction', () => { configs: 'optimisticConfigs', fatQuery: 'fatQuery', mutation: mutationNode, - mutationName: 'RelayMutation', + mutationName: 'RelayMutation' }]]); expect(storeData.handleUpdatePayload.mock.calls).toEqual([[ 'optimisticQuery', {[RelayConnectionInterface.CLIENT_MUTATION_ID]: '0'}, - {configs: 'optimisticConfigs', isOptimisticUpdate: true}, + {configs: 'optimisticConfigs', isOptimisticUpdate: true} ]]); }); @@ -108,13 +108,13 @@ describe('RelayMutationTransaction', () => { fatQuery: 'fatQuery', mutation: mutationNode, response: { - [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', - }, + [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0' + } }]]); expect(storeData.handleUpdatePayload.mock.calls).toEqual([[ 'optimisticQuery', {[RelayConnectionInterface.CLIENT_MUTATION_ID]: '0'}, - {configs: 'configs', isOptimisticUpdate: true}, + {configs: 'configs', isOptimisticUpdate: true} ]]); }); }); @@ -413,7 +413,7 @@ describe('RelayMutationTransaction', () => { ); transaction1.commit({ onSuccess: successCallback1, - onFailure: failureCallback1, + onFailure: failureCallback1 }); expect(RelayNetworkLayer.sendMutation.mock.calls.length).toBe(1); diff --git a/src/network-layer/default/RelayDefaultNetworkLayer.js b/src/network-layer/default/RelayDefaultNetworkLayer.js index 9e5e59a2573f4..123a6777be033 100644 --- a/src/network-layer/default/RelayDefaultNetworkLayer.js +++ b/src/network-layer/default/RelayDefaultNetworkLayer.js @@ -119,17 +119,17 @@ class RelayDefaultNetworkLayer { } init = { body: formData, - method: 'POST', + method: 'POST' }; } else { init = { body: JSON.stringify({ query: request.getQueryString(), - variables: request.getVariables(), + variables: request.getVariables() }), headers: {'Content-Type': 'application/json'}, method: 'POST', - credentials: 'same-origin', + credentials: 'same-origin' }; } return fetch(this._uri, init).then(throwOnServerError); @@ -142,13 +142,13 @@ class RelayDefaultNetworkLayer { return fetchWithRetries(this._uri, { body: JSON.stringify({ query: request.getQueryString(), - variables: request.getVariables(), + variables: request.getVariables() }), fetchTimeout: this._timeout, headers: {'Content-Type': 'application/json'}, method: 'POST', retryDelays: this._retryDelays, - credentials: 'same-origin', + credentials: 'same-origin' }); } } @@ -186,7 +186,7 @@ function formatRequestErrors( var offset = Math.min(column - 1, CONTEXT_BEFORE); return [ queryLine.substr(column - 1 - offset, CONTEXT_LENGTH), - ' '.repeat(offset) + '^^^', + ' '.repeat(offset) + '^^^' ].map(messageLine => indent + messageLine).join('\n'); }).join('\n') ); diff --git a/src/network-layer/default/__tests__/RelayDefaultNetworkLayer-test.js b/src/network-layer/default/__tests__/RelayDefaultNetworkLayer-test.js index adf5713157694..ab7c674eda9a2 100644 --- a/src/network-layer/default/__tests__/RelayDefaultNetworkLayer-test.js +++ b/src/network-layer/default/__tests__/RelayDefaultNetworkLayer-test.js @@ -33,7 +33,7 @@ describe('RelayDefaultNetworkLayer', () => { function genResponse(data) { return { json: () => Promise.resolve(data), - status: 200, + status: 200 }; } @@ -55,7 +55,7 @@ describe('RelayDefaultNetworkLayer', () => { networkConfig = { uri: '/graphql', timeout: 15000, - retryDelays: [1000, 3000], + retryDelays: [1000, 3000] }; // Spread properties to test that functions are bound correctly. networkLayer = { @@ -63,7 +63,7 @@ describe('RelayDefaultNetworkLayer', () => { networkConfig.uri, networkConfig.timeout, networkConfig.retryDelays - ), + ) }; jest.addMatchers(RelayTestUtils.matchers); @@ -89,8 +89,8 @@ describe('RelayDefaultNetworkLayer', () => { variables = { input: { [RelayConnectionInterface.CLIENT_MUTATION_ID]: 'client:a', - actor_id: 4, - }, + actor_id: 4 + } }; request = new RelayMutationRequest(mutation, variables); request.getPromise().then(responseCallback).catch(rejectCallback); @@ -107,11 +107,11 @@ describe('RelayDefaultNetworkLayer', () => { expect(method).toBe('POST'); expect(headers).toEqual({ - 'Content-Type': 'application/json', + 'Content-Type': 'application/json' }); expect(body).toEqual(JSON.stringify({ query: request.getQueryString(), - variables: variables, + variables: variables })); }); @@ -119,9 +119,9 @@ describe('RelayDefaultNetworkLayer', () => { var response = { data: { test_call: { - field: 1, - }, - }, + field: 1 + } + } }; expect(fetch).not.toBeCalled(); @@ -134,7 +134,7 @@ describe('RelayDefaultNetworkLayer', () => { expect(rejectCallback.mock.calls.length).toBe(0); expect(responseCallback.mock.calls.length).toBe(1); expect(responseCallback.mock.calls[0][0]).toEqual({ - response: response.data, + response: response.data }); }); @@ -144,9 +144,9 @@ describe('RelayDefaultNetworkLayer', () => { message: 'Something went wrong.', locations: [{ column: 10, - line: 1, - }], - }], + line: 1 + }] + }] }; expect(fetch).not.toBeCalled(); @@ -165,7 +165,7 @@ describe('RelayDefaultNetworkLayer', () => { '', '1. Something went wrong.', ' ' + request.getQueryString().substr(0, 60), - ' ^^^', + ' ^^^' ].join('\n')); expect(error.source).toEqual(response); }); @@ -195,7 +195,7 @@ describe('RelayDefaultNetworkLayer', () => { var {body, fetchTimeout, method, retryDelays} = call[1]; expect(body).toBe(JSON.stringify({ query: requestA.getQueryString(), - variables: queryA.getVariables(), + variables: queryA.getVariables() })); expect(fetchTimeout).toBe(networkConfig.timeout); expect(method).toBe('POST'); @@ -211,10 +211,10 @@ describe('RelayDefaultNetworkLayer', () => { jest.runAllTimers(); var payloadA = { - data: {'123': {id: '123'}}, + data: {'123': {id: '123'}} }; var payloadB = { - data: {'456': {id: '456'}}, + data: {'456': {id: '456'}} }; fetchWithRetries.mock.deferreds[0].resolve(genResponse(payloadA)); fetchWithRetries.mock.deferreds[1].resolve(genResponse(payloadB)); @@ -222,11 +222,11 @@ describe('RelayDefaultNetworkLayer', () => { expect(resolveACallback.mock.calls.length).toBe(1); expect(resolveACallback.mock.calls[0][0]).toEqual({ - response: payloadA.data, + response: payloadA.data }); expect(resolveBCallback.mock.calls.length).toBe(1); expect(resolveBCallback.mock.calls[0][0]).toEqual({ - response: payloadB.data, + response: payloadB.data }); }); @@ -238,7 +238,7 @@ describe('RelayDefaultNetworkLayer', () => { fetchWithRetries.mock.deferreds[0].resolve({ json: () => Promise.reject(JSON.parse('{ // invalid')), - status: 200, + status: 200 }); jest.runAllTimers(); @@ -260,9 +260,9 @@ describe('RelayDefaultNetworkLayer', () => { message: 'Something went wrong.', locations: [{ column: 7, - line: 1, - }], - }], + line: 1 + }] + }] }; fetchWithRetries.mock.deferreds[0].resolve(genResponse(payloadA)); jest.runAllTimers(); @@ -275,7 +275,7 @@ describe('RelayDefaultNetworkLayer', () => { '', '1. Something went wrong.', ' ' + requestA.getQueryString().substr(0, 60), - ' ^^^', + ' ^^^' ].join('\n')); expect(error.source).toEqual(payloadA); }); @@ -289,7 +289,7 @@ describe('RelayDefaultNetworkLayer', () => { jest.runAllTimers(); var payload = { - data: {'456': {id: '456'}}, + data: {'456': {id: '456'}} }; fetchWithRetries.mock.deferreds[0].resolve(genResponse({})); fetchWithRetries.mock.deferreds[1].resolve(genResponse(payload)); diff --git a/src/network/RelayNetworkLayer.js b/src/network/RelayNetworkLayer.js index 102b1d790243b..045aa6af7bdd3 100644 --- a/src/network/RelayNetworkLayer.js +++ b/src/network/RelayNetworkLayer.js @@ -56,7 +56,7 @@ var RelayNetworkLayer = { supports(...options: Array): boolean { var networkLayer = getCurrentNetworkLayer(); return networkLayer.supports(...options); - }, + } }; function getCurrentNetworkLayer(): NetworkLayer { diff --git a/src/network/__mocks__/fetchRelayQuery.js b/src/network/__mocks__/fetchRelayQuery.js index 39ec68bad1bfc..fb78241f1742b 100644 --- a/src/network/__mocks__/fetchRelayQuery.js +++ b/src/network/__mocks__/fetchRelayQuery.js @@ -34,7 +34,7 @@ function genMockRequest(resolve, reject) { resolve(response, error) { resolve({error: error || null, response}); }, - reject, + reject }); } diff --git a/src/network/__tests__/RelayNetworkLayer-test.js b/src/network/__tests__/RelayNetworkLayer-test.js index ed28d42aa2281..78d7d104807ae 100644 --- a/src/network/__tests__/RelayNetworkLayer-test.js +++ b/src/network/__tests__/RelayNetworkLayer-test.js @@ -32,7 +32,7 @@ describe('RelayNetworkLayer', () => { injectedNetworkLayer = { sendMutation: jest.genMockFunction(), sendQueries: jest.genMockFunction(), - supports: jest.genMockFunction(), + supports: jest.genMockFunction() }; RelayNetworkLayer.injectNetworkLayer(injectedNetworkLayer); diff --git a/src/query/RelayQL.js b/src/query/RelayQL.js index 3a73ce1bcaafc..8693979ca00d1 100644 --- a/src/query/RelayQL.js +++ b/src/query/RelayQL.js @@ -80,7 +80,7 @@ Object.assign(RelayQL, { ); } return substitution; - }, + } }); module.exports = RelayQL; diff --git a/src/query/RelayQuery.js b/src/query/RelayQuery.js index 05935e7135edb..1ffc9fb8d10aa 100644 --- a/src/query/RelayQuery.js +++ b/src/query/RelayQuery.js @@ -501,7 +501,7 @@ class RelayQueryRoot extends RelayQueryNode { batchCall = { refParamName: REF_PARAM_PREFIX + callArg.sourceQueryID, sourceQueryID: callArg.sourceQueryID, - sourceQueryPath: callArg.jsonPath, + sourceQueryPath: callArg.jsonPath }; } else { batchCall = null; @@ -975,7 +975,7 @@ class RelayQueryField extends RelayQueryNode { field.__children__ = []; field.__metadata__ = { ...field.__metadata__, - isRefQueryDependency: true, + isRefQueryDependency: true }; return field; } @@ -1156,5 +1156,5 @@ module.exports = { Node: RelayQueryNode, Operation: RelayQueryOperation, Root: RelayQueryRoot, - Subscription: RelayQuerySubscription, + Subscription: RelayQuerySubscription }; diff --git a/src/query/RelayQueryPath.js b/src/query/RelayQueryPath.js index 11fad193932a0..c768b6e9016c8 100644 --- a/src/query/RelayQueryPath.js +++ b/src/query/RelayQueryPath.js @@ -151,7 +151,7 @@ class RelayQueryPath { [child, (node: $FlowIssue).getFieldByStorageKey('id')], { ...node.__concreteNode__.metatada, - rootArg: node.getRootCallArgument(), + rootArg: node.getRootCallArgument() }, this.getName() ); diff --git a/src/query/RelayQuerySerializer.js b/src/query/RelayQuerySerializer.js index f428352603c37..49c138a0df50f 100644 --- a/src/query/RelayQuerySerializer.js +++ b/src/query/RelayQuerySerializer.js @@ -144,7 +144,7 @@ var RelayQuerySerializer = { alias: alias !== name ? alias : null, calls: node.getCallsWithValues(), children, - metadata: node.__concreteNode__.__metadata__, + metadata: node.__concreteNode__.__metadata__ }; } else if (node instanceof RelayQuery.Fragment) { return { @@ -155,8 +155,8 @@ var RelayQuerySerializer = { metadata: { ...node.__concreteNode__.__metadata__, isDeferred: node.isDeferred(), - isReferenceFragment: node.isReferenceFragment(), - }, + isReferenceFragment: node.isReferenceFragment() + } }; } else { invariant( @@ -171,10 +171,10 @@ var RelayQuerySerializer = { name: node.getName(), calls: [rootCall], children, - metadata: node.__concreteNode__.__metadata__, + metadata: node.__concreteNode__.__metadata__ }; } - }, + } }; module.exports = RelayQuerySerializer; diff --git a/src/query/__tests__/RelayFragmentReference-test.js b/src/query/__tests__/RelayFragmentReference-test.js index 4e1e849f6ce53..30950e466e931 100644 --- a/src/query/__tests__/RelayFragmentReference-test.js +++ b/src/query/__tests__/RelayFragmentReference-test.js @@ -46,7 +46,7 @@ describe('RelayFragmentReference', () => { var reference = new RelayFragmentReference( () => node, { - size: 'default', + size: 'default' } ); var variables = {size: 'ignored'}; @@ -54,7 +54,7 @@ describe('RelayFragmentReference', () => { // size ignored because no variables are passed into the fragment expect(reference.getFragment(variables)).toBe(node); expect(reference.getVariables(route, variables)).toEqual({ - size: 'default', + size: 'default' }); }); @@ -70,24 +70,24 @@ describe('RelayFragmentReference', () => { var reference = new RelayFragmentReference( () => node, { - size: 'default', + size: 'default' }, { - size: new GraphQL.CallVariable('outerSize'), + size: new GraphQL.CallVariable('outerSize') } ); // no outer variable, default is used var variables = {}; expect(reference.getFragment(variables)).toBe(node); expect(reference.getVariables(route, variables)).toEqual({ - size: 'default', + size: 'default' }); // outer variable overrides inner default variables = {outerSize: 'override'}; expect(reference.getFragment(variables)).toBe(node); expect(reference.getVariables(route, variables)).toEqual({ - size: 'override', + size: 'override' }); }); @@ -127,7 +127,7 @@ describe('RelayFragmentReference', () => { var reference = new RelayFragmentReference( () => node, { - size: 'default', + size: 'default' }, {}, prepareVariables @@ -135,7 +135,7 @@ describe('RelayFragmentReference', () => { var customVariables = { size: 'override', - other: 'custom', + other: 'custom' }; prepareVariables.mockImplementation(() => customVariables); diff --git a/src/query/__tests__/RelayQuery-getCallsWithValues-test.js b/src/query/__tests__/RelayQuery-getCallsWithValues-test.js index afd9725e608ee..30b90c9cc89f5 100644 --- a/src/query/__tests__/RelayQuery-getCallsWithValues-test.js +++ b/src/query/__tests__/RelayQuery-getCallsWithValues-test.js @@ -41,7 +41,7 @@ describe('RelayQueryNode.prototype.getCallsWithValues()', function() { var field = getProfilePicture(); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: null, + value: null }]); }); @@ -49,7 +49,7 @@ describe('RelayQueryNode.prototype.getCallsWithValues()', function() { var field = getProfilePicture(new GraphQL.CallValue(32)); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: 32, + value: 32 }]); }); }); @@ -57,41 +57,41 @@ describe('RelayQueryNode.prototype.getCallsWithValues()', function() { describe('with variables', () => { it('return `null` for empty values', () => { var field = getProfilePicture(new GraphQL.CallVariable('size'), { - size: null, + size: null }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: null, + value: null }]); }); it('return empty arrays', () => { var field = getProfilePicture(new GraphQL.CallVariable('size'), { - size: [], + size: [] }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [], + value: [] }]); }); it('return singular values', () => { var field = getProfilePicture(new GraphQL.CallVariable('size'), { - size: 32, + size: 32 }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: 32, + value: 32 }]); }); it('return array values', () => { var field = getProfilePicture(new GraphQL.CallVariable('size'), { - size: [32], + size: [32] }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [32], + value: [32] }]); }); }); @@ -103,17 +103,17 @@ describe('RelayQueryNode.prototype.getCallsWithValues()', function() { var field = getProfilePicture([]); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [], + value: [] }]); }); it('return an array of values', () => { var field = getProfilePicture([ - new GraphQL.CallValue(64), + new GraphQL.CallValue(64) ]); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [64], + value: [64] }]); }); }); @@ -121,55 +121,55 @@ describe('RelayQueryNode.prototype.getCallsWithValues()', function() { describe('with variable', () => { it('return `[null]` for empty values', () => { var field = getProfilePicture([new GraphQL.CallVariable('size')], { - size: null, + size: null }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [null], + value: [null] }]); }); it('return empty arrays', () => { var field = getProfilePicture([new GraphQL.CallVariable('size')], { - size: [], + size: [] }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [[]], + value: [[]] }]); }); it('return arrays for singular values', () => { var field = getProfilePicture([new GraphQL.CallVariable('size')], { - size: 32, + size: 32 }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [32], + value: [32] }]); }); it('return nested ararys for array values', () => { var field = getProfilePicture([new GraphQL.CallVariable('size')], { - size: [32], + size: [32] }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [[32]], + value: [[32]] }]); }); it('returns flat arrays for scalar values', () => { var field = getProfilePicture([ new GraphQL.CallVariable('width'), - new GraphQL.CallVariable('height'), + new GraphQL.CallVariable('height') ], { width: 32, - height: 64, + height: 64 }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [32, 64], + value: [32, 64] }]); }); }); diff --git a/src/query/__tests__/RelayQuery-test.js b/src/query/__tests__/RelayQuery-test.js index 0b50f38b5cfe5..14da1f75a581e 100644 --- a/src/query/__tests__/RelayQuery-test.js +++ b/src/query/__tests__/RelayQuery-test.js @@ -162,14 +162,14 @@ describe('RelayQuery', () => { new GraphQL.BatchCallVariable('q0', '$.*.actor.id'), [ new GraphQL.Field('id'), - new GraphQL.Field('name'), + new GraphQL.Field('name') ] )); var batchCall = root.getBatchCall(); expect(batchCall).toEqual({ refParamName: 'ref_q0', sourceQueryID: 'q0', - sourceQueryPath: '$.*.actor.id', + sourceQueryPath: '$.*.actor.id' }); }); @@ -257,7 +257,7 @@ describe('RelayQuery', () => { new GraphQL.BatchCallVariable('q0', '$.*.actor.id'), [ new GraphQL.Field('id'), - new GraphQL.Field('name'), + new GraphQL.Field('name') ] )); var other = getNode(new GraphQL.Query( @@ -265,7 +265,7 @@ describe('RelayQuery', () => { new GraphQL.BatchCallVariable('q0', '$.*.actor.id'), [ new GraphQL.Field('id'), - new GraphQL.Field('name'), + new GraphQL.Field('name') ] )); expect(node.equals(other)).toBe(true); @@ -277,7 +277,7 @@ describe('RelayQuery', () => { new GraphQL.BatchCallVariable('q0', '$.*.actor.id'), [ new GraphQL.Field('id'), - new GraphQL.Field('name'), + new GraphQL.Field('name') ] )); var other = getNode(new GraphQL.Query( @@ -285,7 +285,7 @@ describe('RelayQuery', () => { new GraphQL.BatchCallVariable('q0', '$.*.actor.current_city.id'), [ new GraphQL.Field('id'), - new GraphQL.Field('name'), + new GraphQL.Field('name') ] )); expect(node.equals(other)).toBe(false); @@ -672,7 +672,7 @@ describe('RelayQuery', () => { `; var variables = { after: 'offset', - first: 10, + first: 10 }; friendVariable = getNode(friendVariableRQL, variables).getChildren()[0]; expect(friendVariable.getSchemaName()).toBe('friends'); @@ -860,7 +860,7 @@ describe('RelayQuery', () => { `; var variables = { width: null, - height: undefined, + height: undefined }; var pictureField = getNode(pictureFragment, variables).getChildren()[0]; expect(pictureField.getCallsWithValues()).toEqual([ @@ -868,9 +868,9 @@ describe('RelayQuery', () => { name: 'size', value: [ null, - undefined, - ], - }, + undefined + ] + } ]); }); @@ -898,7 +898,7 @@ describe('RelayQuery', () => { `; var variables = { height: 64, - width: 32, + width: 32 }; var pictureVariable = getNode(pictureVariableRQL, variables).getChildren()[0]; @@ -971,7 +971,7 @@ describe('RelayQuery', () => { `; var variables = { height: 64, - width: 32, + width: 32 }; var pictureVariable = getNode(pictureVariableRQL, variables).getChildren()[0]; @@ -984,12 +984,12 @@ describe('RelayQuery', () => { expect(friendScalar.getCallsWithValues()).toEqual([ {name: 'first', value: '10'}, {name: 'after', value: 'offset'}, - {name: 'orderby', value: 'name'}, + {name: 'orderby', value: 'name'} ]); // variables return their values expect(friendVariable.getCallsWithValues()).toEqual([ {name: 'first', value: 10}, - {name: 'after', value: 'offset'}, + {name: 'after', value: 'offset'} ]); var pictureScalarRQL = Relay.QL` @@ -999,7 +999,7 @@ describe('RelayQuery', () => { `; var pictureScalar = getNode(pictureScalarRQL).getChildren()[0]; expect(pictureScalar.getCallsWithValues()).toEqual([ - {name: 'size', value: ['32', '64']}, + {name: 'size', value: ['32', '64']} ]); var pictureVariableRQL = Relay.QL` @@ -1009,12 +1009,12 @@ describe('RelayQuery', () => { `; var variables = { height: '64', - width: 32, + width: 32 }; var pictureVariable = getNode(pictureVariableRQL, variables).getChildren()[0]; expect(pictureVariable.getCallsWithValues()).toEqual([ - {name: 'size', value: [32, '64']}, + {name: 'size', value: [32, '64']} ]); }); @@ -1039,7 +1039,7 @@ describe('RelayQuery', () => { ); expect(clonedFeed.getSchemaName()).toBe('friends'); expect(clonedFeed.getCallsWithValues()).toEqual([ - {name: 'first', value: 25}, + {name: 'first', value: 25} ]); expect(clonedFeed.getSerializationKey()).toEqual( generateRQLFieldAlias('friends.first(25)') @@ -1050,7 +1050,7 @@ describe('RelayQuery', () => { friendVariable.getChildren(), [ {name: 'first', value: 10}, - {name: 'after', value: 'offset'}, + {name: 'after', value: 'offset'} ] ); expect(clonedFeed).toBe(friendVariable); @@ -1137,8 +1137,8 @@ describe('RelayQuery', () => { actor: 'actor:id', feedback_id: 'feedback:id', message: { - text: 'comment!', - }, + text: 'comment!' + } }); var mutationQuery = getNode(Relay.QL` mutation { @@ -1157,7 +1157,7 @@ describe('RelayQuery', () => { ); expect(mutationQuery.getCall()).toEqual({ name: 'commentCreate', - value: input, + value: input }); var children = mutationQuery.getChildren(); expect(children.length).toBe(2); @@ -1178,8 +1178,8 @@ describe('RelayQuery', () => { actor: 'actor:id', feedback_id: 'feedback:id', message: { - text: 'comment!', - }, + text: 'comment!' + } }); var mutationQuery = getNode(Relay.QL` mutation { @@ -1214,8 +1214,8 @@ describe('RelayQuery', () => { actor: 'actor:id', feedback_id: 'feedback:id', message: { - text: 'comment!', - }, + text: 'comment!' + } }); var mutationQuery = getNode(Relay.QL` mutation { @@ -1269,7 +1269,7 @@ describe('RelayQuery', () => { expect(root instanceof RelayQuery.Root).toBe(true); expect(root.getRootCall()).toEqual({ name: 'node', - value: '4', + value: '4' }); expect(root.getChildren().length).toBe(1); expect(root.getChildren()[0]).toBe(field); @@ -1286,7 +1286,7 @@ describe('RelayQuery', () => { expect(root instanceof RelayQuery.Root).toBe(true); expect(root.getRootCall()).toEqual({ name: 'node', - value: '4', + value: '4' }); expect(root.getChildren().length).toBe(1); expect(root.getChildren()[0]).toBe(field); @@ -1302,7 +1302,7 @@ describe('RelayQuery', () => { expect(root.getBatchCall()).toEqual({ refParamName: 'ref_q0', sourceQueryID: 'q0', - sourceQueryPath: '$.*.id', + sourceQueryPath: '$.*.id' }); }); }); @@ -1362,16 +1362,16 @@ describe('RelayQuery', () => { it('builds fields with calls', () => { var field = RelayQuery.Node.buildField('profilePicture', [ - {name: 'size', value: 32}, + {name: 'size', value: 32} ]); expect(field.getCallsWithValues()).toEqual([ - {name: 'size', value: 32}, + {name: 'size', value: 32} ]); field = RelayQuery.Node.buildField('profilePicture', [ - {name: 'size', value: ['32']}, + {name: 'size', value: ['32']} ]); expect(field.getCallsWithValues()).toEqual([ - {name: 'size', value: ['32']}, + {name: 'size', value: ['32']} ]); }); }); @@ -1426,10 +1426,10 @@ describe('RelayQuery', () => { var reference = new RelayFragmentReference( () => innerFragment, { - size: 'default', + size: 'default' }, { - size: new GraphQL.CallVariable('outerSize'), + size: new GraphQL.CallVariable('outerSize') } ); var fragment = getNode(Relay.QL` @@ -1438,7 +1438,7 @@ describe('RelayQuery', () => { ${reference}, } `, { - outerSize: 'override', + outerSize: 'override' }); var children = fragment.getChildren(); expect(children.length).toBe(2); @@ -1452,7 +1452,7 @@ describe('RelayQuery', () => { expect(grandchildren[0].getSchemaName()).toBe('id'); expect(grandchildren[1].getSchemaName()).toBe('profilePicture'); expect(grandchildren[1].getCallsWithValues()).toEqual([ - {name: 'size', value: 'override'}, + {name: 'size', value: 'override'} ]); }); }); diff --git a/src/query/__tests__/RelayQueryPath-test.js b/src/query/__tests__/RelayQueryPath-test.js index 2d76c8c292adc..02631769f9c7e 100644 --- a/src/query/__tests__/RelayQueryPath-test.js +++ b/src/query/__tests__/RelayQueryPath-test.js @@ -28,8 +28,8 @@ describe('RelayQueryPath', () => { children: [], metadata: { isDeferred: false, - isReferenceFragment: false, - }, + isReferenceFragment: false + } }; beforeEach(() => { @@ -212,11 +212,11 @@ describe('RelayQueryPath', () => { children: [], metadata: { requisite: true, - parentType: 'Node', - }, - }, + parentType: 'Node' + } + } ], - metadata: {}, + metadata: {} }]); var fragment = Relay.QL`fragment on Node { name }`; @@ -251,7 +251,7 @@ describe('RelayQueryPath', () => { name: 'UnknownFile', calls: [{name: 'viewer', value: null}], children: [EMPTY_FRAGMENT], - metadata: {}, + metadata: {} }]); var fragment = Relay.QL`fragment on Viewer { pendingPosts { count } }`; @@ -300,10 +300,10 @@ describe('RelayQueryPath', () => { children: [], metadata: { requisite: true, - parentType: 'Node', - }, + parentType: 'Node' + } }], - metadata: {}, + metadata: {} }, { kind: 'Field', @@ -312,9 +312,9 @@ describe('RelayQueryPath', () => { calls: [], children: [EMPTY_FRAGMENT], metadata: { - parentType: 'Actor', - }, - }, + parentType: 'Actor' + } + } ]); var fragment = Relay.QL`fragment on StreetAddress { country }`; diff --git a/src/query/__tests__/RelayQuerySerializer-test.js b/src/query/__tests__/RelayQuerySerializer-test.js index 1d9b55c59adfa..2dce10af8934e 100644 --- a/src/query/__tests__/RelayQuerySerializer-test.js +++ b/src/query/__tests__/RelayQuerySerializer-test.js @@ -33,8 +33,8 @@ describe('RelayQuerySerializer', () => { metadata: { generated: true, requisite: true, - parentType, - }, + parentType + } }; } @@ -46,8 +46,8 @@ describe('RelayQuerySerializer', () => { calls: [], children: [], metadata: { - parentType, - }, + parentType + } }; } @@ -104,17 +104,17 @@ describe('RelayQuerySerializer', () => { calls: [], children: [ scalarField('name', 'Actor'), - idField('Actor'), + idField('Actor') ], metadata: { dynamic: true, pk: 'id', rootCall: 'node', - parentType: 'Viewer', - }, - }, + parentType: 'Viewer' + } + } ], - metadata: {}, + metadata: {} }); var clone = fromJSON(toJSON(query)); expect(clone.equals(query)).toBe(true); @@ -136,9 +136,9 @@ describe('RelayQuerySerializer', () => { calls: [{name: 'node', value: '123'}], children: [ scalarField('name', 'Node'), - idField('Node'), + idField('Node') ], - metadata: {}, + metadata: {} }); var clone = fromJSON(toJSON(query)); expect(clone.equals(query)).toBe(true); @@ -160,9 +160,9 @@ describe('RelayQuerySerializer', () => { calls: [{name: 'nodes', value: ['1', '2', '3']}], children: [ scalarField('name', 'Node'), - idField('Node'), + idField('Node') ], - metadata: {varargs: 1}, + metadata: {varargs: 1} }); var clone = fromJSON(toJSON(query)); expect(clone.equals(query)).toBe(true); @@ -182,13 +182,13 @@ describe('RelayQuerySerializer', () => { ...idField('Node'), metadata: { requisite: true, - parentType: 'Node', - }, + parentType: 'Node' + } }], metadata: { isDeferred: false, - isReferenceFragment: false, - }, + isReferenceFragment: false + } }); expect(fromJSON(toJSON(fragment)).equals(fragment)).toBe(true); }); @@ -209,13 +209,13 @@ describe('RelayQuerySerializer', () => { ...idField('Node'), metadata: { requisite: true, - parentType: 'Node', - }, + parentType: 'Node' + } }], metadata: { isDeferred: true, - isReferenceFragment: true, - }, + isReferenceFragment: true + } }); var deserialized = fromJSON(toJSON(fragment)); @@ -240,7 +240,7 @@ describe('RelayQuerySerializer', () => { name: 'profilePicture', alias: 'photo', calls: [ - {name: 'size', value: '32'}, + {name: 'size', value: '32'} ], children: [{ kind: 'Field', @@ -248,9 +248,9 @@ describe('RelayQuerySerializer', () => { alias: null, calls: [], children: [], - metadata: {parentType: 'Image'}, + metadata: {parentType: 'Image'} }], - metadata: {parentType: 'User'}, + metadata: {parentType: 'User'} }); expect(fromJSON(toJSON(field)).equals(field)).toBe(true); }); @@ -269,7 +269,7 @@ describe('RelayQuerySerializer', () => { name: 'profilePicture', alias: 'photo', calls: [ - {name: 'size', value: ['32', '64']}, + {name: 'size', value: ['32', '64']} ], children: [{ kind: 'Field', @@ -277,9 +277,9 @@ describe('RelayQuerySerializer', () => { alias: null, calls: [], children: [], - metadata: {parentType: 'Image'}, + metadata: {parentType: 'Image'} }], - metadata: {parentType: 'User'}, + metadata: {parentType: 'User'} }); expect(fromJSON(toJSON(field)).equals(field)).toBe(true); }); @@ -302,7 +302,7 @@ describe('RelayQuerySerializer', () => { name: 'friends', alias: null, calls: [ - {name: 'isViewerFriend', value: true}, + {name: 'isViewerFriend', value: true} ], children: [{ kind: 'Field', @@ -318,19 +318,19 @@ describe('RelayQuerySerializer', () => { ...idField('User'), metadata: { requisite: true, - parentType: 'User', - }, + parentType: 'User' + } }], metadata: { pk: 'id', requisite: true, rootCall: 'node', - parentType: 'FriendsEdge', - }, + parentType: 'FriendsEdge' + } }], - metadata: {plural: true, parentType: 'FriendsConnection'}, + metadata: {plural: true, parentType: 'FriendsConnection'} }], - metadata: {connection: true, parentType: 'User'}, + metadata: {connection: true, parentType: 'User'} }); expect(fromJSON(toJSON(field)).equals(field)).toBe(true); }); diff --git a/src/query/__tests__/RelayQueryTransform-test.js b/src/query/__tests__/RelayQueryTransform-test.js index fefc4d2ad3ae6..6019e3ee949f0 100644 --- a/src/query/__tests__/RelayQueryTransform-test.js +++ b/src/query/__tests__/RelayQueryTransform-test.js @@ -32,7 +32,7 @@ describe('RelayQueryTransform', () => { var variables = { first: 10, - after: 'offset', + after: 'offset' }; var fragment = Relay.QL` diff --git a/src/query/__tests__/RelayQueryVisitor-test.js b/src/query/__tests__/RelayQueryVisitor-test.js index cbee4da213e0f..3bdc418834af8 100644 --- a/src/query/__tests__/RelayQueryVisitor-test.js +++ b/src/query/__tests__/RelayQueryVisitor-test.js @@ -32,7 +32,7 @@ describe('RelayQueryVisitor', () => { var variables = { first: 10, - after: 'offset', + after: 'offset' }; var fragment = Relay.QL` diff --git a/src/query/__tests__/buildRQL-test.js b/src/query/__tests__/buildRQL-test.js index d4520642bc5b5..aad09b0a6f277 100644 --- a/src/query/__tests__/buildRQL-test.js +++ b/src/query/__tests__/buildRQL-test.js @@ -44,7 +44,7 @@ describe('buildRQL', () => { }); MockComponent = React.createClass({render}); MockContainer = Relay.createContainer(MockComponent, { - fragments: {}, + fragments: {} }); MockContainer.getQuery = jest.genMockFunction().mockReturnValue( Relay.QL`fragment on Node { name }` @@ -93,7 +93,7 @@ describe('buildRQL', () => { // Confirm that `${variables.sizeVariable}` is a variable by applying // variable values using `RelayQuery`: var fragment = getNode(node, { - sizeVariable: '32', + sizeVariable: '32' }); expect(fragment instanceof RelayQuery.Fragment).toBe(true); var children = fragment.getChildren(); @@ -101,7 +101,7 @@ describe('buildRQL', () => { expect(children[1].getSchemaName()).toBe('profilePicture'); // Variable has the applied value, not initial value. expect(children[1].getCallsWithValues()).toEqual([ - {name: 'size', value: '32'}, + {name: 'size', value: '32'} ]); }); @@ -149,7 +149,7 @@ describe('buildRQL', () => { expect(query instanceof RelayQuery.Root).toBe(true); expect(query.getRootCall()).toEqual({ name: 'node', - value: '123', + value: '123' }); expect(query.getChildren()[1].equals( getNode(MockContainer.getQuery(), variables) @@ -171,7 +171,7 @@ describe('buildRQL', () => { it('returns different queries for different components', () => { var MockContainer2 = Relay.createContainer(MockComponent, { - fragments: {}, + fragments: {} }); MockContainer2.getQuery = jest.genMockFunction().mockReturnValue( Relay.QL`fragment on Node { name }` diff --git a/src/query/__tests__/callsToGraphQL-test.js b/src/query/__tests__/callsToGraphQL-test.js index 56a93ddc327e0..641adbefd49db 100644 --- a/src/query/__tests__/callsToGraphQL-test.js +++ b/src/query/__tests__/callsToGraphQL-test.js @@ -30,7 +30,7 @@ describe('callsToGraphQL', function() { it('converts array calls with null values', () => { var relayCalls = [{ name: 'size', - value: null, + value: null }]; var graphqlCalls = [new GraphQL.Callv('size', null)]; expect(callsFromGraphQL(graphqlCalls)).toEqual(relayCalls); @@ -40,7 +40,7 @@ describe('callsToGraphQL', function() { it('converts array calls without values', () => { var relayCalls = [{ name: 'size', - value: [], + value: [] }]; var graphqlCalls = [new GraphQL.Callv('size', [])]; expect(callsFromGraphQL(graphqlCalls)).toEqual(relayCalls); @@ -50,7 +50,7 @@ describe('callsToGraphQL', function() { it('converts calls with array values', () => { var relayCalls = [{ name: 'size', - value: [32, 64], + value: [32, 64] }]; var graphqlCalls = [new GraphQL.Callv('size', [32, 64])]; expect(callsFromGraphQL(graphqlCalls)).toEqual(relayCalls); @@ -60,7 +60,7 @@ describe('callsToGraphQL', function() { it('converts singular calls with null values', () => { var relayCalls = [{ name: 'size', - value: 32, + value: 32 }]; var graphqlCalls = [new GraphQL.Callv('size', 32)]; expect(callsFromGraphQL(graphqlCalls)).toEqual(relayCalls); diff --git a/src/query/__tests__/stableStringify-test.js b/src/query/__tests__/stableStringify-test.js index 5b4baf4dd3ff8..00fbcdfac26e8 100644 --- a/src/query/__tests__/stableStringify-test.js +++ b/src/query/__tests__/stableStringify-test.js @@ -52,16 +52,16 @@ describe('stableStringify', () => { top2: { middle: { inner: [1, 'foo', ['bar', 2]], - other: false, - }, + other: false + } }, top1: [ {first: true}, {first: false}, - 'random', + 'random' ], misc: true, - extra: null, + extra: null }; var expected = diff --git a/src/query/__tests__/toGraphQL-test.js b/src/query/__tests__/toGraphQL-test.js index 0fb268c83fb5d..54654584db268 100644 --- a/src/query/__tests__/toGraphQL-test.js +++ b/src/query/__tests__/toGraphQL-test.js @@ -44,7 +44,7 @@ describe('toGraphQL', function() { 'Expected ' + expected + not + 'to equal ' + actual; return expected === actual; - }, + } }); }); @@ -147,7 +147,7 @@ describe('toGraphQL', function() { } } `, { - q: value, + q: value }); expect(relayQuery.getRootCall().value).toEqual(value); var convertedQuery = toGraphQL.Query(relayQuery); @@ -163,7 +163,7 @@ describe('toGraphQL', function() { } } `, { - q: value, + q: value }); expect(relayQuery.getRootCall().value).toEqual(value); var convertedQuery = toGraphQL.Query(relayQuery); diff --git a/src/query/buildRQL.js b/src/query/buildRQL.js index a5202005e07fa..71d78d2468219 100644 --- a/src/query/buildRQL.js +++ b/src/query/buildRQL.js @@ -105,7 +105,7 @@ var buildRQL = { return GraphQL.isQuery(node) ? node : undefined; } return null; - }, + } }; function toVariables(variableNames: VariableNames): { diff --git a/src/query/fromGraphQL.js b/src/query/fromGraphQL.js index f0736471d1353..d702f0d46ce5a 100644 --- a/src/query/fromGraphQL.js +++ b/src/query/fromGraphQL.js @@ -70,14 +70,14 @@ var fromGraphQL = { 'fromGraphQL.Operation(): Expected a mutation/subscription node.' ); return node; - }, + } }; RelayProfiler.instrumentMethods(fromGraphQL, { Node: 'fromGraphQL.Node', Field: 'fromGraphQL.Field', Fragment: 'fromGraphQL.Fragment', - Query: 'fromGraphQL.Query', + Query: 'fromGraphQL.Query' }); module.exports = fromGraphQL; diff --git a/src/query/toGraphQL.js b/src/query/toGraphQL.js index 1fa13da9948cb..11eb93b793835 100644 --- a/src/query/toGraphQL.js +++ b/src/query/toGraphQL.js @@ -103,7 +103,7 @@ var toGraphQL = { metadata ); }); - }, + } }; RelayProfiler.instrumentMethods(toGraphQL, { @@ -111,7 +111,7 @@ RelayProfiler.instrumentMethods(toGraphQL, { QueryWithValues: 'toGraphQL.QueryWithValues', Query: 'toGraphQL.Query', Fragment: 'toGraphQL.Fragment', - Field: 'toGraphQL.Field', + Field: 'toGraphQL.Field' }); function toGraphQLChildren( @@ -136,7 +136,7 @@ function toGraphQLChildren( function toGraphQLMetadata(node: RelayQuery.Node): ?Object { var metadata = { ...node.__concreteNode__.__metadata__, - ...node.__metadata__, + ...node.__metadata__ }; if (Object.keys(metadata).length) { return metadata; diff --git a/src/route/RelayMetaRoute.js b/src/route/RelayMetaRoute.js index 3bf9855455867..fff314cef6b9f 100644 --- a/src/route/RelayMetaRoute.js +++ b/src/route/RelayMetaRoute.js @@ -24,7 +24,7 @@ class RelayMetaRoute { Object.defineProperty(this, 'name', { enumerable: true, value: name, - writable: false, + writable: false }); } diff --git a/src/route/RelayRoute.js b/src/route/RelayRoute.js index d40578050d9a6..ec129fb437bf9 100644 --- a/src/route/RelayRoute.js +++ b/src/route/RelayRoute.js @@ -54,7 +54,7 @@ class RelayRoute { queries, paramDefinitions, path, - prepareParams, + prepareParams } = constructor; invariant( constructor !== RelayRoute, @@ -70,7 +70,7 @@ class RelayRoute { if (processQueryParams && !prepareParams) { RelayDeprecated.warn({ was: routeName + '.processQueryParams', - now: routeName + '.prepareParams', + now: routeName + '.prepareParams' }); prepareParams = processQueryParams; } @@ -104,22 +104,22 @@ class RelayRoute { Object.defineProperty(this, 'name', { enumerable: true, value: routeName, - writable: false, + writable: false }); Object.defineProperty(this, 'params', { enumerable: true, value: params, - writable: false, + writable: false }); Object.defineProperty(this, 'queries', { enumerable: true, value: queries, - writable: false, + writable: false }); Object.defineProperty(this, 'uri', { enumerable: true, value: uri, - writable: false, + writable: false }); if (__DEV__) { Object.freeze(this.params); diff --git a/src/route/__tests__/RelayRoute-test.js b/src/route/__tests__/RelayRoute-test.js index 9edb674d63d42..d62027230e061 100644 --- a/src/route/__tests__/RelayRoute-test.js +++ b/src/route/__tests__/RelayRoute-test.js @@ -33,12 +33,12 @@ describe('RelayRoute', () => { MockRoute.paramDefinitions = { required: { type: 'String', - required: true, + required: true }, optional: { type: 'String', - required: false, - }, + required: false + } }; MockRoute.queries = { required: (Component, params) => Relay.QL` @@ -54,7 +54,7 @@ describe('RelayRoute', () => { ${Component.getQuery('optional')} } } - `, + ` }; return MockRoute; }; diff --git a/src/store/RelayBufferedNeglectionStateMap.js b/src/store/RelayBufferedNeglectionStateMap.js index 9645c25f7cabd..72213b7fba5f2 100644 --- a/src/store/RelayBufferedNeglectionStateMap.js +++ b/src/store/RelayBufferedNeglectionStateMap.js @@ -48,7 +48,7 @@ class RelayBufferedNeglectionStateMap { decreaseSubscriptionsFor(dataID: DataID): void { this._bufferedChanges.push({ type: 'decrease', - dataID, + dataID }); } @@ -59,7 +59,7 @@ class RelayBufferedNeglectionStateMap { increaseSubscriptionsFor(dataID: DataID): void { this._bufferedChanges.push({ type: 'increase', - dataID, + dataID }); } @@ -70,7 +70,7 @@ class RelayBufferedNeglectionStateMap { register(dataID: DataID): void { this._bufferedChanges.push({ type: 'register', - dataID, + dataID }); } @@ -81,7 +81,7 @@ class RelayBufferedNeglectionStateMap { remove(dataID: DataID): void { this._bufferedChanges.push({ type: 'remove', - dataID, + dataID }); } diff --git a/src/store/RelayChangeTracker.js b/src/store/RelayChangeTracker.js index 79b304e0e02c7..767af2f114cfa 100644 --- a/src/store/RelayChangeTracker.js +++ b/src/store/RelayChangeTracker.js @@ -74,12 +74,12 @@ class RelayChangeTracker { if (__DEV__) { return { created: Object.freeze(this._created), - updated: Object.freeze(this._updated), + updated: Object.freeze(this._updated) }; } return { created: this._created, - updated: this._updated, + updated: this._updated }; } } diff --git a/src/store/RelayMutationTracker.js b/src/store/RelayMutationTracker.js index a3e265a781f12..2298ae7cc8d23 100644 --- a/src/store/RelayMutationTracker.js +++ b/src/store/RelayMutationTracker.js @@ -151,7 +151,7 @@ var RelayMutationTracker = { clientMutationID: ClientMutationID ): void { delete clientMutationIDToErrorNodeID[clientMutationID]; - }, + } }; module.exports = RelayMutationTracker; diff --git a/src/store/RelayNeglectionStateMap.js b/src/store/RelayNeglectionStateMap.js index 1682322c66603..3a313cf69a52f 100644 --- a/src/store/RelayNeglectionStateMap.js +++ b/src/store/RelayNeglectionStateMap.js @@ -110,7 +110,7 @@ class RelayNeglectionStateMap { } var value = states[ii++]; return {done, value}; - }, + } }; } @@ -124,7 +124,7 @@ class RelayNeglectionStateMap { dataID, collectible: false, generations: 0, - subscriptions, + subscriptions }); } diff --git a/src/store/RelayPendingQueryTracker.js b/src/store/RelayPendingQueryTracker.js index 1b0a23556d59d..66b617eed0cfc 100644 --- a/src/store/RelayPendingQueryTracker.js +++ b/src/store/RelayPendingQueryTracker.js @@ -100,7 +100,7 @@ class PendingFetch { if (subtractedQuery) { pendingFetchMap[queryID] = { fetch: this, - query: subtractedQuery, + query: subtractedQuery }; GraphQLDeferredQueryTracker.recordQuery(subtractedQuery); this._fetchSubtractedQueryPromise.done( @@ -318,7 +318,7 @@ var RelayPendingQueryTracker = { }, // TODO: Use `export type`. - PendingFetch, + PendingFetch }; diff --git a/src/store/RelayQueryTracker.js b/src/store/RelayQueryTracker.js index 81665856d2d63..9a6383f028caa 100644 --- a/src/store/RelayQueryTracker.js +++ b/src/store/RelayQueryTracker.js @@ -60,7 +60,7 @@ class RelayQueryTracker { this._trackedNodesByID[dataID] = this._trackedNodesByID[dataID] || { trackedNodes: [], - isFlattened: false, + isFlattened: false }; this._trackedNodesByID[dataID].trackedNodes.push(node); this._trackedNodesByID[dataID].isFlattened = false; diff --git a/src/store/RelayQueryWriter.js b/src/store/RelayQueryWriter.js index 9ea881f542b49..dadc1049c601d 100644 --- a/src/store/RelayQueryWriter.js +++ b/src/store/RelayQueryWriter.js @@ -88,7 +88,7 @@ class RelayQueryWriter extends RelayQueryVisitor { nodeID: null, recordID, responseData, - path, + path }; if (node instanceof RelayQuery.Field && !node.isScalar()) { @@ -191,7 +191,7 @@ class RelayQueryWriter extends RelayQueryVisitor { ): ?RelayQuery.Node { var { recordID, - responseData, + responseData } = state; invariant( this._store.getRecordStatus(recordID) === RelayRecordStatus.EXISTENT, @@ -319,7 +319,7 @@ class RelayQueryWriter extends RelayQueryVisitor { path, nodeID: null, recordID: connectionID, - responseData: connectionData, + responseData: connectionData }; this._traverseConnection(field, field, connectionState); } @@ -360,7 +360,7 @@ class RelayQueryWriter extends RelayQueryVisitor { ): void { var { recordID: connectionID, - responseData: connectionData, + responseData: connectionData } = state; var storageKey = connection.getStorageKey(); invariant( @@ -464,7 +464,7 @@ class RelayQueryWriter extends RelayQueryVisitor { path, nodeID, recordID: edgeID, - responseData: edgeData, + responseData: edgeData }); isUpdate = isUpdate || this.hasChangeToRecord(edgeID); }); @@ -543,7 +543,7 @@ class RelayQueryWriter extends RelayQueryVisitor { path, nodeID: null, // never propagate `nodeID` past the first linked field recordID: nextLinkedID, - responseData: nextRecord, + responseData: nextRecord }); isUpdate = isUpdate || this.hasChangeToRecord(nextLinkedID); nextIndex++; @@ -605,7 +605,7 @@ class RelayQueryWriter extends RelayQueryVisitor { path, nodeID: null, recordID: nextLinkedID, - responseData: fieldData, + responseData: fieldData }); } } diff --git a/src/store/RelayRecordStatus.js b/src/store/RelayRecordStatus.js index af29d6640fb0b..718c7f0d2dcd7 100644 --- a/src/store/RelayRecordStatus.js +++ b/src/store/RelayRecordStatus.js @@ -32,7 +32,7 @@ var RelayRecordStatus = { * Record status is unknown because it has not yet been fetched from the * server. */ - UNKNOWN: 'UNKNOWN', + UNKNOWN: 'UNKNOWN' }; module.exports = RelayRecordStatus; diff --git a/src/store/RelayRecordStore.js b/src/store/RelayRecordStore.js index 20266c13c7c58..c624fa101e9bb 100644 --- a/src/store/RelayRecordStore.js +++ b/src/store/RelayRecordStore.js @@ -242,7 +242,7 @@ class RelayRecordStore { return; } var nextRecord: Record = ({ - __dataID__: dataID, + __dataID__: dataID }: $FixMe); if (target === this._queuedRecords) { this._setClientMutationID(nextRecord); @@ -457,7 +457,7 @@ class RelayRecordStore { parentID ); var fieldValue = { - __dataID__: recordID, + __dataID__: recordID }; parent[storageKey] = fieldValue; if (!this._queuedRecords && this._cacheManager) { @@ -522,7 +522,7 @@ class RelayRecordStore { parentID ); return { - __dataID__: recordID, + __dataID__: recordID }; }); parent[storageKey] = records; @@ -632,7 +632,7 @@ class RelayRecordStore { diffCalls: calls, filterCalls, pageInfo: undefined, - requestedEdges: [], + requestedEdges: [] }; } // Convert ordered `{name,value}` objects to `GraphQL.Call`s @@ -643,7 +643,7 @@ class RelayRecordStore { var { diffCalls, pageInfo, - requestedEdgeIDs, + requestedEdgeIDs } = range.retrieveRangeInfoForQuery(calls, queuedRecord); if (diffCalls && diffCalls.length) { diffCalls = filterCalls.concat(diffCalls); @@ -655,7 +655,7 @@ class RelayRecordStore { requestedEdges = requestedEdgeIDs .map(edgeID => ({ edgeID, - nodeID: this.getLinkedRecordID(edgeID, NODE), + nodeID: this.getLinkedRecordID(edgeID, NODE) })) .filter(edge => this._getRecord(edge.nodeID)); } else { @@ -665,7 +665,7 @@ class RelayRecordStore { diffCalls, filterCalls, pageInfo, - requestedEdges, + requestedEdges }; } @@ -785,8 +785,8 @@ class RelayRecordStore { __dataID__: edgeID, cursor: this.getField(edgeID, CURSOR), node: { - __dataID__: nodeID, - }, + __dataID__: nodeID + } }; } @@ -925,7 +925,7 @@ class RelayRecordStore { var source = this._queuedRecords || this._records; if (!source[dataID]) { record = source[dataID] = ({ - __dataID__: dataID, + __dataID__: dataID }: $FixMe); } if (source === this._queuedRecords) { diff --git a/src/store/RelayStore.js b/src/store/RelayStore.js index b75a85e30f1e8..d6cd6b4bc8803 100644 --- a/src/store/RelayStore.js +++ b/src/store/RelayStore.js @@ -175,7 +175,7 @@ var RelayStore = { ): void { var transaction = new RelayMutationTransaction(mutation); transaction.commit(callbacks); - }, + } }; module.exports = RelayStore; diff --git a/src/store/RelayStoreData.js b/src/store/RelayStoreData.js index ce7029f709345..a1a6c9dc82e82 100644 --- a/src/store/RelayStoreData.js +++ b/src/store/RelayStoreData.js @@ -192,7 +192,7 @@ class RelayStoreData { changeTracker, { forceIndex, - updateTrackedQueries: true, + updateTrackedQueries: true } ); writeRelayQueryPayload( @@ -221,7 +221,7 @@ class RelayStoreData { changeTracker, { forceIndex: generateForceIndex(), - updateTrackedQueries: false, + updateTrackedQueries: false } ); writeRelayUpdatePayload( @@ -362,7 +362,7 @@ class RelayStoreData { } RelayProfiler.instrumentMethods(RelayStoreData.prototype, { - handleQueryPayload: 'RelayStoreData.prototype.handleQueryPayload', + handleQueryPayload: 'RelayStoreData.prototype.handleQueryPayload' }); module.exports = RelayStoreData; diff --git a/src/store/RelayStoreGarbageCollector.js b/src/store/RelayStoreGarbageCollector.js index 23d205ed5fdfd..651d87ce4e2ba 100644 --- a/src/store/RelayStoreGarbageCollector.js +++ b/src/store/RelayStoreGarbageCollector.js @@ -128,7 +128,7 @@ class RelayStoreGarbageCollector { iterator = offset; var profileState = { count: -1, - stepLength: stepLength, + stepLength: stepLength }; var profile = RelayProfiler.profile( 'RelayStoreGarbageCollector.collect', @@ -239,7 +239,7 @@ class RelayStoreGarbageCollector { var remainingRecords: Array = [ records[dataID], queuedRecords[dataID], - cachedRecords[dataID], + cachedRecords[dataID] ]; // If `field` contains a linked record and the linked record has a @@ -332,7 +332,7 @@ RelayProfiler.instrumentMethods(RelayStoreGarbageCollector.prototype, { increaseSubscriptionsFor: 'RelayStoreGarbageCollector.prototype.increaseSubscriptionsFor', register: - 'RelayStoreGarbageCollector.prototype.register', + 'RelayStoreGarbageCollector.prototype.register' }); module.exports = RelayStoreGarbageCollector; diff --git a/src/store/__mocks__/RelayBufferedNeglectionStateMap.js b/src/store/__mocks__/RelayBufferedNeglectionStateMap.js index 1f9653c449168..6f8157d405fe0 100644 --- a/src/store/__mocks__/RelayBufferedNeglectionStateMap.js +++ b/src/store/__mocks__/RelayBufferedNeglectionStateMap.js @@ -20,7 +20,7 @@ class RelayBufferedNeglectionStateMap { } RelayBufferedNeglectionStateMap.mock = { - instances: [], + instances: [] }; module.exports = RelayBufferedNeglectionStateMap; diff --git a/src/store/__mocks__/RelayMockCacheManager.js b/src/store/__mocks__/RelayMockCacheManager.js index a4468ecd10c61..b3f1a9b4b0d26 100644 --- a/src/store/__mocks__/RelayMockCacheManager.js +++ b/src/store/__mocks__/RelayMockCacheManager.js @@ -15,9 +15,9 @@ var RelayMockCacheManager = { cacheNode: jest.genMockFunction(), cacheField: jest.genMockFunction(), cacheRootCall: jest.genMockFunction(), - readAllData: jest.genMockFunction(), + readAllData: jest.genMockFunction() }; - }, + } }; module.exports = RelayMockCacheManager; diff --git a/src/store/__mocks__/RelayNeglectionStateMap.js b/src/store/__mocks__/RelayNeglectionStateMap.js index 3e6ca6bfa46f0..77295bedb3e73 100644 --- a/src/store/__mocks__/RelayNeglectionStateMap.js +++ b/src/store/__mocks__/RelayNeglectionStateMap.js @@ -20,7 +20,7 @@ class RelayNeglectionStateMap { } RelayNeglectionStateMap.mock = { - instances: [], + instances: [] }; module.exports = RelayNeglectionStateMap; diff --git a/src/store/__mocks__/RelayStore.js b/src/store/__mocks__/RelayStore.js index f88e5000f1a73..7ada56b832f70 100644 --- a/src/store/__mocks__/RelayStore.js +++ b/src/store/__mocks__/RelayStore.js @@ -49,7 +49,7 @@ function genMockRequest(args) { }, fail(error) { args[1]({aborted: false, done: false, error, ready, stale: false}); - }, + } }; } @@ -60,7 +60,7 @@ RelayStore.primeCache.mockImplementation((...args) => { var returnValue = { abort: jest.genMockFunction().mockImplementation(() => { resolveImmediate(request.abort); - }), + }) }; RelayStore.primeCache.mock.abort.push(returnValue.abort); RelayStore.primeCache.mock.requests.push(request); @@ -74,7 +74,7 @@ RelayStore.forceFetch.mockImplementation((...args) => { var returnValue = { abort: jest.genMockFunction().mockImplementation(() => { resolveImmediate(request.abort); - }), + }) }; RelayStore.forceFetch.mock.abort.push(returnValue.abort); RelayStore.forceFetch.mock.requests.push(request); @@ -85,7 +85,7 @@ RelayStore.mock = { setMockRecords: records => { RelayStore.mock.recordStore = new RelayRecordStore({records}); }, - recordStore: null, + recordStore: null }; RelayStore.observe.mockImplementation((...args) => { diff --git a/src/store/__tests__/RelayNeglectionStateMap-test.js b/src/store/__tests__/RelayNeglectionStateMap-test.js index 65ad411ef7696..07ec2c1498d4b 100644 --- a/src/store/__tests__/RelayNeglectionStateMap-test.js +++ b/src/store/__tests__/RelayNeglectionStateMap-test.js @@ -118,14 +118,14 @@ describe('RelayNeglectionStateMap', () => { dataID: 'a', collectible: false, generations: 0, - subscriptions: 0, + subscriptions: 0 }; neglectionStateB = { dataID: 'b', collectible: false, generations: 0, - subscriptions: 1, + subscriptions: 1 }; }); diff --git a/src/store/__tests__/RelayPendingQueryTracker-test.js b/src/store/__tests__/RelayPendingQueryTracker-test.js index 6d3e112cea226..4d4effc2a90ef 100644 --- a/src/store/__tests__/RelayPendingQueryTracker-test.js +++ b/src/store/__tests__/RelayPendingQueryTracker-test.js @@ -53,7 +53,7 @@ describe('RelayPendingQueryTracker', () => { query, fetchMode, forceIndex: null, - storeData: RelayStoreData.getDefaultInstance(), + storeData: RelayStoreData.getDefaultInstance() }); }; @@ -96,7 +96,7 @@ describe('RelayPendingQueryTracker', () => { jest.runAllTimers(); expect(subtractRelayQuery.mock.calls).toEqual([ - [mockQueryC, mockQueryA], + [mockQueryC, mockQueryA] ]); fetchRelayQuery.mock.requests[1].resolve({}); @@ -137,7 +137,7 @@ describe('RelayPendingQueryTracker', () => { expect(subtractRelayQuery.mock.calls).toEqual([ [mockQueryB, mockQueryA], - [mockQueryC, mockQueryA], + [mockQueryC, mockQueryA] ]); }); @@ -353,7 +353,7 @@ describe('RelayPendingQueryTracker', () => { addPending({ query: mockQuery, - fetchMode: DliteFetchModeConstants.FETCH_MODE_PRELOAD, + fetchMode: DliteFetchModeConstants.FETCH_MODE_PRELOAD }); RelayPendingQueryTracker.resolvePreloadQuery( @@ -384,7 +384,7 @@ describe('RelayPendingQueryTracker', () => { addPending({ query: mockQuery, - fetchMode: DliteFetchModeConstants.FETCH_MODE_PRELOAD, + fetchMode: DliteFetchModeConstants.FETCH_MODE_PRELOAD }); jest.runAllTimers(); @@ -405,7 +405,7 @@ describe('RelayPendingQueryTracker', () => { var mockPending = addPending({ query: mockQuery, - fetchMode: DliteFetchModeConstants.FETCH_MODE_PRELOAD, + fetchMode: DliteFetchModeConstants.FETCH_MODE_PRELOAD }); var mockCallback = jest.genMockFunction(); mockPending.getResolvedPromise().catch(mockCallback); diff --git a/src/store/__tests__/RelayRecordStore-test.js b/src/store/__tests__/RelayRecordStore-test.js index 316dffcd9c922..b96c35e3fe577 100644 --- a/src/store/__tests__/RelayRecordStore-test.js +++ b/src/store/__tests__/RelayRecordStore-test.js @@ -53,8 +53,8 @@ describe('RelayRecordStore', () => { var records = { '4': { id: '4', - __dataID__: '4', - }, + __dataID__: '4' + } }; var store = new RelayRecordStore({records}); expect(store.getRecordStatus('4')).toBe('EXISTENT'); @@ -63,11 +63,11 @@ describe('RelayRecordStore', () => { it('prefers queued records over non-existent records', () => { var queuedRecord = { id: '4', - __dataID__: '4', + __dataID__: '4' }; var store = new RelayRecordStore({ records: {}, - queuedRecords: {'4': queuedRecord}, + queuedRecords: {'4': queuedRecord} }); expect(store.getRecordStatus('4')).toBe('EXISTENT'); }); @@ -75,11 +75,11 @@ describe('RelayRecordStore', () => { it('prefers queued records over deleted records', () => { var queuedRecord = { id: '4', - __dataID__: '4', + __dataID__: '4' }; var store = new RelayRecordStore({ records: {'4': null}, - queuedRecords: {'4': queuedRecord}, + queuedRecords: {'4': queuedRecord} }); expect(store.getRecordStatus('4')).toBe('EXISTENT'); }); @@ -87,11 +87,11 @@ describe('RelayRecordStore', () => { it('prefers queued records when they are deleted', () => { var record = { id: '4', - __dataID__: '4', + __dataID__: '4' }; var store = new RelayRecordStore({ records: {'4': record}, - queuedRecords: {'4': null}, + queuedRecords: {'4': null} }); expect(store.getRecordStatus('4')).toBe('NONEXISTENT'); }); @@ -99,12 +99,12 @@ describe('RelayRecordStore', () => { it('prefers queued records over cached records', () => { var record = { id: '4', - __dataID__: '4', + __dataID__: '4' }; var store = new RelayRecordStore({ queuedRecords: {'4': record}, records: {}, - cachedRecords: {'4': null}, + cachedRecords: {'4': null} }); expect(store.getRecordStatus('4')).toBe('EXISTENT'); }); @@ -112,11 +112,11 @@ describe('RelayRecordStore', () => { it('prefers existing records over cached records', () => { var record = { id: '4', - __dataID__: '4', + __dataID__: '4' }; var store = new RelayRecordStore({ records: {'4': record}, - cachedRecords: {'4': null}, + cachedRecords: {'4': null} }); expect(store.getRecordStatus('4')).toBe('EXISTENT'); }); @@ -124,11 +124,11 @@ describe('RelayRecordStore', () => { it('falls back to cached records when necessary', () => { var record = { id: '4', - __dataID__: '4', + __dataID__: '4' }; var store = new RelayRecordStore({ records: {}, - cachedRecords: {'4': record}, + cachedRecords: {'4': record} }); expect(store.getRecordStatus('4')).toBe('EXISTENT'); }); @@ -138,7 +138,7 @@ describe('RelayRecordStore', () => { it('returns true if record is queued', () => { var store = new RelayRecordStore({ records: {}, - queuedRecords: {'4': {__dataID__: '4'}}, + queuedRecords: {'4': {__dataID__: '4'}} }); expect(store.hasOptimisticUpdate('4')).toBe(true); }); @@ -146,14 +146,14 @@ describe('RelayRecordStore', () => { it('returns false if record is not queued', () => { var store = new RelayRecordStore({ records: {'4': {__dataID__: '4'}}, - queuedRecords: {}, + queuedRecords: {} }); expect(store.hasOptimisticUpdate('4')).toBe(false); }); it('throws if called on a non-queued record store', () => { var store = new RelayRecordStore({ - records: {'4': {__dataID__: '4'}}, + records: {'4': {__dataID__: '4'}} }); expect(() => { store.hasOptimisticUpdate('4'); @@ -169,8 +169,8 @@ describe('RelayRecordStore', () => { var queuedRecords = { '1': { __dataID__: '1', - __hasError__: true, - }, + __hasError__: true + } }; var store = new RelayRecordStore({queuedRecords}); expect(store.hasMutationError('1')).toBe(true); @@ -180,8 +180,8 @@ describe('RelayRecordStore', () => { var queuedRecords = { '1': { __dataID__: '1', - __hasError__: false, - }, + __hasError__: false + } }; var store = new RelayRecordStore({queuedRecords}); expect(store.hasMutationError('1')).toBe(false); @@ -196,8 +196,8 @@ describe('RelayRecordStore', () => { it('throws if queuedRecords are not available', () => { var records = { '1': { - __dataID__: '1', - }, + __dataID__: '1' + } }; var store = new RelayRecordStore({records}); expect(() => { @@ -221,8 +221,8 @@ describe('RelayRecordStore', () => { it('updates the error status for existing queued records', () => { var queuedRecords = { '1': { - __dataID__: '1', - }, + __dataID__: '1' + } }; var store = new RelayRecordStore({queuedRecords}); store.setMutationErrorStatus('1', true); @@ -313,8 +313,8 @@ describe('RelayRecordStore', () => { '4': { id: '4', __dataID__: '4', - name: 'Zuck', - }, + name: 'Zuck' + } }; var store = new RelayRecordStore({records}); expect(store.getField('4', 'name')).toBe('Zuck'); @@ -333,16 +333,16 @@ describe('RelayRecordStore', () => { var record = { id: '4', name: 'Zuck', - __dataID__: '4', + __dataID__: '4' }; var queuedRecord = { id: '4', name: 'Mark', - __dataID__: '4', + __dataID__: '4' }; var store = new RelayRecordStore({ records: {'4': record}, - queuedRecords: {'4': queuedRecord}, + queuedRecords: {'4': queuedRecord} }); expect(store.getField('4', 'name')).toBe('Mark'); }); @@ -351,16 +351,16 @@ describe('RelayRecordStore', () => { var record = { id: '4', name: 'Zuck', - __dataID__: '4', + __dataID__: '4' }; var cachedRecord = { id: '4', name: 'Mark', - __dataID__: '4', + __dataID__: '4' }; var store = new RelayRecordStore({ records: {'4': record}, - cachedRecords: {'4': cachedRecord}, + cachedRecords: {'4': cachedRecord} }); expect(store.getField('4', 'name')).toBe('Zuck'); }); @@ -370,15 +370,15 @@ describe('RelayRecordStore', () => { var record = { id: '4', name: 'Zuck', - __dataID__: '4', + __dataID__: '4' }; var queuedRecord = { id: '4', - __dataID__: '4', + __dataID__: '4' }; var store = new RelayRecordStore({ records: {'4': record}, - queuedRecords: {'4': queuedRecord}, + queuedRecords: {'4': queuedRecord} }); expect(store.getField('4', 'name')).toBe('Zuck'); } @@ -388,16 +388,16 @@ describe('RelayRecordStore', () => { () => { var record = { id: '4', - __dataID__: '4', + __dataID__: '4' }; var cachedRecord = { id: '4', name: 'Mark', - __dataID__: '4', + __dataID__: '4' }; var store = new RelayRecordStore({ cachedRecords: {'4': cachedRecord}, - records: {'4': record}, + records: {'4': record} }); expect(store.getField('4', 'name')).toBe('Mark'); } @@ -408,8 +408,8 @@ describe('RelayRecordStore', () => { it('throws if the data is an unexpected format', () => { var records = { story: { - feedback: 'not an object', - }, + feedback: 'not an object' + } }; var store = new RelayRecordStore({records}); expect(() => { @@ -421,8 +421,8 @@ describe('RelayRecordStore', () => { var records = { '4': { id: '4', - __dataID__: '4', - }, + __dataID__: '4' + } }; var store = new RelayRecordStore({records}); expect(store.getLinkedRecordID('4', 'address')).toBe(undefined); @@ -433,8 +433,8 @@ describe('RelayRecordStore', () => { '4': { id: '4', __dataID__: '4', - address: null, - }, + address: null + } }; var store = new RelayRecordStore({records}); expect(store.getLinkedRecordID('4', 'address')).toBe(null); @@ -446,12 +446,12 @@ describe('RelayRecordStore', () => { id: '4', __dataID__: '4', address: { - __dataID__: 'client:1', - }, + __dataID__: 'client:1' + } }, 'client:1': { - street: '1 Hacker Way', - }, + street: '1 Hacker Way' + } }; var store = new RelayRecordStore({records}); expect(store.getLinkedRecordID('4', 'address')).toBe('client:1'); @@ -462,8 +462,8 @@ describe('RelayRecordStore', () => { it('throws if the data is an unexpected format', () => { var records = { 'story': { - actors: ['not an object'], - }, + actors: ['not an object'] + } }; var store = new RelayRecordStore({records}); expect(() => { @@ -475,8 +475,8 @@ describe('RelayRecordStore', () => { var records = { '4': { id: '4', - __dataID__: '4', - }, + __dataID__: '4' + } }; var store = new RelayRecordStore({records}); expect(store.getLinkedRecordIDs('4', 'actors')).toBe(undefined); @@ -487,8 +487,8 @@ describe('RelayRecordStore', () => { '4': { id: '4', __dataID__: '4', - actors: null, - }, + actors: null + } }; var store = new RelayRecordStore({records}); expect(store.getLinkedRecordIDs('4', 'actors')).toBe(null); @@ -501,14 +501,14 @@ describe('RelayRecordStore', () => { __dataID__: '4', actors: [ {__dataID__: 'item:1'}, - {__dataID__: 'item:2'}, - ], - }, + {__dataID__: 'item:2'} + ] + } }; var store = new RelayRecordStore({records}); expect(store.getLinkedRecordIDs('4', 'actors')).toEqual([ 'item:1', - 'item:2', + 'item:2' ]); }); }); @@ -523,21 +523,21 @@ describe('RelayRecordStore', () => { id: '4', __dataID__: '4', 'friends': { - __dataID__: 'client:1', - }, + __dataID__: 'client:1' + } }, 'client:1': { - __range__: mockRange, + __range__: mockRange }, 'edge:1': { __dataID__: 'edge:1', node: { - __dataID__: 'node:1', - }, + __dataID__: 'node:1' + } }, 'node:1': { - __dataID__: 'node:1', - }, + __dataID__: 'node:1' + } }; }); @@ -552,7 +552,7 @@ describe('RelayRecordStore', () => { var store = new RelayRecordStore({records}); var calls = [ {name: 'first', value: '10'}, - {name: 'orderby', value: 'TOP_STORIES'}, + {name: 'orderby', value: 'TOP_STORIES'} ]; expect(store.getRangeMetadata('client:1', calls)).toBe(undefined); }); @@ -563,7 +563,7 @@ describe('RelayRecordStore', () => { store.getRangeMetadata('client:1', []); expect([ 'RelayRecordStore.getRangeMetadata(): Expected range to exist if ' + - '`edges` has been fetched.', + '`edges` has been fetched.' ]).toBeWarnedNTimes(1); }); @@ -571,7 +571,7 @@ describe('RelayRecordStore', () => { records['node:1'] = null; var store = new RelayRecordStore({records}); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ - requestedEdgeIDs: ['edge:1'], + requestedEdgeIDs: ['edge:1'] }); var metadata = store.getRangeMetadata( 'client:1', @@ -595,26 +595,26 @@ describe('RelayRecordStore', () => { requestedEdgeIDs: ['edge:1'], diffCalls: [ {name: 'first', value: '1'}, - {name: 'after', value: 'edge:1'}, - ], + {name: 'after', value: 'edge:1'} + ] }); var store = new RelayRecordStore({records}); var rangeInfo = store.getRangeMetadata('client:1', [ {name: 'orderby', value: ['TOP_STORIES']}, - {name: 'first', value: 2}, + {name: 'first', value: 2} ]); expect(mockRange.retrieveRangeInfoForQuery).toBeCalled(); expect(rangeInfo.diffCalls).toEqual([ {name: 'orderby', value: ['TOP_STORIES']}, {name: 'first', value: '1'}, - {name: 'after', value: 'edge:1'}, + {name: 'after', value: 'edge:1'} ]); expect(rangeInfo.requestedEdges).toEqual([{ edgeID: 'edge:1', - nodeID: 'node:1', + nodeID: 'node:1' }]); expect(rangeInfo.filterCalls).toEqual([ - {name: 'orderby', value: ['TOP_STORIES']}, + {name: 'orderby', value: ['TOP_STORIES']} ]); }); }); @@ -623,7 +623,7 @@ describe('RelayRecordStore', () => { it('returns null/undefined for deleted/unfetched records', () => { var records = { deleted: null, - notARange: {}, + notARange: {} }; var store = new RelayRecordStore({records}); @@ -636,14 +636,14 @@ describe('RelayRecordStore', () => { var calls = [ { name: 'orderby', - value: 'TOP_STORIES', - }, + value: 'TOP_STORIES' + } ]; var records = { 'client:1': { __range__: new GraphQLRange(), - __filterCalls__: calls, - }, + __filterCalls__: calls + } }; var store = new RelayRecordStore({records}); @@ -654,7 +654,7 @@ describe('RelayRecordStore', () => { describe('getConnectionIDsForRecord', () => { it('returns null for non-existent records', () => { var records = { - deleted: null, + deleted: null }; var store = new RelayRecordStore({records}); expect(store.getConnectionIDsForRecord('unfetched')).toBe(null); @@ -664,8 +664,8 @@ describe('RelayRecordStore', () => { it('returns null if the record is not in a connection', () => { var records = { '1': { - __dataID__: '1', - }, + __dataID__: '1' + } }; var store = new RelayRecordStore({records}); expect(store.getConnectionIDsForRecord('1')).toBe(null); @@ -674,25 +674,25 @@ describe('RelayRecordStore', () => { it('returns the connection ids containing the node', () => { var records = { '1': { - __dataID__: '1', + __dataID__: '1' }, 'range:1': { - __dataID__: 'range:1', + __dataID__: 'range:1' }, 'range:2': { - __dataID__: 'range:2', - }, + __dataID__: 'range:2' + } }; var nodeRangeMap = { '1': { 'range:1': true, - 'range:2': true, - }, + 'range:2': true + } }; var store = new RelayRecordStore({records}, null, nodeRangeMap); expect(store.getConnectionIDsForRecord('1')).toEqual([ 'range:1', - 'range:2', + 'range:2' ]); // node/connection link is cleared when the node is deleted @@ -704,7 +704,7 @@ describe('RelayRecordStore', () => { describe('getConnectionIDsForField()', () => { it('returns null/undefined for non-existent records', () => { var records = { - 'deleted': null, + 'deleted': null }; var store = new RelayRecordStore({records}); expect(store.getConnectionIDsForField('unfetched', 'news_feed')).toBe( @@ -725,12 +725,12 @@ describe('RelayRecordStore', () => { '1': { __dataID__: '1', 'photos': { - __dataID__: '2', + __dataID__: '2' }, 'photos.orderby(likes)': { - __dataID__: '3', - }, - }, + __dataID__: '3' + } + } }; var store = new RelayRecordStore({records}); expect(store.getConnectionIDsForField('1', 'photos')).toEqual(['2', '3']); diff --git a/src/store/__tests__/RelayRecordStore_write-test.js b/src/store/__tests__/RelayRecordStore_write-test.js index def6db1d4309b..50a7029adaf13 100644 --- a/src/store/__tests__/RelayRecordStore_write-test.js +++ b/src/store/__tests__/RelayRecordStore_write-test.js @@ -74,8 +74,8 @@ describe('RelayRecordStore', () => { var cache = RelayMockCacheManager.genCacheManager(); var records = { '1': { - __dataID__: '1', - }, + __dataID__: '1' + } }; var store = new RelayRecordStore({records}, null, null, cache); store.deleteRecord('1'); @@ -89,7 +89,7 @@ describe('RelayRecordStore', () => { it('writes to queued data if available, otherwise base data', () => { var cachedRecords = { a: {__dataID__: 'a'}, - b: {__dataID__: 'b'}, + b: {__dataID__: 'b'} }; var records = {}; var queuedRecords = {}; @@ -176,8 +176,8 @@ describe('RelayRecordStore', () => { var phone = { is_verified: true, phone_number: { - display_number: '1-800-555-1212', // directory assistance - }, + display_number: '1-800-555-1212' // directory assistance + } }; store.putField('1', 'all_phones', [phone]); expect(store.getField('1', 'all_phones')).toEqual([phone]); @@ -187,7 +187,7 @@ describe('RelayRecordStore', () => { it('writes to queued data if available, otherwise base data', () => { var cachedRecords = { 'a': {__dataID__: 'a'}, - 'b': {__dataID__: 'b'}, + 'b': {__dataID__: 'b'} }; var records = {}; var queuedRecords = {}; @@ -247,12 +247,12 @@ describe('RelayRecordStore', () => { var cachedRecords = { 'a': { __dataID__: 'a', - name: 'A', + name: 'A' }, 'b': { __dataID__: 'b', - name: 'B', - }, + name: 'B' + } }; var records = {}; var queuedRecords = {}; @@ -301,7 +301,7 @@ describe('RelayRecordStore', () => { store.putLinkedRecordID('viewerID', 'actor', 'actorID'); expect(store.getLinkedRecordID('viewerID', 'actor')).toBe('actorID'); expect(cache.cacheField).toBeCalledWith('viewerID', 'actor', { - __dataID__: 'actorID', + __dataID__: 'actorID' }); }); @@ -362,7 +362,7 @@ describe('RelayRecordStore', () => { .toEqual(['actor1', 'actor2']); expect(cache.cacheField).toBeCalledWith('storyID', 'actors', [ {__dataID__: 'actor1'}, - {__dataID__: 'actor2'}, + {__dataID__: 'actor2'} ]); }); @@ -481,12 +481,12 @@ describe('RelayRecordStore', () => { var calls = [ { name: 'orderby', - value: 'TOP_STORIES', + value: 'TOP_STORIES' }, { name: 'first', - value: '10', - }, + value: '10' + } ]; store.putRecord('1'); store.putRange('1', calls); @@ -526,7 +526,7 @@ describe('RelayRecordStore', () => { store.putRange(connectionID, []); var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }; var calls = [{name: 'first', value: 3}]; var edges = []; @@ -559,7 +559,7 @@ describe('RelayRecordStore', () => { expect(rangeInfo.requestedEdges).toEqual([ {edgeID: 'edge0', nodeID: 'node0'}, {edgeID: 'edge1', nodeID: 'node1'}, - {edgeID: 'edge2', nodeID: 'node2'}, + {edgeID: 'edge2', nodeID: 'node2'} ]); expect(cache.cacheField).toBeCalledWith( connectionID, @@ -622,7 +622,7 @@ describe('RelayRecordStore', () => { [{name: 'first', value: 1}], { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, + [HAS_PREV_PAGE]: false }, [firstEdgeID] ); @@ -635,7 +635,7 @@ describe('RelayRecordStore', () => { [{name: 'last', value: 1}], { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true, + [HAS_PREV_PAGE]: true }, [lastEdgeID] ); @@ -664,7 +664,7 @@ describe('RelayRecordStore', () => { var rangeInfo = store.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ edgeID, - firstEdgeID, + firstEdgeID ]); expect(store.getConnectionIDsForRecord(nodeID)).toEqual([connectionID]); expect(cache.cacheField).toBeCalledWith( @@ -683,7 +683,7 @@ describe('RelayRecordStore', () => { var rangeInfo = queuedStore.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ edgeID, - firstEdgeID, + firstEdgeID ]); // cache not updated on optimistic range update expect(cache.cacheField).not.toBeCalledWith( @@ -695,7 +695,7 @@ describe('RelayRecordStore', () => { // base store is unchanged rangeInfo = store.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ - firstEdgeID, + firstEdgeID ]); expect(store.getConnectionIDsForRecord(nodeID)).toEqual(null); }); @@ -709,7 +709,7 @@ describe('RelayRecordStore', () => { var rangeInfo = store.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ lastEdgeID, - edgeID, + edgeID ]); expect(store.getConnectionIDsForRecord(nodeID)).toEqual([connectionID]); expect(cache.cacheField).toBeCalledWith( @@ -728,7 +728,7 @@ describe('RelayRecordStore', () => { var rangeInfo = queuedStore.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ lastEdgeID, - edgeID, + edgeID ]); // cache not updated on optimistic range update expect(cache.cacheField).not.toBeCalledWith( @@ -740,14 +740,14 @@ describe('RelayRecordStore', () => { // base store is unchanged rangeInfo = store.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ - lastEdgeID, + lastEdgeID ]); expect(store.getConnectionIDsForRecord(nodeID)).toEqual(null); }); it('deletes edges from base stores', () => { expect(store.getConnectionIDsForRecord(firstNodeID)).toEqual([ - connectionID, + connectionID ]); store.applyRangeUpdate(connectionID, firstEdgeID, REMOVE); @@ -780,10 +780,10 @@ describe('RelayRecordStore', () => { // base store is unchanged rangeInfo = store.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ - firstEdgeID, + firstEdgeID ]); expect(store.getConnectionIDsForRecord(firstNodeID)).toEqual([ - connectionID, + connectionID ]); }); @@ -796,7 +796,7 @@ describe('RelayRecordStore', () => { var calls = [{name: 'first', value: 1}]; var rangeInfo = queuedStore.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ - firstEdgeID, + firstEdgeID ]); }); @@ -809,7 +809,7 @@ describe('RelayRecordStore', () => { var calls = [{name: 'last', value: 1}]; var rangeInfo = queuedStore.getRangeMetadata(connectionID, calls); expect(rangeInfo.requestedEdges.map(edge => edge.edgeID)).toEqual([ - lastEdgeID, + lastEdgeID ]); }); }); diff --git a/src/store/__tests__/RelayStoreData-test.js b/src/store/__tests__/RelayStoreData-test.js index 968ecbedee644..f94e7e97b60a8 100644 --- a/src/store/__tests__/RelayStoreData-test.js +++ b/src/store/__tests__/RelayStoreData-test.js @@ -58,9 +58,9 @@ describe('RelayStoreData', () => { id: '123', doesViewerLike: false, topLevelComments: { - count: 1, - }, - }, + count: 1 + } + } }; storeData.handleQueryPayload(query, response); @@ -103,13 +103,13 @@ describe('RelayStoreData', () => { id: '123', doesViewerLike: false, topLevelComments: { - count: 1, - }, - }, + count: 1 + } + } }; storeData.handleUpdatePayload(mutationQuery, payload, { configs: [], - isOptimisticUpdate: false, + isOptimisticUpdate: false }); // results are written to `records` @@ -149,14 +149,14 @@ describe('RelayStoreData', () => { id: '123', doesViewerLike: false, topLevelComments: { - count: 1, - }, - }, + count: 1 + } + } }; storeData.handleUpdatePayload(mutationQuery, payload, { configs: [], isOptimisticUpdate: true, - clientMutationID: 'mutationID', + clientMutationID: 'mutationID' }); // results are written to `queuedRecords` @@ -169,7 +169,7 @@ describe('RelayStoreData', () => { // `records` is unchanged expect(storeData.getNodeData()).toEqual({ - '123': {__dataID__: '123'}, + '123': {__dataID__: '123'} }); }); @@ -201,9 +201,9 @@ describe('RelayStoreData', () => { id: '123', doesViewerLike: false, topLevelComments: { - count: 1, - }, - }, + count: 1 + } + } }; storeData.handleQueryPayload(query, response); @@ -228,14 +228,14 @@ describe('RelayStoreData', () => { id: '123', doesViewerLike: false, topLevelComments: { - count: 1, - }, - }, + count: 1 + } + } }; storeData.handleUpdatePayload(mutationQuery, payload, { configs: [], isOptimisticUpdate: true, - clientMutationID: 'mutationID', + clientMutationID: 'mutationID' }); // simulate a server response with different data @@ -243,8 +243,8 @@ describe('RelayStoreData', () => { '123': { id: '123', doesViewerLike: true, // inverted - topLevelComments: null, // delete - }, + topLevelComments: null // delete + } }; storeData.handleQueryPayload(query, response); diff --git a/src/store/__tests__/RelayStoreData_cacheManager-test.js b/src/store/__tests__/RelayStoreData_cacheManager-test.js index 58bce8e687f64..81396af76c535 100644 --- a/src/store/__tests__/RelayStoreData_cacheManager-test.js +++ b/src/store/__tests__/RelayStoreData_cacheManager-test.js @@ -61,7 +61,7 @@ describe('RelayStoreData', function() { CLIENT_MUTATION_ID, HAS_NEXT_PAGE, HAS_PREV_PAGE, - PAGE_INFO, + PAGE_INFO } = RelayConnectionInterface); cacheManager = RelayMockCacheManager.genCacheManager(); @@ -108,7 +108,7 @@ describe('RelayStoreData', function() { } ) ); - }, + } }); }); @@ -120,13 +120,13 @@ describe('RelayStoreData', function() { expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: 2, - cacheRootCall: 0, + cacheRootCall: 0 }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ '123': { __dataID__: '123', - id: '123', - }, + id: '123' + } }); }); @@ -138,7 +138,7 @@ describe('RelayStoreData', function() { expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: 2, - cacheRootCall: 1, + cacheRootCall: 1 }); expect(cacheManager.cacheRootCall).toBeCalledWith( 'username', @@ -148,8 +148,8 @@ describe('RelayStoreData', function() { expect(cacheManager.cacheField).toBeCalledWithNodeFields({ '123': { __dataID__: '123', - id: '123', - }, + id: '123' + } }); }); @@ -161,14 +161,14 @@ describe('RelayStoreData', function() { expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: 3, - cacheRootCall: 1, + cacheRootCall: 1 }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ 'client:viewer': { __dataID__: 'client:viewer', __path__: getPathToRecord('client:viewer'), - isFbEmployee: true, - }, + isFbEmployee: true + } }); }); @@ -189,28 +189,28 @@ describe('RelayStoreData', function() { id: '123', hometown: { id: '456', - url: 'http://...', - }, - }, + url: 'http://...' + } + } }; storeData.handleQueryPayload(query, response); expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: 6, - cacheRootCall: 0, + cacheRootCall: 0 }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ '123': { __dataID__: '123', id: '123', - hometown: {__dataID__: '456'}, + hometown: {__dataID__: '456'} }, '456': { __dataID__: '456', id: '456', - url: 'http://...', - }, + url: 'http://...' + } }); }); @@ -230,9 +230,9 @@ describe('RelayStoreData', function() { id: '123', screennames: [ {service: 'GTALK'}, - {service: 'TWITTER'}, - ], - }, + {service: 'TWITTER'} + ] + } }; storeData.handleQueryPayload(query, response); @@ -240,7 +240,7 @@ describe('RelayStoreData', function() { expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: 9, - cacheRootCall: 0, + cacheRootCall: 0 }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ '123': { @@ -248,19 +248,19 @@ describe('RelayStoreData', function() { id: '123', screennames: [ {__dataID__: 'client:1'}, - {__dataID__: 'client:2'}, - ], + {__dataID__: 'client:2'} + ] }, 'client:1': { __dataID__: 'client:1', __path__: getPathToRecord('client:1'), - service: 'GTALK', + service: 'GTALK' }, 'client:2': { __dataID__: 'client:2', __path__: getPathToRecord('client:2'), - service: 'TWITTER', - }, + service: 'TWITTER' + } }); }); @@ -291,64 +291,64 @@ describe('RelayStoreData', function() { edges: [ { node: { - id: '1', + id: '1' }, - cursor: '1', + cursor: '1' }, { node: { - id: '2', + id: '2' }, - cursor: '2', - }, + cursor: '2' + } ], [PAGE_INFO]: { [HAS_PREV_PAGE]: false, - [HAS_NEXT_PAGE]: true, - }, - }, - }, + [HAS_NEXT_PAGE]: true + } + } + } }; storeData.handleQueryPayload(query, response); expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: 21, - cacheRootCall: 0, + cacheRootCall: 0 }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ '123': { __dataID__: '123', id: '123', - friends: {__dataID__: 'client:1'}, + friends: {__dataID__: 'client:1'} }, 'client:1': { __dataID__: 'client:1', __path__: getPathToRecord('client:1'), __filterCalls__: [], __forceIndex__: 0, - __range__: getRangeForRecord('client:1'), + __range__: getRangeForRecord('client:1') }, 'client:client:1:1': { __dataID__: 'client:client:1:1', __path__: getPathToRecord('client:client:1:1'), node: {__dataID__: '1'}, - cursor: '1', + cursor: '1' }, '1': { __dataID__: '1', - id: '1', + id: '1' }, 'client:client:1:2': { __dataID__: 'client:client:1:2', __path__: getPathToRecord('client:client:1:2'), node: {__dataID__: '2'}, - cursor: '2', + cursor: '2' }, '2': { __dataID__: '2', - id: '2', - }, + id: '2' + } }); }); @@ -379,31 +379,31 @@ describe('RelayStoreData', function() { edges: [], [PAGE_INFO]: { [HAS_PREV_PAGE]: false, - [HAS_NEXT_PAGE]: true, - }, - }, - }, + [HAS_NEXT_PAGE]: true + } + } + } }; storeData.handleQueryPayload(query, response); expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: 9, - cacheRootCall: 0, + cacheRootCall: 0 }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ '123': { __dataID__: '123', id: '123', - friends: {__dataID__: 'client:1'}, + friends: {__dataID__: 'client:1'} }, 'client:1': { __dataID__: 'client:1', __path__: getPathToRecord('client:1'), __filterCalls__: [], __forceIndex__: 0, - __range__: getRangeForRecord('client:1'), - }, + __range__: getRangeForRecord('client:1') + } }); }); @@ -428,8 +428,8 @@ describe('RelayStoreData', function() { [CLIENT_MUTATION_ID]: 'abc', feedback: { id: '123', - doesViewerLike: true, - }, + doesViewerLike: true + } }; storeData.handleUpdatePayload( mutationQuery, @@ -440,12 +440,12 @@ describe('RelayStoreData', function() { expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: prevCallCount + 2, // both scalar fields are updated - cacheRootCall: 0, + cacheRootCall: 0 }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ '123': { - doesViewerLike: true, - }, + doesViewerLike: true + } }); }); @@ -478,17 +478,17 @@ describe('RelayStoreData', function() { edges: [ { node: { - id: '1', + id: '1' }, - cursor: '1', - }, + cursor: '1' + } ], [PAGE_INFO]: { [HAS_PREV_PAGE]: false, - [HAS_NEXT_PAGE]: true, - }, - }, - }, + [HAS_NEXT_PAGE]: true + } + } + } }; storeData.handleQueryPayload(query, response); @@ -496,7 +496,7 @@ describe('RelayStoreData', function() { type: RelayMutationType.RANGE_ADD, connectionName: 'comments', edgeName: 'feedbackCommentEdge', - rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND}, + rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND} }]; var prevCallCount = cacheManager.cacheField.mock.calls.length; @@ -526,19 +526,19 @@ describe('RelayStoreData', function() { [CLIENT_MUTATION_ID]: 'abc', feedback: { comments: { - count: 3, + count: 3 }, - id: '123', + id: '123' }, feedbackCommentEdge: { node: { - id: '2', + id: '2' }, cursor: '2', source: { - id: '123', - }, - }, + id: '123' + } + } }; storeData.handleUpdatePayload( mutationQuery, @@ -549,24 +549,24 @@ describe('RelayStoreData', function() { expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: prevCallCount + 12, - cacheRootCall: 0, + cacheRootCall: 0 }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ 'client:1': { __range__: getRangeForRecord('client:1'), - count: 3, + count: 3 }, 'client:client:1:2': { __dataID__: 'client:client:1:2', __path__: getPathToRecord('client:client:1:2'), node: {__dataID__: '2'}, cursor: '2', - source: {__dataID__: '123'}, + source: {__dataID__: '123'} }, '2': { __dataID__: '2', - id: '2', - }, + id: '2' + } }); }); @@ -599,24 +599,24 @@ describe('RelayStoreData', function() { edges: [ { node: { - id: '1', + id: '1' }, - cursor: '1', - }, + cursor: '1' + } ], [PAGE_INFO]: { [HAS_PREV_PAGE]: false, - [HAS_NEXT_PAGE]: true, - }, - }, - }, + [HAS_NEXT_PAGE]: true + } + } + } }; storeData.handleQueryPayload(query, response); var configs = [{ type: RelayMutationType.RANGE_DELETE, pathToConnection: ['feedback', 'comments'], - deletedIDFieldName: 'deletedCommentId', + deletedIDFieldName: 'deletedCommentId' }]; var prevCallCount = cacheManager.cacheField.mock.calls.length; @@ -640,9 +640,9 @@ describe('RelayStoreData', function() { feedback: { id: '123', comments: { - count: 1, - }, - }, + count: 1 + } + } }; storeData.handleUpdatePayload( mutationQuery, @@ -653,13 +653,13 @@ describe('RelayStoreData', function() { expect(cacheManager).toContainCalledMethods({ cacheNode: 1, cacheField: prevCallCount + 4, - cacheRootCall: 0, + cacheRootCall: 0 }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ 'client:1': { __range__: getRangeForRecord('client:1'), - count: 1, - }, + count: 1 + } }); }); }); diff --git a/src/store/__tests__/RelayStoreGarbageCollector-test.js b/src/store/__tests__/RelayStoreGarbageCollector-test.js index 4472eb7df26a4..4cfa9e6c6087a 100644 --- a/src/store/__tests__/RelayStoreGarbageCollector-test.js +++ b/src/store/__tests__/RelayStoreGarbageCollector-test.js @@ -44,7 +44,7 @@ describe('RelayStoreGarbageCollector', () => { relayStoreData, stepLength ), - storeData: relayStoreData, + storeData: relayStoreData }; } @@ -246,8 +246,8 @@ describe('RelayStoreGarbageCollector', () => { 'client:1': {__dataID__: 'client:1'}, 'client:range': { __dataID__: 'client:range', - __range__: mockRange, - }, + __range__: mockRange + } }; var {garbageCollector, storeData} = createRelayStoreGarbageCollector(records); @@ -259,7 +259,7 @@ describe('RelayStoreGarbageCollector', () => { // Collectible on all registered DataIDs now set to true garbageCollector.scheduleCollection(); expect(storeData.getQueuedData()).toEqual({ - 'client:1': {__dataID__: 'client:1'}, + 'client:1': {__dataID__: 'client:1'} }); } ); @@ -277,7 +277,7 @@ describe('RelayStoreGarbageCollector', () => { var records = { a: {__dataID__: 'a'}, b: {__dataID__: 'b'}, - c: {__dataID__: 'c'}, + c: {__dataID__: 'c'} }; var {garbageCollector, storeData} = createRelayStoreGarbageCollector(records); @@ -306,13 +306,13 @@ describe('RelayStoreGarbageCollector', () => { jest.runAllTimers(); expect(storeData.getQueuedData()).toEqual({ b: {__dataID__: 'b'}, - c: {__dataID__: 'c'}, + c: {__dataID__: 'c'} }); // Second step of the second collect-cycle. `b` will be removed. (tasks[3])(); jest.runAllTimers(); expect(storeData.getQueuedData()).toEqual({ - c: {__dataID__: 'c'}, + c: {__dataID__: 'c'} }); // Executing the last step of the last collect-cycle, no more steps will // be queued after this step. @@ -346,17 +346,17 @@ describe('RelayStoreGarbageCollector', () => { var records = { a: { __dataID__: 'a', - field: {__dataID__: 'client:1'}, + field: {__dataID__: 'client:1'} }, b: {__dataID__: 'b'}, c: { __dataID__: 'c', - field: {__dataID__: 'client:2'}, + field: {__dataID__: 'client:2'} }, d: {__dataID__: 'd'}, e: {__dataID__: 'e'}, 'client:1': {__dataID__: 'client:1'}, - 'client:2': {__dataID__: 'client:2'}, + 'client:2': {__dataID__: 'client:2'} }; var {garbageCollector, storeData} = createRelayStoreGarbageCollector(records); @@ -376,7 +376,7 @@ describe('RelayStoreGarbageCollector', () => { // will be scheduled and run asynchronously. expect(storeData.getQueuedData()).toEqual({ d: {__dataID__: 'd'}, - e: {__dataID__: 'e'}, + e: {__dataID__: 'e'} }); jest.runAllTimers(); // Next collection step takes care of the remaining DataIDs `d` and `e`. @@ -399,14 +399,14 @@ describe('RelayStoreGarbageCollector', () => { a: { __dataID__: 'a', field1: {__dataID__: 'client:1'}, - field2: {__dataID__: 'client:2'}, + field2: {__dataID__: 'client:2'} }, 'client:1': {__dataID__: 'client:1'}, 'client:2': { __dataID__: 'client:2', - field3: {__dataID__: 'client:3' }, + field3: {__dataID__: 'client:3' } }, - 'client:3': {__dataID__: 'client:3'}, + 'client:3': {__dataID__: 'client:3'} }; var nodeData = storeData.getNodeData(); forEachObject(records, (data, dataID) => { @@ -416,10 +416,10 @@ describe('RelayStoreGarbageCollector', () => { var queuedRecords = { a: { __dataID__: 'a', - field2: {__dataID__: 'client:4'}, + field2: {__dataID__: 'client:4'} }, 'client:4': {__dataID__: 'client:4'}, - 'client:5': {__dataID__: 'client:5'}, + 'client:5': {__dataID__: 'client:5'} }; var queuedData = storeData.getQueuedData(); forEachObject(queuedRecords, (data, dataID) => { @@ -436,7 +436,7 @@ describe('RelayStoreGarbageCollector', () => { garbageCollector.scheduleCollection(); expect(storeData.getNodeData()).toEqual({}); expect(storeData.getQueuedData()).toEqual({ - 'client:5': {__dataID__: 'client:5'}, + 'client:5': {__dataID__: 'client:5'} }); }); @@ -448,14 +448,14 @@ describe('RelayStoreGarbageCollector', () => { a: { __dataID__: 'a', b: {__dataID__: 'b'}, - field1: {__dataID__: 'client:1'}, + field1: {__dataID__: 'client:1'} }, b: { __dataID__: 'b', - field2: {__dataID__: 'client:2'}, + field2: {__dataID__: 'client:2'} }, 'client:1': {__dataID__: 'client:1'}, - 'client:2': {__dataID__: 'client:2'}, + 'client:2': {__dataID__: 'client:2'} }; var {garbageCollector, storeData} = createRelayStoreGarbageCollector(records); @@ -469,9 +469,9 @@ describe('RelayStoreGarbageCollector', () => { expect(storeData.getQueuedData()).toEqual({ b: { __dataID__: 'b', - field2: {__dataID__: 'client:2'}, + field2: {__dataID__: 'client:2'} }, - 'client:2': {__dataID__: 'client:2'}, + 'client:2': {__dataID__: 'client:2'} }); } ); @@ -479,12 +479,12 @@ describe('RelayStoreGarbageCollector', () => { it('removes all edges when a range is removed', () => { var mockRange = new GraphQLRange(); mockRange.getEdgeIDs = jest.genMockFunction().mockReturnValue([ - 'client:1', 'client:2', + 'client:1', 'client:2' ]); var records = { range: {__dataID__: 'range', __range__: mockRange}, 'client:1': {__dataID__: 'client:1'}, - 'client:2': {__dataID__: 'client:2'}, + 'client:2': {__dataID__: 'client:2'} }; var {garbageCollector, storeData} = createRelayStoreGarbageCollector(records); @@ -492,7 +492,7 @@ describe('RelayStoreGarbageCollector', () => { expect(storeData.getQueuedData()).toEqual({ range: {__dataID__: 'range', __range__: mockRange}, 'client:1': {__dataID__: 'client:1'}, - 'client:2': {__dataID__: 'client:2'}, + 'client:2': {__dataID__: 'client:2'} }); garbageCollector.register('range'); diff --git a/src/store/__tests__/filterExclusiveKeys-test.js b/src/store/__tests__/filterExclusiveKeys-test.js index 2b407f0509f7d..320f4d021ac4c 100644 --- a/src/store/__tests__/filterExclusiveKeys-test.js +++ b/src/store/__tests__/filterExclusiveKeys-test.js @@ -25,7 +25,7 @@ describe('filterExclusiveKeys', () => { var b = {x: true, y: true, z: true}; expect(filterExclusiveKeys(a, b)).toEqual([ ['v', 'w'], - ['y', 'z'], + ['y', 'z'] ]); }); @@ -34,7 +34,7 @@ describe('filterExclusiveKeys', () => { var b = {x: true, y: true, z: true}; expect(filterExclusiveKeys(a, b)).toEqual([ [], - ['x', 'y', 'z'], + ['x', 'y', 'z'] ]); }); @@ -43,7 +43,7 @@ describe('filterExclusiveKeys', () => { var b = {x: true, y: true, z: true}; expect(filterExclusiveKeys(a, b)).toEqual([ [], - ['x', 'y', 'z'], + ['x', 'y', 'z'] ]); }); @@ -52,7 +52,7 @@ describe('filterExclusiveKeys', () => { var b = null; expect(filterExclusiveKeys(a, b)).toEqual([ ['x', 'y', 'z'], - [], + [] ]); }); @@ -61,7 +61,7 @@ describe('filterExclusiveKeys', () => { var b = {}; expect(filterExclusiveKeys(a, b)).toEqual([ ['x', 'y', 'z'], - [], + [] ]); }); }); diff --git a/src/store/__tests__/observeAllRelayQueryData-test.js b/src/store/__tests__/observeAllRelayQueryData-test.js index e8eeb9f90fd62..0c8c378e1d592 100644 --- a/src/store/__tests__/observeAllRelayQueryData-test.js +++ b/src/store/__tests__/observeAllRelayQueryData-test.js @@ -50,7 +50,7 @@ describe('observeRelayQueryData', () => { mockCallsbacks = { onCompleted: jest.genMockFunction(), onError: jest.genMockFunction(), - onNext: jest.genMockFunction(), + onNext: jest.genMockFunction() }; jest.addMatchers(RelayTestUtils.matchers); @@ -67,7 +67,7 @@ describe('observeRelayQueryData', () => { it('creates observers for the dataIDs when `subscribe` is called', () => { var query = getNode(Relay.QL`fragment on Node @relay(plural:true){id}`); var records = { - 1: {__dataID__: '1', id: 1}, + 1: {__dataID__: '1', id: 1} }; var observer = observeAllData(records, query, ['1']); @@ -80,7 +80,7 @@ describe('observeRelayQueryData', () => { var records = { 1: {__dataID__: '1', id: 1}, 2: {__dataID__: '2', id: 2}, - 3: {__dataID__: '3', id: 3}, + 3: {__dataID__: '3', id: 3} }; var observer = observeAllData(records, query, ['1', '2', '3']); @@ -97,7 +97,7 @@ describe('observeRelayQueryData', () => { var records = { 1: {__dataID__: '1', id: 1}, 2: {__dataID__: '2', id: 2}, - 3: {__dataID__: '3', id: 3}, + 3: {__dataID__: '3', id: 3} }; var observer = observeAllData(records, query, ['1', '2', '3']); @@ -112,7 +112,7 @@ describe('observeRelayQueryData', () => { var records = { 1: {__dataID__: '1', id: 1}, 2: {__dataID__: '2', id: 2}, - 3: {__dataID__: '3', id: 3}, + 3: {__dataID__: '3', id: 3} }; var observer = observeAllData(records, query, ['1', '2', '3']); @@ -132,7 +132,7 @@ describe('observeRelayQueryData', () => { var records = { 1: {__dataID__: '1', id: 1}, 2: {__dataID__: '2', id: 2}, - 3: {__dataID__: '3', id: 3}, + 3: {__dataID__: '3', id: 3} }; var observer = observeAllData(records, query, ['1', '2', '3']); @@ -147,7 +147,7 @@ describe('observeRelayQueryData', () => { var query = getNode(Relay.QL`fragment on Node @relay(plural:true){id}`); var records = { 1: {__dataID__: '1', id: 1}, - 2: {__dataID__: '2', id: 2}, + 2: {__dataID__: '2', id: 2} }; var observer = observeAllData(records, query, ['1']); @@ -163,14 +163,14 @@ describe('observeRelayQueryData', () => { var query = getNode(Relay.QL`fragment on Node @relay(plural:true){id}`); var records = { 1: {__dataID__: '1', id: 1}, - 2: {__dataID__: '2', id: 2}, + 2: {__dataID__: '2', id: 2} }; var observer = observeAllData(records, query, ['1', '2']); observer.subscribe(mockCallsbacks); expect(mockCallsbacks.onNext.mock.calls[0][0]).toEqual([ {__dataID__: '1', id: 1}, - {__dataID__: '2', id: 2}, + {__dataID__: '2', id: 2} ]); }); @@ -179,7 +179,7 @@ describe('observeRelayQueryData', () => { var records = { 1: {__dataID__: '1', id: 1}, 2: {__dataID__: '2', id: 2}, - 3: {__dataID__: '3', id: 3}, + 3: {__dataID__: '3', id: 3} }; var observer = observeAllData(records, query, ['1']); @@ -190,7 +190,7 @@ describe('observeRelayQueryData', () => { expect(mockCallsbacks.onNext.mock.calls[1][0]).toEqual([ {__dataID__: '1', id: 1}, {__dataID__: '2', id: 2}, - {__dataID__: '3', id: 3}, + {__dataID__: '3', id: 3} ]); }); @@ -199,7 +199,7 @@ describe('observeRelayQueryData', () => { var records = { a: {__dataID__: 'a', id: 1}, b: {__dataID__: 'b', id: 2}, - c: {__dataID__: 'c', id: 3}, + c: {__dataID__: 'c', id: 3} }; var observer = observeAllData(records, query, ['a', 'b', 'c']); @@ -207,14 +207,14 @@ describe('observeRelayQueryData', () => { expect(mockCallsbacks.onNext.mock.calls[0][0]).toEqual([ {__dataID__: 'a', id: 1}, {__dataID__: 'b', id: 2}, - {__dataID__: 'c', id: 3}, + {__dataID__: 'c', id: 3} ]); observer.setDataIDs(['c', 'a', 'b']); expect(mockCallsbacks.onNext.mock.calls[1][0]).toEqual([ {__dataID__: 'c', id: 3}, {__dataID__: 'a', id: 1}, - {__dataID__: 'b', id: 2}, + {__dataID__: 'b', id: 2} ]); }); @@ -222,7 +222,7 @@ describe('observeRelayQueryData', () => { var query = getNode(Relay.QL`fragment on Node @relay(plural:true){id}`); var records = { a: {__dataID__: 'a', id: 1}, - b: {__dataID__: 'b', id: 2}, + b: {__dataID__: 'b', id: 2} }; var observer = observeAllData(records, query, ['a', 'b']); @@ -230,7 +230,7 @@ describe('observeRelayQueryData', () => { observer.setDataIDs(['a']); expect(mockCallsbacks.onNext.mock.calls[1][0]).toEqual([ - {__dataID__: 'a', id: 1}, + {__dataID__: 'a', id: 1} ]); }); @@ -238,7 +238,7 @@ describe('observeRelayQueryData', () => { var query = getNode(Relay.QL`fragment on Node @relay(plural:true){id}`); var records = { a: {__dataID__: 'a', id: 1}, - b: {__dataID__: 'b', id: 2}, + b: {__dataID__: 'b', id: 2} }; var error = new Error('An error occured'); @@ -257,7 +257,7 @@ describe('observeRelayQueryData', () => { () => { var query = getNode(Relay.QL`fragment on Node @relay(plural:true){id}`); var records = { - a: {__dataID__: 'a', id: 1}, + a: {__dataID__: 'a', id: 1} }; var observer = observeAllData(records, query, ['a', 'b']); diff --git a/src/store/__tests__/observeRelayQueryData-test.js b/src/store/__tests__/observeRelayQueryData-test.js index 730ddef5bb181..ff8bd6c370b19 100644 --- a/src/store/__tests__/observeRelayQueryData-test.js +++ b/src/store/__tests__/observeRelayQueryData-test.js @@ -59,7 +59,7 @@ describe('observeRelayQueryData', () => { var name = 'RelayObserverError'; var message = 'Record `node` has not been fetched.'; observeData({}, query, 'node').subscribe({ - onError: firstMockCallback, + onError: firstMockCallback }); expect(firstMockCallback).toBeCalled(); @@ -71,7 +71,7 @@ describe('observeRelayQueryData', () => { var query = getNode(Relay.QL`fragment on Node{id, name}`); var records = {node: null}; var subscription = observeData(records, query, 'node').subscribe({ - onNext: firstMockCallback, + onNext: firstMockCallback }); subscription.dispose(); @@ -84,7 +84,7 @@ describe('observeRelayQueryData', () => { var query = getNode(Relay.QL`fragment on Node{id, name}`); var records = {node: null}; observeData(records, query, 'node').subscribe({ - onNext: firstMockCallback, + onNext: firstMockCallback }); expect(firstMockCallback).toBeCalledWith(null); @@ -107,11 +107,11 @@ describe('observeRelayQueryData', () => { it('no longer watches data when no subscribers are attached', () => { var recordsStore = new RelayRecordStore({records: { user: {id: 1, name: 'Chris', birthdate: {__dataID__: 'date'}}, - date: null, + date: null }}); var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); observeRelayQueryData(recordsStore, query, 'user').subscribe({ - onNext: firstMockCallback, + onNext: firstMockCallback }).dispose(); expect(addListenerForIDs.mock.calls.length).toBe(1); @@ -121,7 +121,7 @@ describe('observeRelayQueryData', () => { it('calls a subscriber when observed data changes', () => { var recordsStore = new RelayRecordStore({records: { user: {id: 1, name: 'Chris', birthdate: {__dataID__: 'date'}}, - date: null, + date: null }}); var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); var observable = observeRelayQueryData(recordsStore, query, 'user'); @@ -139,19 +139,19 @@ describe('observeRelayQueryData', () => { __dataID__: 'user', id: 1, name: 'Joe', - birthdate: null, + birthdate: null }); // Check that the change emitter still listens to the right id expect(addListenerForIDs.mock.calls[1][0]).toEqual([ - 'user', 'date', + 'user', 'date' ]); }); it('calls subscribers when data is added to an observed node', () => { var recordsStore = new RelayRecordStore({records: { user: {id: 1, name: 'Chris', birthdate: {__dataID__: 'date'}}, - date: null, + date: null }}); var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); var observable = observeRelayQueryData(recordsStore, query, 'user'); @@ -170,19 +170,19 @@ describe('observeRelayQueryData', () => { name: 'Chris', birthdate: { __dataID__: 'date', - day: 30, - }, + day: 30 + } }); expect(addListenerForIDs.mock.remove[0]).toBeCalled(); expect(addListenerForIDs.mock.calls[1][0]).toEqual([ - 'user', 'date', + 'user', 'date' ]); }); it('calls a subscriber when data disappears from a node', () => { var recordsStore = new RelayRecordStore({records: { user: {id: 1, name: 'Jon', birthdate: {__dataID__: 'date'}}, - date: {day: 15 }, + date: {day: 15 } }}); var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); var observable = observeRelayQueryData(recordsStore, query, 'user'); @@ -198,21 +198,21 @@ describe('observeRelayQueryData', () => { __dataID__: 'user', id: 1, name: 'Jon', - birthdate: null, + birthdate: null }); expect(addListenerForIDs.mock.calls[0][0]).toEqual([ - 'user', 'date', + 'user', 'date' ]); expect(addListenerForIDs.mock.remove[0]).toBeCalled(); expect(addListenerForIDs.mock.calls[1][0]).toEqual([ - 'user', 'date', + 'user', 'date' ]); }); it('no longer calls disposed-of subscribers when data changes', () => { var recordsStore = new RelayRecordStore({records: { user: {id: 1, name: 'Jon', birthdate: {__dataID__: 'date'}}, - date: {day: 15 }, + date: {day: 15 } }}); var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); var observable = observeRelayQueryData(recordsStore, query, 'user'); @@ -286,7 +286,7 @@ describe('observeRelayQueryData', () => { recordsStore = new RelayRecordStore({records: { chris: {__dataID__: 'chris', address: {__dataID__: 'address'}}, date: {__dataID__: 'date', day: 15}, - address: {__dataID__: 'address', city: 'Menlo Park'}, + address: {__dataID__: 'address', city: 'Menlo Park'} }}); observable = observeRelayQueryData(recordsStore, query, 'chris'); }); diff --git a/src/store/__tests__/readRelayQueryData-test.js b/src/store/__tests__/readRelayQueryData-test.js index 3702e98a4277a..11cf091a97274 100644 --- a/src/store/__tests__/readRelayQueryData-test.js +++ b/src/store/__tests__/readRelayQueryData-test.js @@ -56,7 +56,7 @@ describe('readRelayQueryData', () => { HAS_NEXT_PAGE, HAS_PREV_PAGE, PAGE_INFO, - START_CURSOR, + START_CURSOR } = RelayConnectionInterface); jest.addMatchers(RelayTestUtils.matchers); @@ -81,13 +81,13 @@ describe('readRelayQueryData', () => { 'client:viewer': { __dataID__: 'client:viewer', actor: { - __dataID__: '660361306', - }, + __dataID__: '660361306' + } }, 660361306: { __dataID__: '660361306', - firstName: 'Greg', - }, + firstName: 'Greg' + } }; var query = getNode(Relay.QL`query{viewer{actor{firstName}}}`); var data = getData({records}, query, 'client:viewer'); @@ -95,8 +95,8 @@ describe('readRelayQueryData', () => { __dataID__: 'client:viewer', actor: { __dataID__: '660361306', - firstName: 'Greg', - }, + firstName: 'Greg' + } }); }); @@ -105,10 +105,10 @@ describe('readRelayQueryData', () => { node: { name: 'Chris', birthdate: {__dataID__: 'date'}, - address: {__dataID__: 'address'}, + address: {__dataID__: 'address'} }, date: {day: 21}, - address: null, + address: null }; var query = getNode(Relay.QL`fragment on User{birthdate {day}, address {city}}`); expect( @@ -116,7 +116,7 @@ describe('readRelayQueryData', () => { ).toEqual({ node: true, date: true, - address: true, + address: true }); }); @@ -124,9 +124,9 @@ describe('readRelayQueryData', () => { var records = { 1055790163: { address: {__dataID__: 'client:1'}, - firstName: 'Yuzhi', + firstName: 'Yuzhi' }, - 'client:1': null, + 'client:1': null }; var query = getNode(Relay.QL` fragment on Actor { @@ -140,7 +140,7 @@ describe('readRelayQueryData', () => { expect(data).toEqual({ __dataID__: '1055790163', address: null, - firstName: 'Yuzhi', + firstName: 'Yuzhi' }); }); @@ -149,8 +149,8 @@ describe('readRelayQueryData', () => { feedbackID: { __dataID__: 'feedbackID', doesViewerLike: null, - id: 'feedbackID', - }, + id: 'feedbackID' + } }; var query = getNode(Relay.QL` fragment on Feedback { @@ -165,8 +165,8 @@ describe('readRelayQueryData', () => { records = { feedbackID: { __dataID__: 'feedbackID', - id: 'feedbackID', - }, + id: 'feedbackID' + } }; data = getData({records}, query, 'feedbackID'); expect(data.id).toBe('feedbackID'); @@ -178,8 +178,8 @@ describe('readRelayQueryData', () => { var records = { user_id: { id: 'user_id', - websites: [], - }, + websites: [] + } }; var query = getNode(Relay.QL`fragment on User{id,websites}`); var data = getData({records}, query, 'user_id'); @@ -192,8 +192,8 @@ describe('readRelayQueryData', () => { var records = { user_id: { id: 'user_id', - websites, - }, + websites + } }; var query = getNode(Relay.QL`fragment on User{id,websites}`); var data = getData({records}, query, 'user_id'); @@ -208,22 +208,22 @@ describe('readRelayQueryData', () => { var records = { 660361306: { __dataID__: '660361306', - firstName: 'Greg', - }, + firstName: 'Greg' + } }; var queuedRecords = { 660361306: { __dataID__: '660361306', __status__: ERROR, - firstName: 'Snoop Lion', - }, + firstName: 'Snoop Lion' + } }; var query = getNode(Relay.QL`fragment on User{firstName}`); var data = getData({records, queuedRecords}, query, '660361306'); expect(data).toEqual({ __dataID__: '660361306', __status__: ERROR, - firstName: 'Snoop Lion', + firstName: 'Snoop Lion' }); }); @@ -232,13 +232,13 @@ describe('readRelayQueryData', () => { 'client:viewer': { __dataID__: 'client:viewer', actor: { - __dataID__: '660361306', - }, + __dataID__: '660361306' + } }, 660361306: { __dataID__: '660361306', - firstName: 'Greg', - }, + firstName: 'Greg' + } }; var fragmentReference = new RelayFragmentReference( () => Relay.QL`fragment on Viewer{actor{firstName}}`, @@ -256,13 +256,13 @@ describe('readRelayQueryData', () => { 1055790163: { __dataID__: '1055790163', address: {__dataID__: 'client:1'}, - last_name: 'Zheng', + last_name: 'Zheng' }, 'client:1': { __dataID__: 'client:1', city: 'San Francisco', - country: 'US', - }, + country: 'US' + } }; var fragment1 = Relay.QL`fragment on Actor{address{city}}`; @@ -277,8 +277,8 @@ describe('readRelayQueryData', () => { address: { __dataID__: 'client:1', city: 'San Francisco', - country: 'US', - }, + country: 'US' + } }); }); @@ -288,8 +288,8 @@ describe('readRelayQueryData', () => { id: 'client:123', count: 42, __dataID__: 'client:123', - __range__: new GraphQLRange(), - }, + __range__: new GraphQLRange() + } }; var query = getNode(Relay.QL` fragment on FriendsConnection { @@ -299,7 +299,7 @@ describe('readRelayQueryData', () => { var rangeID = GraphQLStoreRangeUtils.getClientIDForRangeWithID( callsToGraphQL([ {name: 'is_viewer_friend', value: null}, - {name: 'first', value: 10}, + {name: 'first', value: 10} ]), {}, 'client:123' @@ -313,13 +313,13 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false, - }, + [HAS_PREV_PAGE]: false + } }); var data = getData({records}, query, rangeID); expect(data).toEqual({ __dataID__: rangeID, - count: 42, + count: 42 }); }); @@ -328,13 +328,13 @@ describe('readRelayQueryData', () => { feedback_id: { __dataID__: 'feedback_id', likers: { - __dataID__: 'likers_id', - }, + __dataID__: 'likers_id' + } }, likers_id: { __dataID__: 'likers_id', - count: 31337, - }, + count: 31337 + } }; var query = getNode(Relay.QL`fragment on Feedback{likers{count}}`); var data = getData({records}, query, 'feedback_id'); @@ -342,8 +342,8 @@ describe('readRelayQueryData', () => { __dataID__: 'feedback_id', likers: { __dataID__: 'likers_id', - count: 31337, - }, + count: 31337 + } }); }); @@ -362,14 +362,14 @@ describe('readRelayQueryData', () => { feedbackID: { __dataID__: 'feedbackID', topLevelComments: { - __dataID__: 'commentsID', - }, + __dataID__: 'commentsID' + } }, commentsID: { __dataID__: 'commentsID', __range__: new GraphQLRange(), - count: 57, - }, + count: 57 + } }; GraphQLRange.prototype.retrieveRangeInfoForQuery.mockReturnValue({ @@ -379,8 +379,8 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, + [HAS_PREV_PAGE]: false + } }); var data = getData({records}, query, 'feedbackID'); @@ -388,8 +388,8 @@ describe('readRelayQueryData', () => { __dataID__: 'feedbackID', topLevelComments: { __dataID__: 'commentsID_first(1)', - count: 57, - }, + count: 57 + } }); }); @@ -409,14 +409,14 @@ describe('readRelayQueryData', () => { feedbackID: { __dataID__: 'feedbackID', topLevelComments: { - __dataID__: 'commentsID', - }, + __dataID__: 'commentsID' + } }, commentsID: { __dataID__: 'commentsID', __range__: new GraphQLRange(), - count: 57, - }, + count: 57 + } }; GraphQLRange.prototype.retrieveRangeInfoForQuery.mockReturnValue({ @@ -426,8 +426,8 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, + [HAS_PREV_PAGE]: false + } }); var data = getData({records}, query, 'feedbackID'); @@ -437,9 +437,9 @@ describe('readRelayQueryData', () => { __dataID__: 'commentsID_first(1)', count: 57, [PAGE_INFO]: { - [HAS_NEXT_PAGE]: true, - }, - }, + [HAS_NEXT_PAGE]: true + } + } }); }); @@ -448,20 +448,20 @@ describe('readRelayQueryData', () => { story_id: { __dataID__: 'story_id', feedback: { - __dataID__: 'feedback_id', - }, + __dataID__: 'feedback_id' + } }, feedback_id: { __dataID__: 'feedback_id', likers: { - __dataID__: 'likers_id', - }, + __dataID__: 'likers_id' + } }, likers_id: { __dataID__: 'likers_id', __range__: new GraphQLRange(), - count: 31337, - }, + count: 31337 + } }; var error = 'Invariant Violation: ' + @@ -486,20 +486,20 @@ describe('readRelayQueryData', () => { story_id: { __dataID__: 'story_id', feedback: { - __dataID__: 'feedback_id', - }, + __dataID__: 'feedback_id' + } }, feedback_id: { __dataID__: 'feedback_id', likers: { - __dataID__: 'likers_id', - }, + __dataID__: 'likers_id' + } }, likers_id: { __dataID__: 'likers_id', __range__: new GraphQLRange(), - count: 31337, - }, + count: 31337 + } }; var error = 'Invariant Violation: ' + @@ -533,34 +533,34 @@ describe('readRelayQueryData', () => { feedback_id: { __dataID__: 'feedback_id', likers: { - __dataID__: 'likers_id', - }, + __dataID__: 'likers_id' + } }, likers_id: { __dataID__: 'likers_id', edges: [ { - __dataID__: 'likers_edge_id', - }, + __dataID__: 'likers_edge_id' + } ], [PAGE_INFO]: { - __dataID__: 'likers_page_info_id', - }, + __dataID__: 'likers_page_info_id' + } }, likers_edge_id: { __dataID__: 'likers_edge_id', node: { - __dataID__: 'liker_id', - }, + __dataID__: 'liker_id' + } }, likers_page_info_id: { __dataID__: 'likers_page_info_id', - [HAS_NEXT_PAGE]: true, + [HAS_NEXT_PAGE]: true }, liker_id: { __dataID__: 'liker_id', - name: 'Tim', - }, + name: 'Tim' + } }; var query = getNode(Relay.QL`fragment on Feedback{likers(first:"1"){edges{node{name}}}}`); @@ -574,11 +574,11 @@ describe('readRelayQueryData', () => { __dataID__: 'likers_edge_id', node: { __dataID__: 'liker_id', - name: 'Tim', - }, - }, - ], - }, + name: 'Tim' + } + } + ] + } }); query = getNode(Relay.QL` @@ -591,9 +591,9 @@ describe('readRelayQueryData', () => { __dataID__: 'likers_id_first(1)', [PAGE_INFO]: { __dataID__: 'likers_page_info_id', - [HAS_NEXT_PAGE]: true, - }, - }, + [HAS_NEXT_PAGE]: true + } + } }); }); @@ -602,13 +602,13 @@ describe('readRelayQueryData', () => { feedback_id: { __dataID__: 'feedback_id', comments: { - __dataID__: 'comments_id', - }, + __dataID__: 'comments_id' + } }, comments_id: { __dataID__: 'comments_id', - __range__: new GraphQLRange(), - }, + __range__: new GraphQLRange() + } }; var fragmentReference = new RelayFragmentReference( () => Relay.QL`fragment on PageInfo{hasNextPage}`, @@ -630,8 +630,8 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, + [HAS_PREV_PAGE]: false + } }); var data = getData( @@ -645,8 +645,8 @@ describe('readRelayQueryData', () => { __dataID__: 'comments_id_first(1)', [PAGE_INFO]: { [START_CURSOR]: 'cursor', - [HAS_NEXT_PAGE]: true, - }, + [HAS_NEXT_PAGE]: true + } }); data = getData({records}, query, 'feedback_id'); @@ -665,22 +665,22 @@ describe('readRelayQueryData', () => { feedback_id: { __dataID__: 'feedback_id', comments: { - __dataID__: 'comments_id', - }, + __dataID__: 'comments_id' + } }, comments_id: { __dataID__: 'comments_id', - __range__: new GraphQLRange(), + __range__: new GraphQLRange() }, comment_node_id: { __dataID__: 'comment_node_id', - id: 'comment_node_id', + id: 'comment_node_id' }, comment_edge_id: { __dataID__: 'comment_edge_id', node: {__dataID__: 'comment_node_id'}, - cursor: 'cursor', - }, + cursor: 'cursor' + } }; var fragmentReference = new RelayFragmentReference( () => Relay.QL`fragment on CommentsConnection{edges{node{id}}}`, @@ -707,8 +707,8 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, + [HAS_PREV_PAGE]: false + } }); var data = getData( @@ -724,12 +724,12 @@ describe('readRelayQueryData', () => { __dataID__: 'comment_edge_id', node: { __dataID__: 'comment_node_id', - id: 'comment_node_id', - }, + id: 'comment_node_id' + } }], [PAGE_INFO]: { - [START_CURSOR]: 'cursor', - }, + [START_CURSOR]: 'cursor' + } }); data = getData({records}, query, 'feedback_id'); @@ -750,25 +750,25 @@ describe('readRelayQueryData', () => { id: 'user_id', screennames: [ {__dataID__: 'client1'}, - {__dataID__: 'client2'}, + {__dataID__: 'client2'} ], - hometown: {__dataID__: 'hometown_id'}, + hometown: {__dataID__: 'hometown_id'} }, hometown_id: { __dataID__: 'hometown_id', id: 'hometown_id', - name: 'hometown name', + name: 'hometown name' }, client1: { __dataID__: 'client1', service: 'GTALK', - name: '123', + name: '123' }, client2: { __dataID__: 'client1', service: 'TWITTER', - name: '123', - }, + name: '123' + } }; var fragmentReference = new RelayFragmentReference( () => Relay.QL`fragment on Screenname {service, name}`, @@ -820,16 +820,16 @@ describe('readRelayQueryData', () => { var records = { 'client:viewer': { __dataID__: 'client:viewer', - actor: null, - }, + actor: null + } }; var data = getData({records}, query, 'client:viewer'); expect(data.actor).toBeNull(); records = { 'client:viewer': { - __dataID__: 'client:viewer', - }, + __dataID__: 'client:viewer' + } }; data = getData({records}, query, 'client:viewer'); expect(data.actor).toBeUndefined(); @@ -849,8 +849,8 @@ describe('readRelayQueryData', () => { user_id: { __dataID__: 'user_id', id: 'user_id', - address: null, - }, + address: null + } }; var data = getData({records}, query, 'user_id'); expect(data.address).toBeNull(); @@ -859,8 +859,8 @@ describe('readRelayQueryData', () => { records = { user_id: { __dataID__: 'user_id', - id: 'user_id', - }, + id: 'user_id' + } }; data = getData({records}, query, 'user_id'); expect(data.address).toBeUndefined(); @@ -881,8 +881,8 @@ describe('readRelayQueryData', () => { var records = { 'client:viewer': { - __dataID__: 'client:viewer', - }, + __dataID__: 'client:viewer' + } }; var data = getData({records}, query, 'client:viewer'); @@ -907,13 +907,13 @@ describe('readRelayQueryData', () => { '123': { __dataID__: '123', birthdate: { - __dataID__: 'client:1', - }, + __dataID__: 'client:1' + } }, 'client:1': { __dataID__: 'client:1', - year: null, - }, + year: null + } }; var data = getData({records}, query, '123'); @@ -933,13 +933,13 @@ describe('readRelayQueryData', () => { 'user_id': { __dataID__: 'user_id', friends: { - __dataID__: 'client:friends', - }, + __dataID__: 'client:friends' + } }, 'client:friends': { __dataID__: 'client:friends', - count: 42, - }, + count: 42 + } }; var data = getData({records}, query, 'user_id'); expect(data.friends.count).toBe(42); @@ -950,14 +950,14 @@ describe('readRelayQueryData', () => { 'user_id': { __dataID__: 'user_id', friends: { - __dataID__: 'client:friends', - }, + __dataID__: 'client:friends' + } }, 'client:friends': { __dataID__: 'client:friends', __range__: new GraphQLRange(), - count: 42, - }, + count: 42 + } }; GraphQLRange.prototype.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['edgeID'], @@ -966,8 +966,8 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, + [HAS_PREV_PAGE]: false + } }); data = getData({records}, query, 'user_id'); expect(data.friends.count).toBe(42); @@ -1009,21 +1009,21 @@ describe('readRelayQueryData', () => { __dataID__: 'storyID', id: 'storyID', feedback: { - __dataID__: 'feedbackID', - }, + __dataID__: 'feedbackID' + } }, feedbackID: { __dataID__: 'feedbackID', - id: 'feedbackID', - }, + id: 'feedbackID' + } }; var data = getData({records}, query, 'storyID'); expect(data).toEqual({ __dataID__: 'storyID', id: 'storyID', feedback: { - __dataID__: 'feedbackID', - }, + __dataID__: 'feedbackID' + } }); }); @@ -1055,31 +1055,31 @@ describe('readRelayQueryData', () => { userID: { __dataID__: 'userID', friends: { - __dataID__: 'friendsID', - }, + __dataID__: 'friendsID' + } }, friendsID: { __dataID__: 'friendsID', - __range__: new GraphQLRange(), + __range__: new GraphQLRange() }, edgeID: { __dataID__: 'edgeID', node: { - __dataID__: 'friendID', + __dataID__: 'friendID' }, - cursor: 'cursor', + cursor: 'cursor' }, friendID: { __dataID__: 'friendID', address: { - __dataID__: 'addressID', - }, + __dataID__: 'addressID' + } }, addressID: { __dataID__: 'addressID', city: 'Menlo Park', - country: 'USA', - }, + country: 'USA' + } }; GraphQLRange.prototype.retrieveRangeInfoForQuery.mockReturnValue({ @@ -1089,8 +1089,8 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false, - }, + [HAS_PREV_PAGE]: false + } }); // First we read the outer fragment, which populates the @@ -1105,8 +1105,8 @@ describe('readRelayQueryData', () => { __dataID__: 'userID', friends: { __dataID__: 'friendsID_first(25)', - [getNode(fragmentReference).getConcreteFragmentID()]: pointer, - }, + [getNode(fragmentReference).getConcreteFragmentID()]: pointer + } }); // Now we read the inner (non-local) fragment, using the range client ID. @@ -1125,11 +1125,11 @@ describe('readRelayQueryData', () => { address: { __dataID__: 'addressID', city: 'Menlo Park', - country: 'USA', - }, - }, - }, - ], + country: 'USA' + } + } + } + ] }); }); @@ -1138,14 +1138,14 @@ describe('readRelayQueryData', () => { 'client:viewer': { __dataID__: 'client:viewer', actor: { - __dataID__: '660361306', - }, + __dataID__: '660361306' + } }, 660361306: { __dataID__: '660361306', firstName: 'Greg', - id: '660361306', - }, + id: '660361306' + } }; var query = getNode(Relay.QL`query{viewer{actor{firstName}}}`); var data = getData( @@ -1159,8 +1159,8 @@ describe('readRelayQueryData', () => { actor: { __dataID__: '660361306', firstName: 'Greg', - id: '660361306', - }, + id: '660361306' + } }); }); @@ -1179,14 +1179,14 @@ describe('readRelayQueryData', () => { feedbackID: { __dataID__: 'feedbackID', topLevelComments: { - __dataID__: 'commentsID', - }, + __dataID__: 'commentsID' + } }, commentsID: { __dataID__: 'commentsID', __range__: new GraphQLRange(), - count: 57, - }, + count: 57 + } }; GraphQLRange.prototype.retrieveRangeInfoForQuery.mockReturnValue({ @@ -1196,8 +1196,8 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, + [HAS_PREV_PAGE]: false + } }); var data = getData( @@ -1212,9 +1212,9 @@ describe('readRelayQueryData', () => { __dataID__: 'commentsID_first(1)', [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, - }, + [HAS_PREV_PAGE]: false + } + } }); }); diff --git a/src/store/__tests__/validateRelayReadQuery-test.js b/src/store/__tests__/validateRelayReadQuery-test.js index 4cd777e196ea8..a3c037e3d0d6c 100644 --- a/src/store/__tests__/validateRelayReadQuery-test.js +++ b/src/store/__tests__/validateRelayReadQuery-test.js @@ -47,7 +47,7 @@ describe('validateRelayReadQuery', () => { alias ); return true; - }, + } }); }); diff --git a/src/store/filterExclusiveKeys.js b/src/store/filterExclusiveKeys.js index eaf3122a29eeb..2b5260d06f383 100644 --- a/src/store/filterExclusiveKeys.js +++ b/src/store/filterExclusiveKeys.js @@ -31,7 +31,7 @@ function filterExclusiveKeys( } return [ keysA.filter(key => !hasOwnProperty.call(b, key)), - keysB.filter(key => !hasOwnProperty.call(a, key)), + keysB.filter(key => !hasOwnProperty.call(a, key)) ]; } diff --git a/src/store/observeAllRelayQueryData.js b/src/store/observeAllRelayQueryData.js index 7b6f67d72133b..077b5b3f63817 100644 --- a/src/store/observeAllRelayQueryData.js +++ b/src/store/observeAllRelayQueryData.js @@ -93,7 +93,7 @@ class RelayQueryMultipleDataObservable { if (this._lastError) { callbacks.onError(this._lastError); return { - dispose: emptyFunction, + dispose: emptyFunction }; } @@ -112,7 +112,7 @@ class RelayQueryMultipleDataObservable { callbacks.onError(this._lastError); this._disposeSubscriptions(dataIDToSubscriptionIndex); return { - dispose: emptyFunction, + dispose: emptyFunction }; } this._subscribeCalls.push({callbacks, dataIDToSubscriptionIndex}); @@ -140,7 +140,7 @@ class RelayQueryMultipleDataObservable { this._subscriptions = {}; this._wrappedData = {}; } - }, + } }; } @@ -211,7 +211,7 @@ class RelayQueryMultipleDataObservable { subscriptions.push(observer.subscribe({ onCompleted: () => this._handleCompleted(dataID), onError: error => this._handleError(dataID, error), - onNext: data => this._handleNext(dataID, data), + onNext: data => this._handleNext(dataID, data) })); } } diff --git a/src/store/observeRelayQueryData.js b/src/store/observeRelayQueryData.js index 518999edd1988..3ef2fa2bd689d 100644 --- a/src/store/observeRelayQueryData.js +++ b/src/store/observeRelayQueryData.js @@ -103,7 +103,7 @@ class RelayQueryDataObservable { if (this._lastError) { callbacks.onError(this._lastError); return { - dispose: emptyFunction, + dispose: emptyFunction }; } @@ -134,7 +134,7 @@ class RelayQueryDataObservable { // No longer observing any dataIDs this._observedDataIDs = {}; } - }, + } }; } diff --git a/src/store/readRelayQueryData.js b/src/store/readRelayQueryData.js index 4af90235d274d..64d590c4512f8 100644 --- a/src/store/readRelayQueryData.js +++ b/src/store/readRelayQueryData.js @@ -98,7 +98,7 @@ class RelayStoreReader extends RelayQueryVisitor { ): StoreReaderResult { var result = { data: (undefined: $FlowIssue), - dataIDs: ({}: $FlowIssue), + dataIDs: ({}: $FlowIssue) }; var rangeData = GraphQLStoreRangeUtils.parseRangeClientID(dataID); var status = this._recordStore.getRecordStatus( @@ -111,7 +111,7 @@ class RelayStoreReader extends RelayQueryVisitor { parent: null, rangeInfo: null, seenDataIDs: result.dataIDs, - storeDataID: dataID, + storeDataID: dataID }; this.visit(queryNode, state); result.data = state.data; @@ -208,7 +208,7 @@ class RelayStoreReader extends RelayQueryVisitor { parent: node, rangeInfo: null, seenDataIDs: state.seenDataIDs, - storeDataID: dataID, + storeDataID: dataID }; node.getChildren().forEach(child => this.visit(child, nextState)); return nextState.data; @@ -236,7 +236,7 @@ class RelayStoreReader extends RelayQueryVisitor { parent: node, rangeInfo: metadata && calls.length ? metadata : null, seenDataIDs: state.seenDataIDs, - storeDataID: dataID, + storeDataID: dataID }; this.traverse(node, nextState); this._setDataValue(state, applicationName, nextState.data); @@ -255,7 +255,7 @@ class RelayStoreReader extends RelayQueryVisitor { parent: node, rangeInfo: null, seenDataIDs: state.seenDataIDs, - storeDataID: edgeData.edgeID, + storeDataID: edgeData.edgeID }; this.traverse(node, nextState); return nextState.data; @@ -327,7 +327,7 @@ class RelayStoreReader extends RelayQueryVisitor { parent: node, rangeInfo: null, seenDataIDs: state.seenDataIDs, - storeDataID: dataID, + storeDataID: dataID }; var status = this._recordStore.getRecordStatus(dataID); if (status === RelayRecordStatus.EXISTENT) { diff --git a/src/tools/RelayDeprecated.js b/src/tools/RelayDeprecated.js index c4b7652fa55d0..05538ff240434 100644 --- a/src/tools/RelayDeprecated.js +++ b/src/tools/RelayDeprecated.js @@ -33,7 +33,7 @@ var RelayDeprecated = { */ warn({was, now}: { was: string, - now: string, + now: string }): void { warning(false, 'Relay: `%s` is deprecated; use `%s`.', was, now); }, @@ -44,7 +44,7 @@ var RelayDeprecated = { createWarning({was, now, adapter}: { was: string, now: string, - adapter: Function, + adapter: Function }): Function { return function() { RelayDeprecated.warn({was, now}); @@ -59,13 +59,13 @@ var RelayDeprecated = { var deprecatedProperties = [ 'queries', 'queryParams', - 'processQueryParams', + 'processQueryParams' ].filter(property => maybeSpec.hasOwnProperty(property)); var modernProperties = [ 'fragments', 'initialVariables', - 'prepareVariables', + 'prepareVariables' ].filter(property => maybeSpec.hasOwnProperty(property)); if (modernProperties.length) { @@ -103,7 +103,7 @@ var RelayDeprecated = { if (queryParams && !Mutation.initialVariables) { RelayDeprecated.warn({ was: Mutation.name + '.queryParams', - now: Mutation.name + '.initialVariables', + now: Mutation.name + '.initialVariables' }); Mutation.initialVariables = queryParams; } @@ -115,12 +115,12 @@ var RelayDeprecated = { if (queries && !Mutation.fragments) { RelayDeprecated.warn({ was: Mutation.name + '.queries', - now: Mutation.name + '.fragments', + now: Mutation.name + '.fragments' }); Mutation.fragments = queries; } return Mutation.fragments; - }, + } }; diff --git a/src/tools/RelayError.js b/src/tools/RelayError.js index f4a5539875aed..9eb28094d9660 100644 --- a/src/tools/RelayError.js +++ b/src/tools/RelayError.js @@ -44,7 +44,7 @@ var RelayError = { ); (error: any).source = errorData; return error; - }, + } }; /** diff --git a/src/tools/RelayGarbageCollection.js b/src/tools/RelayGarbageCollection.js index 006788dcc15bd..81536c3ff31b0 100644 --- a/src/tools/RelayGarbageCollection.js +++ b/src/tools/RelayGarbageCollection.js @@ -63,7 +63,7 @@ var RelayGarbageCollection = { if (garbageCollector) { garbageCollector.scheduleCollection(stepLength); } - }, + } }; module.exports = RelayGarbageCollection; diff --git a/src/tools/RelayProfiler.js b/src/tools/RelayProfiler.js index a12cbf2d0a3b4..7515ffd7fd12c 100644 --- a/src/tools/RelayProfiler.js +++ b/src/tools/RelayProfiler.js @@ -210,7 +210,7 @@ var RelayProfiler = { profileHandler.onStop(name, state); } }); - }, + } }; } } @@ -238,7 +238,7 @@ var RelayProfiler = { removeFromArray(profileHandlersByName[name], handler); } } - }, + } }; diff --git a/src/tools/RelayTaskScheduler.js b/src/tools/RelayTaskScheduler.js index 3de29e956d6c9..82df23e8492b7 100644 --- a/src/tools/RelayTaskScheduler.js +++ b/src/tools/RelayTaskScheduler.js @@ -123,7 +123,7 @@ var RelayTaskScheduler = { }); scheduleIfNecessary(); return promise; - }, + } }; function scheduleIfNecessary(): void { diff --git a/src/tools/__mocks__/RelayProfiler.js b/src/tools/__mocks__/RelayProfiler.js index ed726261225ad..6e5b00fe9ffff 100644 --- a/src/tools/__mocks__/RelayProfiler.js +++ b/src/tools/__mocks__/RelayProfiler.js @@ -32,11 +32,11 @@ var RelayProfiler = { detachAggregateHandler: jest.genMockFunction(), profile: jest.genMockFunction().mockImplementation(() => { return { - stop: jest.genMockFunction(), + stop: jest.genMockFunction() }; }), attachProfileHandler: jest.genMockFunction(), - detachProfileHandler: jest.genMockFunction(), + detachProfileHandler: jest.genMockFunction() }; module.exports = RelayProfiler; diff --git a/src/tools/__mocks__/RelayTestUtils.js b/src/tools/__mocks__/RelayTestUtils.js index a827d51a2c811..2c15eb47ee2b7 100644 --- a/src/tools/__mocks__/RelayTestUtils.js +++ b/src/tools/__mocks__/RelayTestUtils.js @@ -43,7 +43,7 @@ var RelayTestUtils = { } } ContextSetter.childContextTypes = { - route: RelayPropTypes.QueryConfig.isRequired, + route: RelayPropTypes.QueryConfig.isRequired }; class MockPointer { @@ -90,7 +90,7 @@ var RelayTestUtils = { container ); return result; - }, + } }; }, @@ -354,7 +354,7 @@ var RelayTestUtils = { } var fragment = RelayQuery.Node.create( new GraphQL.QueryFragment('Test', 'Node', [ - new GraphQL.Field('__test__'), + new GraphQL.Field('__test__') ]), RelayMetaRoute.get('$RelayTestUtils'), {} @@ -367,7 +367,7 @@ var RelayTestUtils = { 'Expected:', ' ' + printRelayQuery(actualQuery), '\ntoMatchPath:', - ' ' + printRelayQuery(expectedQuery), + ' ' + printRelayQuery(expectedQuery) ].filter(token => token).join('\n'); return false; @@ -433,7 +433,7 @@ var RelayTestUtils = { return true; }; return matchQueryJSON(this.actual, expected, []); - }, + } }, unmockRelay() { @@ -474,7 +474,7 @@ var RelayTestUtils = { payload, ); return changeTracker.getChangeSet(); - }, + } }; /** @@ -538,7 +538,7 @@ function printQueryComparison(actual, expected, message) { formatRefParam(actual), message + ':', ' ' + printRelayQuery(expected), - formatRefParam(expected), + formatRefParam(expected) ].filter(line => !!line).join('\n'); } diff --git a/src/tools/__mocks__/matchRecord.js b/src/tools/__mocks__/matchRecord.js index b3696779a29a9..0a8d4022e0314 100644 --- a/src/tools/__mocks__/matchRecord.js +++ b/src/tools/__mocks__/matchRecord.js @@ -20,7 +20,7 @@ type Result = { var METADATA_KEYS = { '__dataID__': true, '__range__': true, - '__status__': true, + '__status__': true }; function matchRecord( @@ -32,7 +32,7 @@ function matchRecord( return { isMatched: actual === expected, message: 'be ' + expected + ', but got ' + actual, - path, + path }; } @@ -43,20 +43,20 @@ function matchRecord( message: ( 'be ' + expected.toString() + ', but got ' + actual.toString() ), - path, + path }; } else { return { isMatched: false, message: 'be ' + expected + ', but got ' + actual.toString(), - path, + path }; } } else if (expected instanceof GraphQLFragmentPointer) { return { isMatched: false, message: 'be ' + expected.toString() + ', but got ' + actual, - path, + path }; } @@ -67,7 +67,7 @@ function matchRecord( return { isMatched: false, message: 'not have key ' + key, - path, + path }; } } @@ -78,7 +78,7 @@ function matchRecord( return { isMatched: false, message: 'have key ' + k, - path, + path }; } if (k in METADATA_KEYS) { @@ -108,7 +108,7 @@ function matchRecord( return { isMatched: true, message: null, - path: null, + path: null }; } diff --git a/src/tools/__tests__/RelayProfiler-test.js b/src/tools/__tests__/RelayProfiler-test.js index 5487a5faeb97d..82f1d4be69dff 100644 --- a/src/tools/__tests__/RelayProfiler-test.js +++ b/src/tools/__tests__/RelayProfiler-test.js @@ -69,7 +69,7 @@ describe('RelayProfiler', function() { expect(actualOrdering).toEqual([ 'beforeCallback', 'mockMethod', - 'afterCallback', + 'afterCallback' ]); }); @@ -101,7 +101,7 @@ describe('RelayProfiler', function() { '1: beforeCallback', '0: mockMethod', '1: afterCallback', - '2: afterCallback', + '2: afterCallback' ]); }); @@ -185,7 +185,7 @@ describe('RelayProfiler', function() { '1: afterCallback', '2: afterCallback', '3: afterCallback (aggregate)', - '4: afterCallback (aggregate)', + '4: afterCallback (aggregate)' ]); }); @@ -229,7 +229,7 @@ describe('RelayProfiler', function() { onStop(name) { expect(name).toBe('mockBehavior'); actualOrdering.push('1: afterEnd'); - }, + } }); RelayProfiler.attachProfileHandler('mockBehavior', { @@ -240,14 +240,14 @@ describe('RelayProfiler', function() { onStop(name) { expect(name).toBe('mockBehavior'); actualOrdering.push('2: afterEnd'); - }, + } }); var profiler = RelayProfiler.profile('mockBehavior'); expect(actualOrdering).toEqual([ '2: beforeEnd', - '1: beforeEnd', + '1: beforeEnd' ]); profiler.stop(); @@ -256,14 +256,14 @@ describe('RelayProfiler', function() { '2: beforeEnd', '1: beforeEnd', '1: afterEnd', - '2: afterEnd', + '2: afterEnd' ]); }); it('does not invoke detached profile handlers', () => { var mockHandlers = { onStart: jest.genMockFunction(), - onStop: jest.genMockFunction(), + onStop: jest.genMockFunction() }; RelayProfiler.attachProfileHandler('mockBehavior', mockHandlers); @@ -277,7 +277,7 @@ describe('RelayProfiler', function() { it('passes state to each profile handler', () => { var mockHandlers = { onStart: jest.genMockFunction(), - onStop: jest.genMockFunction(), + onStop: jest.genMockFunction() }; var state = {}; diff --git a/src/traversal/__tests__/checkRelayQueryData-test.js b/src/traversal/__tests__/checkRelayQueryData-test.js index 716d7d391af4b..ccdf3303489e3 100644 --- a/src/traversal/__tests__/checkRelayQueryData-test.js +++ b/src/traversal/__tests__/checkRelayQueryData-test.js @@ -70,7 +70,7 @@ describe('checkRelayQueryData', () => { it('returns true when node is null', () => { var records = { - 1055790163: null, + 1055790163: null }; var result = hasData(getNode( @@ -89,8 +89,8 @@ describe('checkRelayQueryData', () => { var records = { 1055790163: { id: '1055790163', - __dataID__: '1055790163', - }, + __dataID__: '1055790163' + } }; var result = hasData(getNode( @@ -109,8 +109,8 @@ describe('checkRelayQueryData', () => { var records = { 1055790163: { id: '1055790163', - __dataID__: '1055790163', - }, + __dataID__: '1055790163' + } }; var result = hasData(getNode( @@ -129,8 +129,8 @@ describe('checkRelayQueryData', () => { var records = { 1055790163: { id: '1055790163', - __dataID__: '1055790163', - }, + __dataID__: '1055790163' + } }; var result = hasData(getNode( @@ -151,8 +151,8 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', firstName: 'Yuzhi', - __dataID__: '1055790163', - }, + __dataID__: '1055790163' + } }; var result = hasData(getNode( @@ -174,8 +174,8 @@ describe('checkRelayQueryData', () => { var records = { 1055790163: { id: '1055790163', - __dataID__: '1055790163', - }, + __dataID__: '1055790163' + } }; var result = hasData(getNode( @@ -198,12 +198,12 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - friends: { __dataID__: 'friends_id'}, + friends: { __dataID__: 'friends_id'} }, friends_id: { __dataID__:'friends_id', - count: 500, - }, + count: 500 + } }; var result = hasData(getNode( @@ -226,8 +226,8 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - friends: { __dataID__: 'friends_id'}, - }, + friends: { __dataID__: 'friends_id'} + } }; var result = hasData(getNode( @@ -250,11 +250,11 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - friends: { __dataID__: 'friends_id'}, + friends: { __dataID__: 'friends_id'} }, friends_id: { - __dataID__: 'friends_id', - }, + __dataID__: 'friends_id' + } }; var result = hasData(getNode( @@ -277,12 +277,12 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - screennames: [{__dataID__: 'client:screenname1'}], + screennames: [{__dataID__: 'client:screenname1'}] }, 'client:screenname1': { __dataID__: 'client:screenname1', - service: true, - }, + service: true + } }; var result = hasData(getNode( @@ -305,8 +305,8 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - screennames: [{__dataID__: 'client:screenname1'}], - }, + screennames: [{__dataID__: 'client:screenname1'}] + } }; var result = hasData(getNode( @@ -329,11 +329,11 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - screennames: [{__dataID__: 'client:screenname1'}], + screennames: [{__dataID__: 'client:screenname1'}] }, 'client:screenname1': { - __dataID__: 'client:screenname1', - }, + __dataID__: 'client:screenname1' + } }; var result = hasData(getNode( @@ -356,17 +356,17 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - friends: { __dataID__: 'friends_id'}, + friends: { __dataID__: 'friends_id'} }, friends_id: { __dataID__:'friends_id', - __range__: new GraphQLRange(), - }, + __range__: new GraphQLRange() + } }; records.friends_id.__range__.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: [], diffCalls: [], - pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false }, + pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false } }); var result = hasData(getNode( @@ -390,17 +390,17 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - friends: { __dataID__: 'friends_id'}, + friends: { __dataID__: 'friends_id'} }, friends_id: { __dataID__:'friends_id', - __range__: new GraphQLRange(), - }, + __range__: new GraphQLRange() + } }; records.friends_id.__range__.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: [], diffCalls: [new GraphQL.Callv('first', 10)], - pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false }, + pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false } }); var result = hasData(getNode( @@ -423,20 +423,20 @@ describe('checkRelayQueryData', () => { var records = { viewer_id: { '__configs__.named(some_gk)': {__dataID__:'configs_id'}, - __dataID__: 'viewer_id', + __dataID__: 'viewer_id' }, configs_id: { __dataID__: 'configs_id', - edges: [{__dataID__: 'edge_id'}], + edges: [{__dataID__: 'edge_id'}] }, edge_id: { __dataID__: 'edge_id', - node: {__dataID__:'node_id'}, + node: {__dataID__:'node_id'} }, node_id: { __dataID__: 'node_id', - name: 'some_gk', - }, + name: 'some_gk' + } }; var result = hasData(getNode( @@ -465,25 +465,25 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - friends: { __dataID__: 'friends_id'}, + friends: { __dataID__: 'friends_id'} }, friends_id: { __dataID__:'friends_id', - __range__: new GraphQLRange(), + __range__: new GraphQLRange() }, edge_id: { __dataID__: 'edge_id', - node: {__dataID__:'node_id'}, + node: {__dataID__:'node_id'} }, node_id: { __dataID__: 'node_id', - id: 'node_id', - }, + id: 'node_id' + } }; records.friends_id.__range__.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['edge_id'], diffCalls: [], - pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false }, + pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false } }); var result = hasData(getNode( @@ -507,25 +507,25 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - friends: { __dataID__: 'friends_id'}, + friends: { __dataID__: 'friends_id'} }, friends_id: { __dataID__:'friends_id', - __range__: new GraphQLRange(), + __range__: new GraphQLRange() }, edge_id: { __dataID__: 'edge_id', node: {__dataID__:'node_id'}, - cursor: 'cursor', + cursor: 'cursor' }, node_id: { - __dataID__: 'node_id', - }, + __dataID__: 'node_id' + } }; records.friends_id.__range__.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['edge_id'], diffCalls: [], - pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false }, + pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false } }); var result = hasData(getNode( @@ -549,8 +549,8 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - username: 'yuzhi', - }, + username: 'yuzhi' + } }; var fragment1 = Relay.QL` diff --git a/src/traversal/__tests__/containsRelayQueryRootCall-test.js b/src/traversal/__tests__/containsRelayQueryRootCall-test.js index c712b14a4a6c3..d116aae52d1a4 100644 --- a/src/traversal/__tests__/containsRelayQueryRootCall-test.js +++ b/src/traversal/__tests__/containsRelayQueryRootCall-test.js @@ -34,7 +34,7 @@ describe('containsRelayQueryRootCall', function() { getNode(thisQuery), getNode(thatQuery) ); - }, + } }); }); diff --git a/src/traversal/__tests__/diffRelayQuery-test.js b/src/traversal/__tests__/diffRelayQuery-test.js index 043755c9132a2..ab1f35a26033e 100644 --- a/src/traversal/__tests__/diffRelayQuery-test.js +++ b/src/traversal/__tests__/diffRelayQuery-test.js @@ -46,7 +46,7 @@ describe('diffRelayQuery', () => { printRelayQuery = require('printRelayQuery'); rootCallMap = { - viewer: {'': 'client:viewer'}, + viewer: {'': 'client:viewer'} }; jest.addMatchers(RelayTestUtils.matchers); @@ -80,8 +80,8 @@ describe('diffRelayQuery', () => { var records = { '4': { __dataID__: '4', - id: '4', - }, + id: '4' + } }; var store = new RelayRecordStore({records}); var tracker = new RelayQueryTracker(); @@ -102,8 +102,8 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - name: 'Mark', - }, + name: 'Mark' + } }; var store = new RelayRecordStore({records}); var tracker = new RelayQueryTracker(); @@ -124,8 +124,8 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - 'profilePicture.size(32)': 'https://facebook.com', - }, + 'profilePicture.size(32)': 'https://facebook.com' + } }; var store = new RelayRecordStore({records}); var tracker = new RelayQueryTracker(); @@ -146,8 +146,8 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - 'profilePicture.size(32)': 'https://facebook.com', - }, + 'profilePicture.size(32)': 'https://facebook.com' + } }; var store = new RelayRecordStore({records}); var tracker = new RelayQueryTracker(); @@ -175,13 +175,13 @@ describe('diffRelayQuery', () => { var records = { 'client:viewer': { __dataID__: 'client:viewer', - actor: {__dataID__: '4808495'}, + actor: {__dataID__: '4808495'} }, '4808495': { __dataID__: '4808495', id: '4808495', - name: 'Joe', - }, + name: 'Joe' + } }; var store = new RelayRecordStore({records}, {rootCallMap}); var tracker = new RelayQueryTracker(); @@ -216,19 +216,19 @@ describe('diffRelayQuery', () => { __dataID__: 'story', id: 'story', feedback: { - __dataID__: 'story:feedback', - }, + __dataID__: 'story:feedback' + } }, 'story:feedback': { __dataID__: 'story:feedback', topLevelComments: { - __dataID__: 'story:feedback:comments', - }, + __dataID__: 'story:feedback:comments' + } }, 'story:feedback:comments': { __dataID__: 'story:feedback:comments', - count: 5, - }, + count: 5 + } }; var store = new RelayRecordStore({records}); var tracker = new RelayQueryTracker(); @@ -327,19 +327,19 @@ describe('diffRelayQuery', () => { __dataID__: 'story', id: 'story', feedback: { - __dataID__: 'story:feedback', - }, + __dataID__: 'story:feedback' + } }, 'story:feedback': { __dataID__: 'story:feedback', topLevelComments: { - __dataID__: 'story:feedback:comments', - }, + __dataID__: 'story:feedback:comments' + } }, 'story:feedback:comments': { __dataID__: 'story:feedback:comments', - count: 5, - }, + count: 5 + } }; var store = new RelayRecordStore({records}); @@ -380,19 +380,19 @@ describe('diffRelayQuery', () => { __dataID__: 'story', id: 'story', feedback: { - __dataID__: 'story:feedback', - }, + __dataID__: 'story:feedback' + } }, 'story:feedback': { __dataID__: 'story:feedback', topLevelComments: { - __dataID__: 'story:feedback:comments', - }, + __dataID__: 'story:feedback:comments' + } }, 'story:feedback:comments': { __dataID__: 'story:feedback:comments', - count: 5, - }, + count: 5 + } }; var store = new RelayRecordStore({records}); @@ -423,26 +423,26 @@ describe('diffRelayQuery', () => { var mockRange = new GraphQLRange(); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ diffCalls: [], - requestedEdges: [], + requestedEdges: [] }); var records = { story: { __dataID__: 'story', id: 'story', feedback: { - __dataID__: 'story:feedback', - }, + __dataID__: 'story:feedback' + } }, 'story:feedback': { __dataID__: 'story:feedback', topLevelComments: { - __dataID__: 'story:feedback:comments', - }, + __dataID__: 'story:feedback:comments' + } }, 'story:feedback:comments': { __dataID__: 'story:feedback:comments', - __range__: mockRange, - }, + __range__: mockRange + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -553,13 +553,13 @@ describe('diffRelayQuery', () => { 'client:viewer': { __dataID__: 'client:viewer', actor: { - __dataID__: 'actor', - }, + __dataID__: 'actor' + } }, 'actor': { - __dataID__: 'actor', + __dataID__: 'actor' // `id` should always be fetched, but should work correctly regardless - }, + } }; store = new RelayRecordStore({records}, {rootCallMap}); tracker = new RelayQueryTracker(); @@ -580,8 +580,8 @@ describe('diffRelayQuery', () => { var records = { '4': { __dataID__: '4', - id: '4', - }, + id: '4' + } }; var store = new RelayRecordStore({records}); var tracker = new RelayQueryTracker(); @@ -603,13 +603,13 @@ describe('diffRelayQuery', () => { 'client:viewer': { __dataID__: 'client:viewer', actor: { - __dataID__: 'actor', - }, + __dataID__: 'actor' + } }, 'client:actor': { __dataID__: 'actor', - id: 'actor', - }, + id: 'actor' + } }; store = new RelayRecordStore({records}, {rootCallMap}); tracker = new RelayQueryTracker(); @@ -634,8 +634,8 @@ describe('diffRelayQuery', () => { var records = { '4': { __dataID__: '4', - id: '4', - }, + id: '4' + } }; store = new RelayRecordStore({records}); tracker = new RelayQueryTracker(); @@ -658,8 +658,8 @@ describe('diffRelayQuery', () => { var records = { '4': { __dataID__: '4', - friends: null, - }, + friends: null + } }; var store = new RelayRecordStore({records}); var tracker = new RelayQueryTracker(); @@ -695,12 +695,12 @@ describe('diffRelayQuery', () => { var records = { 'client:viewer': { __dataID__: 'client:viewer', - actor: {__dataID__: '4808495'}, + actor: {__dataID__: '4808495'} }, '4808495': { __dataID__: '4808495', - id: '4808495', - }, + id: '4808495' + } }; var store = new RelayRecordStore({records}, {rootCallMap}); var query = getNode(Relay.QL` @@ -728,14 +728,14 @@ describe('diffRelayQuery', () => { 'client:viewer': { __dataID__: 'client:viewer', actor: { - __dataID__: '123', - }, + __dataID__: '123' + } }, '123': { __dataID__: '123', id: '123', - name: 'Name', - }, + name: 'Name' + } }; var store = new RelayRecordStore({records}, {rootCallMap}); var query = getNode(Relay.QL` @@ -796,8 +796,8 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - name: 'Mark Zuckerberg', - }, + name: 'Mark Zuckerberg' + } }; var store = new RelayRecordStore({records}); var frag = Relay.QL`fragment on Node {name}`; @@ -837,8 +837,8 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - firstName: 'Mark', - }, + firstName: 'Mark' + } }; var store = new RelayRecordStore({records}); @@ -860,8 +860,8 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - firstName: 'Mark', - }, + firstName: 'Mark' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -894,8 +894,8 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - firstName: 'Mark', - }, + firstName: 'Mark' + } }; var store = new RelayRecordStore({records}); @@ -929,14 +929,14 @@ describe('diffRelayQuery', () => { __dataID__: '4', id: '4', hometown: { - __dataID__: '1234', - }, + __dataID__: '1234' + } }, '1234': { __dataID__: '1234', id: '1234', - name: 'Palo Alto, California', - }, + name: 'Palo Alto, California' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -977,26 +977,26 @@ describe('diffRelayQuery', () => { actors: [ {__dataID__: '4'}, {__dataID__: '4808495'}, - {__dataID__: '1023896548'}, - ], + {__dataID__: '1023896548'} + ] }, '4': { __dataID__: '4', id: '4', name: 'Mark Zuckerberg', firstName: 'Mark', - lastName: 'Zuckerberg', + lastName: 'Zuckerberg' }, '4808495': { __dataID__: '4808495', id: '4808495', - firstName: 'Marshall', + firstName: 'Marshall' }, '1023896548': { __dataID__: '1023896548', id: '1023896548', - name: 'Laney Kuenzel', - }, + name: 'Laney Kuenzel' + } }; var store = new RelayRecordStore({records}); @@ -1064,17 +1064,17 @@ describe('diffRelayQuery', () => { id: '12345', screennames: [ {__dataID__: 'client:1'}, - {__dataID__: 'client:2'}, - ], + {__dataID__: 'client:2'} + ] }, 'client:1': { __dataID__: 'client:1', - service: 'GTALK', + service: 'GTALK' }, 'client:2': { __dataID__: 'client:2', - service: 'TWITTER', - }, + service: 'TWITTER' + } }; var store = new RelayRecordStore({records}); var expected = getNode(Relay.QL` @@ -1114,8 +1114,8 @@ describe('diffRelayQuery', () => { __dataID__: '4', id: '4', name: 'Mark Zuckerberg', - lastName: 'Zuckerberg', - }, + lastName: 'Zuckerberg' + } }; var store = new RelayRecordStore({records}); var firstNameFrag = Relay.QL` @@ -1203,8 +1203,8 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - name: 'Mark Zuckerberg', - }, + name: 'Mark Zuckerberg' + } }; var store = new RelayRecordStore({records}); @@ -1258,29 +1258,29 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - friends: {__dataID__: 'client:1'}, + friends: {__dataID__: 'client:1'} }, 'client:1': { __dataID__: 'client:1', - __range__: mockRange, + __range__: mockRange }, 'client:4:4808495': { __dataID__: 'client:4:4808495', node: {__dataID__: '4808495'}, - cursor: 'cursor1', + cursor: 'cursor1' }, '4808495': { __dataID__: '4808495', - id: '4808495', - }, + id: '4808495' + } }; var store = new RelayRecordStore({records}); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['client:4:4808495'], diffCalls: [ {name: 'after', value: 'cursor1'}, - {name: 'first', value: '4'}, - ], + {name: 'first', value: '4'} + ] }); var expected = getNode(Relay.QL` @@ -1331,31 +1331,31 @@ describe('diffRelayQuery', () => { var mockEdge = { __dataID__: 'client:4:4808495', node: {__dataID__: '4808495'}, - cursor: 'cursor1', + cursor: 'cursor1' }; var records = { '4': { __dataID__: '4', id: '4', - friends: {__dataID__: 'client:1'}, + friends: {__dataID__: 'client:1'} }, 'client:1': { __dataID__: 'client:1', - __range__: mockRange, + __range__: mockRange }, 'client:4:4808495': mockEdge, '4808495': { __dataID__: '4808495', - id: '4808495', - }, + id: '4808495' + } }; var store = new RelayRecordStore({records}); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['client:4:4808495'], diffCalls: [ {name: 'after', value: 'cursor1'}, - {name: 'first', value: '4'}, - ], + {name: 'first', value: '4'} + ] }); var expected1 = getNode(Relay.QL` @@ -1439,39 +1439,39 @@ describe('diffRelayQuery', () => { { __dataID__: 'client:4:4808495', node: {__dataID__: '4808495'}, - cursor: 'cursor1', + cursor: 'cursor1' }, { __dataID__: 'client:4:660361306', node: {__dataID__: '660361306'}, - cursor: 'cursor1', - }, + cursor: 'cursor1' + } ]; var records = { '4': { __dataID__: '4', id: '4', - friends: {__dataID__: 'client:1'}, + friends: {__dataID__: 'client:1'} }, 'client:1': { __dataID__: 'client:1', - __range__: mockRange, + __range__: mockRange }, 'client:4:4808495': mockEdges[0], '4808495': null, 'client:4:660361306': mockEdges[1], '660361306': { __dataID__: '660361306', - id: '660361306', - }, + id: '660361306' + } }; var store = new RelayRecordStore({records}); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['client:4:4808495', 'client:4:660361306'], diffCalls: [ {name: 'after', value: 'cursor1'}, - {name: 'first', value: '4'}, - ], + {name: 'first', value: '4'} + ] }); var expected1 = getNode(Relay.QL` @@ -1554,35 +1554,35 @@ describe('diffRelayQuery', () => { var mockEdge = { __dataID__: 'client:viewer:4808495', node: {__dataID__: '4808495'}, - cursor: 'cursor1', + cursor: 'cursor1' }; var mockRange = new GraphQLRange(); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['client:viewer:4808495'], - diffCalls: null, + diffCalls: null }); var records = { 'client:viewer': { __dataID__: 'client:viewer', - actor: {__dataID__: '4'}, + actor: {__dataID__: '4'} }, '4': { __dataID__: '4', id: '4', - friends: {__dataID__: 'client:1'}, + friends: {__dataID__: 'client:1'} }, 'client:1': { __dataID__: 'client:1', - __range__: mockRange, + __range__: mockRange }, 'client:viewer:4808495': mockEdge, '4808495': { __dataID__: '4808495', id: '4808495', - firstName: 'Marshall', - }, + firstName: 'Marshall' + } }; var store = new RelayRecordStore({records}, {rootCallMap}); @@ -1642,27 +1642,27 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - friends: {__dataID__: 'client:1'}, + friends: {__dataID__: 'client:1'} }, 'client:1': { __dataID__: 'client:1', - __range__: mockRange, + __range__: mockRange }, 'client:4:4808495': { __dataID__: 'client:4:4808495', node: {__dataID__: '4808495'}, - cursor: 'cursor1', + cursor: 'cursor1' }, '4808495': { __dataID__: '4808495', id: '4808495', - firstName: 'Marshall', - }, + firstName: 'Marshall' + } }; var store = new RelayRecordStore({records}); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['client:4:4808495'], - diffCalls: null, + diffCalls: null }); var expected = getNode(Relay.QL` @@ -1720,29 +1720,29 @@ describe('diffRelayQuery', () => { __dataID__: 'client:4:4808495', node: {__dataID__: '4808495'}, source: {__dataID__: '4'}, - cursor: 'cursor1', + cursor: 'cursor1' }; var records = { '4': { __dataID__: '4', id: '4', name: 'Mark Zuckerberg', - friends: {__dataID__: 'client:1'}, + friends: {__dataID__: 'client:1'} }, 'client:1': { __dataID__: 'client:1', - __range__: mockRange, + __range__: mockRange }, 'client:4:4808495': mockEdge, '4808495': { __dataID__: '4808495', - id: '4808495', - }, + id: '4808495' + } }; var store = new RelayRecordStore({records}); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['client:4:4808495'], - diffCalls: null, + diffCalls: null }); var query = getNode(Relay.QL` @@ -1797,29 +1797,29 @@ describe('diffRelayQuery', () => { __dataID__: 'client:4:4808495', node: {__dataID__: '4808495'}, source: {__dataID__: '4'}, - cursor: 'cursor1', + cursor: 'cursor1' }; var records = { '4': { __dataID__: '4', id: '4', - friends: {__dataID__: 'client:1'}, + friends: {__dataID__: 'client:1'} }, 'client:1': { __dataID__: 'client:1', - __range__: mockRange, + __range__: mockRange }, 'client:4:4808495': mockEdge, '4808495': { __dataID__: '4808495', id: '4808495', - name: 'Marshall Roch', - }, + name: 'Marshall Roch' + } }; var store = new RelayRecordStore({records}); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['client:4:4808495'], - diffCalls: null, + diffCalls: null }); var expected = getNode(Relay.QL` diff --git a/src/traversal/__tests__/diffRelayQuery_connection-test.js b/src/traversal/__tests__/diffRelayQuery_connection-test.js index b985873bb4b17..ae126c3fd01e0 100644 --- a/src/traversal/__tests__/diffRelayQuery_connection-test.js +++ b/src/traversal/__tests__/diffRelayQuery_connection-test.js @@ -48,7 +48,7 @@ describe('diffRelayQuery', () => { ({HAS_NEXT_PAGE, HAS_PREV_PAGE, PAGE_INFO} = RelayConnectionInterface); rootCallMap = { - 'viewer': {'': 'client:viewer'}, + 'viewer': {'': 'client:viewer'} }; jest.addMatchers(RelayTestUtils.matchers); @@ -89,14 +89,14 @@ describe('diffRelayQuery', () => { edges: [ {cursor: 'c1', node: {id: 's1'}}, {cursor: 'c2', node: {id: 's2'}}, - {cursor: 'c3', node: {id: 's3'}}, + {cursor: 'c3', node: {id: 's3'}} ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, - }, - }, + [HAS_PREV_PAGE]: false + } + } + } }; var query = getNode(Relay.QL` query { @@ -132,14 +132,14 @@ describe('diffRelayQuery', () => { edges: [ {cursor: 'c1', node: {id: 's1'}}, {cursor: 'c2', node: {id: 's2'}}, - {cursor: 'c3', node: {id: 's3'}}, + {cursor: 'c3', node: {id: 's3'}} ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, - }, - }, + [HAS_PREV_PAGE]: false + } + } + } }; var query = getNode(Relay.QL` query { @@ -187,14 +187,14 @@ describe('diffRelayQuery', () => { edges: [ {cursor: 'c1', node: {id:'', message:{text:'s1'}}}, {cursor: 'c2', node: {id:'', message:{text:'s1'}}}, - {cursor: 'c3', node: {id:'', message:{text:'s1'}}}, + {cursor: 'c3', node: {id:'', message:{text:'s1'}}} ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, - }, - }, + [HAS_PREV_PAGE]: false + } + } + } }; var writeQuery = getNode(Relay.QL` query { @@ -236,7 +236,7 @@ describe('diffRelayQuery', () => { 'RelayDiffQueryBuilder: connection `node{*}` can only be refetched ' + 'if the node is refetchable by `id`. Cannot refetch data for field ' + '`%s`.', - 'newsFeed', + 'newsFeed' ]).toBeWarnedNTimes(3); }); @@ -252,14 +252,14 @@ describe('diffRelayQuery', () => { edges: [ {cursor: 'c1', node: {id:'s1', message:{text:'s1'}}}, {cursor: 'c2', node: {id:'s2', message:{text:'s1'}}}, - {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}}, + {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}} ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, - }, - }, + [HAS_PREV_PAGE]: false + } + } + } }; var writeQuery = getNode(Relay.QL` query { @@ -338,14 +338,14 @@ describe('diffRelayQuery', () => { edges: [ {cursor: 'c1', node: {id:'s1', message:{text:'s1'}}}, {cursor: 'c2', node: {id:'s2', message:{text:'s1'}}}, - {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}}, + {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}} ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, - }, - }, + [HAS_PREV_PAGE]: false + } + } + } }; var writeQuery = getNode(Relay.QL` query { @@ -472,14 +472,14 @@ describe('diffRelayQuery', () => { edges: [ {cursor: 'c1', node: {id:'s1', message:{text:'s1'}}}, {cursor: 'c2', node: {id:'s2', message:{text:'s1'}}}, - {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}}, + {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}} ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, - }, - }, + [HAS_PREV_PAGE]: false + } + } + } }; var writeQuery = getNode(Relay.QL` query { @@ -550,7 +550,7 @@ describe('diffRelayQuery', () => { 'RelayDiffQueryBuilder: connection `edges{*}` fields can only be ' + 'refetched if the connection supports the `find` call. Cannot ' + 'refetch data for field `%s`.', - 'notificationStories', + 'notificationStories' ]).toBeWarnedNTimes(3); } ); @@ -565,14 +565,14 @@ describe('diffRelayQuery', () => { viewer: { [alias]: { edges: [ - {cursor: 'c1', node: {id:'s1', message:{text:'s1'}}}, + {cursor: 'c1', node: {id:'s1', message:{text:'s1'}}} ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, - }, - }, + [HAS_PREV_PAGE]: false + } + } + } }; var writeQuery = getNode(Relay.QL` query { diff --git a/src/traversal/__tests__/diffRelayQuery_scalar-test.js b/src/traversal/__tests__/diffRelayQuery_scalar-test.js index 2d305470875bd..9e03872ba6c19 100644 --- a/src/traversal/__tests__/diffRelayQuery_scalar-test.js +++ b/src/traversal/__tests__/diffRelayQuery_scalar-test.js @@ -92,8 +92,8 @@ describe('diffRelayQuery', () => { var payload = { '123': { id: '123', - firstName: 'Joe', - }, + firstName: 'Joe' + } }; writePayload(store, writeQuery, payload, tracker); diff --git a/src/traversal/__tests__/flattenSplitRelayQueries-test.js b/src/traversal/__tests__/flattenSplitRelayQueries-test.js index b9f91158e5c1d..f671c868f50ab 100644 --- a/src/traversal/__tests__/flattenSplitRelayQueries-test.js +++ b/src/traversal/__tests__/flattenSplitRelayQueries-test.js @@ -26,7 +26,7 @@ describe('flattenSplitRelayQueries', () => { it('returns an empty array when there are no queries', () => { var split = { required: null, - deferred: [], + deferred: [] }; expect(flattenSplitRelayQueries(split)).toEqual([]); }); @@ -34,7 +34,7 @@ describe('flattenSplitRelayQueries', () => { it('returns a single required query', () => { var split = { required: getQuery(), - deferred: [], + deferred: [] }; expect(flattenSplitRelayQueries(split)).toEqual([split.required]); }); @@ -44,8 +44,8 @@ describe('flattenSplitRelayQueries', () => { required: null, deferred: [{ required: getQuery(), - deferred: [], - }], + deferred: [] + }] }; expect(flattenSplitRelayQueries(split)) .toEqual([split.deferred[0].required]); @@ -57,19 +57,19 @@ describe('flattenSplitRelayQueries', () => { deferred: [ { required: getQuery(), - deferred: [], + deferred: [] }, { required: getQuery(), - deferred: [], - }, - ], + deferred: [] + } + ] }; expect(flattenSplitRelayQueries(split)) .toEqual([ split.required, split.deferred[0].required, - split.deferred[1].required, + split.deferred[1].required ]); }); @@ -81,16 +81,16 @@ describe('flattenSplitRelayQueries', () => { required: getQuery(), deferred: [{ required: getQuery(), - deferred: [], - }], - }, - ], + deferred: [] + }] + } + ] }; expect(flattenSplitRelayQueries(split)) .toEqual([ split.required, split.deferred[0].required, - split.deferred[0].deferred[0].required, + split.deferred[0].deferred[0].required ]); }); }); diff --git a/src/traversal/__tests__/inferRelayFieldsFromData-test.js b/src/traversal/__tests__/inferRelayFieldsFromData-test.js index 1ea5cf972d3dd..f94ec3cdb582e 100644 --- a/src/traversal/__tests__/inferRelayFieldsFromData-test.js +++ b/src/traversal/__tests__/inferRelayFieldsFromData-test.js @@ -38,7 +38,7 @@ describe('inferRelayFieldsFromData', function() { HAS_NEXT_PAGE, HAS_PREV_PAGE, PAGE_INFO, - START_CURSOR, + START_CURSOR } = RelayConnectionInterface); jest.addMatchers({ @@ -48,14 +48,14 @@ describe('inferRelayFieldsFromData', function() { this.actual = flattenRelayQuery(expected.clone(this.actual)); // NOTE: Generated fields might get in the way. return matchers.toEqualQueryNode.call(this, expected); - }, + } }); }); it('infers scalar fields from scalars', () => { expect(inferRelayFieldsFromData({ id: '123', - name: 'Alice', + name: 'Alice' })).toEqualFields(Relay.QL` fragment on Actor { id, name, @@ -66,8 +66,8 @@ describe('inferRelayFieldsFromData', function() { expect(inferRelayFieldsFromData({ id: '123', address: { - city: 'Menlo Park', - }, + city: 'Menlo Park' + } })).toEqualFields(Relay.QL` fragment on Actor { id, address { @@ -79,7 +79,7 @@ describe('inferRelayFieldsFromData', function() { it('infers unterminated fields from null', () => { expect(inferRelayFieldsFromData({ id: '123', - address: null, + address: null })).toEqualFields(Relay.QL` fragment on Actor { id, address, @@ -91,8 +91,8 @@ describe('inferRelayFieldsFromData', function() { id: '123', websites: [ 'facebook.com', - 'google.com', - ], + 'google.com' + ] }); expect(fields).toEqualFields(Relay.QL` fragment on Actor { id, @@ -106,8 +106,8 @@ describe('inferRelayFieldsFromData', function() { id: '123', screennames: [ {service: 'GTALK'}, - {service: 'TWITTER'}, - ], + {service: 'TWITTER'} + ] })).toEqualFields(Relay.QL` fragment on Actor { id, screennames { @@ -119,7 +119,7 @@ describe('inferRelayFieldsFromData', function() { it('infers unterminated fields from empty arrays', () => { expect(inferRelayFieldsFromData({ id: '123', - websites: [], + websites: [] })).toEqualFields(Relay.QL` fragment on Actor { id, websites, @@ -129,7 +129,7 @@ describe('inferRelayFieldsFromData', function() { it('infers unterminated fields from null elements in arrays', () => { expect(inferRelayFieldsFromData({ id: '123', - websites: [null], + websites: [null] })).toEqualFields(Relay.QL` fragment on Actor { id, websites, @@ -139,7 +139,7 @@ describe('inferRelayFieldsFromData', function() { it('infers field arguments from keys', () => { expect(inferRelayFieldsFromData({ id: '123', - 'url.site(www)': 'https://...', + 'url.site(www)': 'https://...' })).toEqualFields(Relay.QL` fragment on Actor { id, url(site:"www"), @@ -149,7 +149,7 @@ describe('inferRelayFieldsFromData', function() { it('throws for keys with invalid call encodings', () => { expect(() => { inferRelayFieldsFromData({ - 'url.site': 'https://...', + 'url.site': 'https://...' }); }).toFailInvariant( 'inferRelayFieldsFromData(): Malformed data key, `url.site`.' @@ -162,13 +162,13 @@ describe('inferRelayFieldsFromData', function() { 'friends.first(2)': { edges: [ {node: {name: 'Alice'}}, - {node: {name: 'Bob'}}, + {node: {name: 'Bob'}} ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, - }, + [HAS_PREV_PAGE]: false + } + } })).toEqualFields(Relay.QL` fragment on Actor { id, friends(first:"2") { @@ -187,8 +187,8 @@ describe('inferRelayFieldsFromData', function() { expect(inferRelayFieldsFromData({ node: { id: '123', - name: 'name', - }, + name: 'name' + } })).toEqualFields(Relay.QL` fragment on NodeSavedStateResponsePayload { node { id, @@ -203,7 +203,7 @@ describe('inferRelayFieldsFromData', function() { __range__: null, __status__: null, id: '123', - name: 'Alice', + name: 'Alice' })).toEqualFields(Relay.QL` fragment on Node { id, name, diff --git a/src/traversal/__tests__/printRelayQueryCall-test.js b/src/traversal/__tests__/printRelayQueryCall-test.js index f6ad1ce661be6..a5dce780c2d55 100644 --- a/src/traversal/__tests__/printRelayQueryCall-test.js +++ b/src/traversal/__tests__/printRelayQueryCall-test.js @@ -17,7 +17,7 @@ describe('printRelayQueryCall', () => { it('prints a call with a null argument', () => { var call = { name: 'me', - value: null, + value: null }; expect(printRelayQueryCall(call)).toEqual('.me()'); }); @@ -25,7 +25,7 @@ describe('printRelayQueryCall', () => { it('prints a call with an undefined argument', () => { var call = { name: 'me', - value: undefined, + value: undefined }; expect(printRelayQueryCall(call)).toEqual('.me()'); }); @@ -33,7 +33,7 @@ describe('printRelayQueryCall', () => { it('prints a call with a string argument', () => { var call = { name: 'first', - value: '5', + value: '5' }; expect(printRelayQueryCall(call)).toEqual('.first(5)'); }); @@ -41,7 +41,7 @@ describe('printRelayQueryCall', () => { it('prints a call with a numeric argument', () => { var call = { name: 'first', - value: 5, + value: 5 }; expect(printRelayQueryCall(call)).toEqual('.first(5)'); }); @@ -49,7 +49,7 @@ describe('printRelayQueryCall', () => { it('prints a call with `true` argument', () => { var call = { name: 'if', - value: true, + value: true }; expect(printRelayQueryCall(call)).toEqual('.if(true)'); }); @@ -57,7 +57,7 @@ describe('printRelayQueryCall', () => { it('prints a call with `false` argument', () => { var call = { name: 'unless', - value: false, + value: false }; expect(printRelayQueryCall(call)).toEqual('.unless(false)'); }); @@ -65,7 +65,7 @@ describe('printRelayQueryCall', () => { it('prints a call with many arguments', () => { var call = { name: 'usernames', - value: ['glh', 'joesavona'], + value: ['glh', 'joesavona'] }; expect(printRelayQueryCall(call)).toEqual('.usernames(glh,joesavona)'); }); @@ -73,7 +73,7 @@ describe('printRelayQueryCall', () => { it('sanitizes argument values', () => { var call = { name: 'checkin_search_query', - value: JSON.stringify({query: 'Menlo Park'}), + value: JSON.stringify({query: 'Menlo Park'}) }; expect(printRelayQueryCall(call)).toEqual( '.checkin_search_query(\\{"query":"Menlo Park"\\})' @@ -88,12 +88,12 @@ describe('printRelayQueryCall', () => { ' x': '\\ x', 'x ': 'x\\ \\ ', ' x ': '\\ x\\ \\ ', - 'x y': 'x y', + 'x y': 'x y' }; Object.keys(values).forEach(value => { var call = { name: 'node', - value, + value }; var expected = values[value]; expect(printRelayQueryCall(call)).toEqual('.node(' + expected + ')'); diff --git a/src/traversal/__tests__/refragmentRelayQuery-test.js b/src/traversal/__tests__/refragmentRelayQuery-test.js index 7cf26ce3fb618..f86c7f5f4b643 100644 --- a/src/traversal/__tests__/refragmentRelayQuery-test.js +++ b/src/traversal/__tests__/refragmentRelayQuery-test.js @@ -33,7 +33,7 @@ describe('refragmentRelayQuery', () => { /* jslint validthis:true */ this.actual = refragmentRelayQuery(flattenRelayQuery(this.actual)); return matchers.toEqualQueryNode.call(this, expected); - }, + } }); }); diff --git a/src/traversal/__tests__/splitDeferredRelayQueries-test.js b/src/traversal/__tests__/splitDeferredRelayQueries-test.js index 107f1076e9ddc..55d6881b82015 100644 --- a/src/traversal/__tests__/splitDeferredRelayQueries-test.js +++ b/src/traversal/__tests__/splitDeferredRelayQueries-test.js @@ -969,9 +969,9 @@ describe('splitDeferredRelayQueries()', () => { { generated: true, pk: 'id', - rootCall: 'node', + rootCall: 'node' } - ), + ) ] ); queryNode = queryNode.clone( diff --git a/src/traversal/__tests__/subtractRelayQuery-test.js b/src/traversal/__tests__/subtractRelayQuery-test.js index a382646730405..f5a7ab8243fe9 100644 --- a/src/traversal/__tests__/subtractRelayQuery-test.js +++ b/src/traversal/__tests__/subtractRelayQuery-test.js @@ -504,8 +504,8 @@ describe('subtractRelayQuery', () => { `); minQuery = minQuery.clone([ minQuery.getChildren()[0].clone([ - minQuery.getChildren()[0].getChildren()[0].cloneAsRefQueryDependency(), - ]), + minQuery.getChildren()[0].getChildren()[0].cloneAsRefQueryDependency() + ]) ]); var subQuery = getNode(Relay.QL` query { diff --git a/src/traversal/__tests__/writeRelayQueryPayload_connectionField-test.js b/src/traversal/__tests__/writeRelayQueryPayload_connectionField-test.js index a9626c0e4363c..b7c0ceb09bcbc 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_connectionField-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_connectionField-test.js @@ -42,7 +42,7 @@ describe('writeRelayQueryPayload()', () => { HAS_NEXT_PAGE, HAS_PREV_PAGE, PAGE_INFO, - START_CURSOR, + START_CURSOR } = RelayConnectionInterface); jest.addMatchers(RelayTestUtils.matchers); @@ -81,22 +81,22 @@ describe('writeRelayQueryPayload()', () => { edges: [], [PAGE_INFO]: { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false, - }, - }, - }, + [HAS_PREV_PAGE]: false + } + } + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { '123': true, - 'client:1': true, // `friends` connection + 'client:1': true // `friends` connection }, - updated: {}, + updated: {} }); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 3}, + {name: 'first', value: 3} ])).toEqual({ diffCalls: [], filterCalls: [], @@ -104,9 +104,9 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: undefined, [HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false, - [START_CURSOR]: undefined, + [START_CURSOR]: undefined }, - requestedEdges: [], + requestedEdges: [] }); }); @@ -136,8 +136,8 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123', - }, + id: '123' + } }; var alias = generateRQLFieldAlias('friends.first(3)'); payload['123'][alias] = { @@ -145,35 +145,35 @@ describe('writeRelayQueryPayload()', () => { { cursor: 'friend1', node: { - id: 'friend1ID', + id: 'friend1ID' }, source: { - id: '123', - }, + id: '123' + } }, { cursor: 'friend2', node: { - id: 'friend2ID', + id: 'friend2ID' }, source: { - id: '123', - }, + id: '123' + } }, { cursor: 'friend3', node: { - id: 'friend3ID', + id: 'friend3ID' }, source: { - id: '123', - }, - }, + id: '123' + } + } ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, + [HAS_PREV_PAGE]: false + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ @@ -185,15 +185,15 @@ describe('writeRelayQueryPayload()', () => { 'client:client:1:friend3ID': true, 'friend1ID': true, // nodes 'friend2ID': true, - 'friend3ID': true, + 'friend3ID': true }, - updated: {}, + updated: {} }); expect(store.getField('friend1ID', 'id')).toBe('friend1ID'); expect(store.getField('friend2ID', 'id')).toBe('friend2ID'); expect(store.getField('friend3ID', 'id')).toBe('friend3ID'); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 3}, + {name: 'first', value: 3} ])).toEqual({ diffCalls: [], filterCalls: [], @@ -201,13 +201,13 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'friend3', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'friend1', + [START_CURSOR]: 'friend1' }, requestedEdges: [ {edgeID: 'client:client:1:friend1ID', nodeID: 'friend1ID'}, {edgeID: 'client:client:1:friend2ID', nodeID: 'friend2ID'}, - {edgeID: 'client:client:1:friend3ID', nodeID: 'friend3ID'}, - ], + {edgeID: 'client:client:1:friend3ID', nodeID: 'friend3ID'} + ] }); }); @@ -234,8 +234,8 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123', - }, + id: '123' + } }; var alias = generateRQLFieldAlias('friends.first(3)'); payload['123'][alias] = { @@ -243,19 +243,19 @@ describe('writeRelayQueryPayload()', () => { null, { cursor: 'friend2', - node: null, + node: null }, { cursor: 'friend3', node: { - id: 'friend3ID', - }, - }, + id: 'friend3ID' + } + } ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, + [HAS_PREV_PAGE]: false + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ @@ -263,13 +263,13 @@ describe('writeRelayQueryPayload()', () => { '123': true, 'client:1': true, // `friends` connection 'client:client:1:friend3ID': true, // edges - 'friend3ID': true, + 'friend3ID': true }, - updated: {}, + updated: {} }); expect(store.getField('friend3ID', 'id')).toBe('friend3ID'); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 1}, + {name: 'first', value: 1} ])).toEqual({ diffCalls: [], filterCalls: [], @@ -277,11 +277,11 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'friend3', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'friend3', + [START_CURSOR]: 'friend3' }, requestedEdges: [ - {edgeID: 'client:client:1:friend3ID', nodeID: 'friend3ID'}, - ], + {edgeID: 'client:client:1:friend3ID', nodeID: 'friend3ID'} + ] }); }); @@ -298,8 +298,8 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - friends: {count: 5}, - }, + friends: {count: 5} + } }; writePayload(store, query, payload); @@ -326,8 +326,8 @@ describe('writeRelayQueryPayload()', () => { `); payload = { '123': { - id: '123', - }, + id: '123' + } }; var alias = generateRQLFieldAlias('friends.first(1)'); payload['123'][alias] = { @@ -335,31 +335,31 @@ describe('writeRelayQueryPayload()', () => { { cursor: 'friend1', node: { - id: 'friend1ID', + id: 'friend1ID' }, source: { - id: '123', - }, - }, + id: '123' + } + } ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, + [HAS_PREV_PAGE]: false + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { 'client:client:1:friend1ID': true, // edges - 'friend1ID': true, // nodes + 'friend1ID': true // nodes }, updated: { - 'client:1': true, - }, + 'client:1': true + } }); expect(store.getField('friend1ID', 'id')).toBe('friend1ID'); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 1}, + {name: 'first', value: 1} ])).toEqual({ diffCalls: [], filterCalls: [], @@ -367,11 +367,11 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'friend1', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'friend1', + [START_CURSOR]: 'friend1' }, requestedEdges: [ - {edgeID: 'client:client:1:friend1ID', nodeID: 'friend1ID'}, - ], + {edgeID: 'client:client:1:friend1ID', nodeID: 'friend1ID'} + ] }); }); @@ -408,19 +408,19 @@ describe('writeRelayQueryPayload()', () => { { cursor: 'friend1', node: { - id: 'friend1ID', + id: 'friend1ID' }, source: { - id: '123', - }, - }, + id: '123' + } + } ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, - }, - }, + [HAS_PREV_PAGE]: false + } + } + } }; expect(() => writePayload(store, query, payload)).toFailInvariant( 'RelayQueryWriter: Cannot write edges for connection ' + @@ -448,21 +448,21 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123', - }, + id: '123' + } }; var alias = generateRQLFieldAlias('friends.first(1)'); payload['123'][alias] = { edges: [{ node: { - id: 'node1', + id: 'node1' }, - cursor: 'cursor1', + cursor: 'cursor1' }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, + [HAS_PREV_PAGE]: false + } }; var records = {}; store = new RelayRecordStore({records}); @@ -485,34 +485,34 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123', - }, + id: '123' + } }; var alias = generateRQLFieldAlias('friends.first(1).after(cursor1)'); payload['123'][alias] = { edges: [{ node: { - id: 'node2', + id: 'node2' }, - cursor: 'cursor2', + cursor: 'cursor2' }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: true, - }, + [HAS_PREV_PAGE]: true + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { 'node2': true, - 'client:client:1:node2': true, // 2nd edge + 'client:client:1:node2': true // 2nd edge }, updated: { - 'client:1': true, // range updated - }, + 'client:1': true // range updated + } }); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 2}, + {name: 'first', value: 2} ])).toEqual({ diffCalls: [], filterCalls: [], @@ -520,12 +520,12 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'cursor2', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'cursor1', + [START_CURSOR]: 'cursor1' }, requestedEdges: [ {edgeID: 'client:client:1:node1', nodeID: 'node1'}, - {edgeID: 'client:client:1:node2', nodeID: 'node2'}, - ], + {edgeID: 'client:client:1:node2', nodeID: 'node2'} + ] }); }); @@ -546,34 +546,34 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123', - }, + id: '123' + } }; var alias = generateRQLFieldAlias('friends.find(node1)'); payload['123'][alias] = { edges: [{ node: { id: 'node1', - name: 'Tim', // added field + name: 'Tim' // added field }, - cursor: 'cursor1', + cursor: 'cursor1' }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: true, - }, + [HAS_PREV_PAGE]: true + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - 'node1': true, // `name` added + 'node1': true // `name` added // range not updated, only the node changed - }, + } }); expect(store.getField('node1', 'name')).toBe('Tim'); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 1}, + {name: 'first', value: 1} ])).toEqual({ diffCalls: [], filterCalls: [], @@ -581,11 +581,11 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'cursor1', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'cursor1', + [START_CURSOR]: 'cursor1' }, requestedEdges: [ - {edgeID: 'client:client:1:node1', nodeID: 'node1'}, - ], + {edgeID: 'client:client:1:node1', nodeID: 'node1'} + ] }); }); @@ -611,37 +611,37 @@ describe('writeRelayQueryPayload()', () => { `, RelayMetaRoute.get('$RelayTest'), {}); var payload = { '123': { - id: '123', - }, + id: '123' + } }; var alias = generateRQLFieldAlias('friends.find(node1)'); payload['123'][alias] = { edges: [{ node: { - id: 'node1', + id: 'node1' }, source: { // new edge field - id: '456', + id: '456' }, - cursor: 'cursor1', + cursor: 'cursor1' }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: true, - }, + [HAS_PREV_PAGE]: true + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - '456': true, // `source` added + '456': true // `source` added }, updated: { 'client:1': true, // range updated because an edge had a change - 'client:client:1:node1': true, // `source` added to edge - }, + 'client:client:1:node1': true // `source` added to edge + } }); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 1}, + {name: 'first', value: 1} ])).toEqual({ diffCalls: [], filterCalls: [], @@ -649,11 +649,11 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'cursor1', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'cursor1', + [START_CURSOR]: 'cursor1' }, requestedEdges: [ - {edgeID: 'client:client:1:node1', nodeID: 'node1'}, - ], + {edgeID: 'client:client:1:node1', nodeID: 'node1'} + ] }); var sourceID = store.getLinkedRecordID('client:client:1:node1', 'source'); expect(sourceID).toBe('456'); @@ -676,35 +676,35 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123', - }, + id: '123' + } }; var alias = generateRQLFieldAlias('friends.first(1)'); payload['123'][alias] = { edges: [{ node: { - id: 'node1b', + id: 'node1b' }, - cursor: 'cursor1b', + cursor: 'cursor1b' }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, + [HAS_PREV_PAGE]: false + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { 'node1b': true, - 'client:client:1:node1b': true, // edge added but never referenced + 'client:client:1:node1b': true // edge added but never referenced }, updated: { - 'client:1': true, // range updated - }, + 'client:1': true // range updated + } }); expect(store.getField('node1b', 'id')).toBe('node1b'); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 1}, + {name: 'first', value: 1} ])).toEqual({ diffCalls: [], filterCalls: [], @@ -712,11 +712,11 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'cursor1', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'cursor1', + [START_CURSOR]: 'cursor1' }, requestedEdges: [ - {edgeID: 'client:client:1:node1', nodeID: 'node1'}, - ], + {edgeID: 'client:client:1:node1', nodeID: 'node1'} + ] }); }); @@ -736,35 +736,35 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123', - }, + id: '123' + } }; var alias = generateRQLFieldAlias('friends.first(1)'); payload['123'][alias] = { edges: [{ node: { - id: 'node1b', + id: 'node1b' }, - cursor: 'cursor1b', + cursor: 'cursor1b' }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false, - }, + [HAS_PREV_PAGE]: false + } }; var results = writePayload(store, query, payload, null, {forceIndex: 1}); expect(results).toEqual({ created: { 'node1b': true, - 'client:client:1:node1b': true, + 'client:client:1:node1b': true }, updated: { - 'client:1': true, // range updated - }, + 'client:1': true // range updated + } }); expect(store.getField('node1b', 'id')).toBe('node1b'); expect(store.getRangeMetadata('client:1', [ - {name: 'first', value: 1}, + {name: 'first', value: 1} ])).toEqual({ diffCalls: [], filterCalls: [], @@ -772,11 +772,11 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'cursor1b', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'cursor1b', + [START_CURSOR]: 'cursor1b' }, requestedEdges: [ - {edgeID: 'client:client:1:node1b', nodeID: 'node1b'}, - ], + {edgeID: 'client:client:1:node1b', nodeID: 'node1b'} + ] }); }); }); diff --git a/src/traversal/__tests__/writeRelayQueryPayload_linkedField-test.js b/src/traversal/__tests__/writeRelayQueryPayload_linkedField-test.js index 403831de23790..08123f8cbe8da 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_linkedField-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_linkedField-test.js @@ -50,15 +50,15 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { viewer: { - actor: null, - }, + actor: null + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - 'client:viewer': true, + 'client:viewer': true }, - updated: {}, + updated: {} }); expect(store.getRecordStatus(VIEWER_ID)).toBe('EXISTENT'); expect(store.getLinkedRecordID(VIEWER_ID, 'actor')).toBe(null); @@ -69,12 +69,12 @@ describe('writeRelayQueryPayload()', () => { 'client:viewer': { __dataID__: VIEWER_ID, actor: { - __dataID__: 'client:1', - }, + __dataID__: 'client:1' + } }, 'client:1': { - __dataID__: 'client:1', - }, + __dataID__: 'client:1' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -88,16 +88,16 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { viewer: { - actor: null, - }, + actor: null + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { }, updated: { - 'client:viewer': true, - }, + 'client:viewer': true + } }); expect(store.getRecordStatus(VIEWER_ID)).toBe('EXISTENT'); expect(store.getLinkedRecordID(VIEWER_ID, 'actor')).toBe(null); @@ -117,8 +117,8 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { viewer: { - actor: undefined, - }, + actor: undefined + } }; writePayload(store, query, payload); expect(store.getRecordStatus(VIEWER_ID)).toBe('EXISTENT'); @@ -130,13 +130,13 @@ describe('writeRelayQueryPayload()', () => { 'client:viewer': { __dataID__: VIEWER_ID, actor: { - __dataID__: '123', - }, + __dataID__: '123' + } }, '123': { __dataID__: '123', - id: '123', - }, + id: '123' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -150,8 +150,8 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { viewer: { - actor: undefined, - }, + actor: undefined + } }; writePayload(store, query, payload); expect(store.getRecordStatus(VIEWER_ID)).toBe('EXISTENT'); @@ -176,17 +176,17 @@ describe('writeRelayQueryPayload()', () => { var payload = { viewer: { actor: { - id: actorID, - }, - }, + id: actorID + } + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { 'client:viewer': true, - '123': true, + '123': true }, - updated: {}, + updated: {} }); expect(store.getLinkedRecordID(VIEWER_ID, 'actor')).toBe(actorID); expect(store.getRecordStatus(actorID)).toBe('EXISTENT'); @@ -198,12 +198,12 @@ describe('writeRelayQueryPayload()', () => { 'client:viewer': { __dataID__: 'client:viewer', actor: { - __dataID__: actorID, - }, + __dataID__: actorID + } }, '123': { - __dataID__: actorID, - }, + __dataID__: actorID + } }; var store = new RelayRecordStore({records}); var nextActorID = '456'; @@ -219,18 +219,18 @@ describe('writeRelayQueryPayload()', () => { var payload = { viewer: { actor: { - id: nextActorID, - }, - }, + id: nextActorID + } + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - '456': true, + '456': true }, updated: { - 'client:viewer': true, - }, + 'client:viewer': true + } }); expect(store.getLinkedRecordID(VIEWER_ID, 'actor')).toBe(nextActorID); expect(store.getRecordStatus(nextActorID)).toBe('EXISTENT'); @@ -255,17 +255,17 @@ describe('writeRelayQueryPayload()', () => { id: '123', // address has no id and receives a generated client id address: { - city: 'San Francisco', - }, - }, + city: 'San Francisco' + } + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { '123': true, - 'client:1': true, + 'client:1': true }, - updated: {}, + updated: {} }); expect(store.getLinkedRecordID('123', 'address')).toBe(addressID); expect(store.getRecordStatus(addressID)).toBe('EXISTENT'); @@ -279,13 +279,13 @@ describe('writeRelayQueryPayload()', () => { __dataID__: '123', id: '123', address: { - __dataID__: addressID, - }, + __dataID__: addressID + } }, 'client:1': { __dataID__: addressID, - city: 'San Francisco', - }, + city: 'San Francisco' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -303,14 +303,14 @@ describe('writeRelayQueryPayload()', () => { // the address record has no id but should reuse the previously // generated client id address: { - city: 'San Francisco', - }, - }, + city: 'San Francisco' + } + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, - updated: {}, + updated: {} }); expect(store.getLinkedRecordID('123', 'address')).toBe(addressID); expect(store.getField(addressID, 'city')).toBe('San Francisco'); @@ -321,11 +321,11 @@ describe('writeRelayQueryPayload()', () => { 'user:1': { __dataID__: 'user:1', 'hometown': { - __dataID__: 'hometown:1', + __dataID__: 'hometown:1' }, - id: 'user:1', + id: 'user:1' }, - 'hometown:1': null, + 'hometown:1': null }; var store = new RelayRecordStore({records}); store.removeRecord('hometown:1'); @@ -343,18 +343,18 @@ describe('writeRelayQueryPayload()', () => { id: 'user:1', 'hometown': { id: 'hometown:1', - name: 'World', - }, - }, + name: 'World' + } + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - 'hometown:1': true, + 'hometown:1': true }, updated: { - 'user:1': true, - }, + 'user:1': true + } }); }); }); diff --git a/src/traversal/__tests__/writeRelayQueryPayload_paths-test.js b/src/traversal/__tests__/writeRelayQueryPayload_paths-test.js index 12b6a56781840..ad7d6faa849e6 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_paths-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_paths-test.js @@ -72,17 +72,17 @@ describe('writePayload()', () => { var payload = { 'viewer': { actor: { - id: '123', - }, - }, + id: '123' + } + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { 'client:viewer': true, - '123': true, + '123': true }, - updated: {}, + updated: {} }); // viewer has a client id and must be refetched by the original root call @@ -106,15 +106,15 @@ describe('writePayload()', () => { `); var payload = { '123': { - id: '123', - }, + id: '123' + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - '123': true, + '123': true }, - updated: {}, + updated: {} }); expect(store.getRecordStatus('123')).toBe('EXISTENT'); @@ -140,10 +140,10 @@ describe('writePayload()', () => { 'actor': { id: '123', address: { - city: 'San Francisco', - }, - }, - }, + city: 'San Francisco' + } + } + } }; writePayload(store, query, payload); @@ -170,8 +170,8 @@ describe('writePayload()', () => { isVerified: true, phoneNumber: { displayNumber: '1-800-555-1212', // directory assistance - countryCode: '1', - }, + countryCode: '1' + } }; var query = getNode(Relay.QL` query { @@ -189,8 +189,8 @@ describe('writePayload()', () => { var payload = { '123': { id: '123', - allPhones: [phone], - }, + allPhones: [phone] + } }; writePayload(store, query, payload); @@ -241,13 +241,13 @@ describe('writePayload()', () => { node: { id: 'node1', address: { - city: 'San Francisco', - }, - }, - }, - ], - }, - }, + city: 'San Francisco' + } + } + } + ] + } + } }; writePayload(store, query, payload); @@ -288,8 +288,8 @@ describe('writePayload()', () => { var payload = { '123': { id: '123', - name: 'Joe', - }, + name: 'Joe' + } }; writePayload(store, query, payload, tracker); var trackedQueries = tracker.trackNodeForID.mock.calls; @@ -317,9 +317,9 @@ describe('writePayload()', () => { '123': { id: '123', address: { - city: 'San Francisco', - }, - }, + city: 'San Francisco' + } + } }; var addressID = 'client:1'; var addressFragment = getNode(fragment).getChildren()[0]; @@ -335,8 +335,8 @@ describe('writePayload()', () => { it('tracks new linked records', () => { var records = { 'client:viewer': { - __dataID__: 'client:viewer', - }, + __dataID__: 'client:viewer' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -352,9 +352,9 @@ describe('writePayload()', () => { viewer: { actor: { id: '123', - name: 'Joe', - }, - }, + name: 'Joe' + } + } }; var tracker = new RelayQueryTracker(); writePayload(store, query, payload, tracker); @@ -368,8 +368,8 @@ describe('writePayload()', () => { var records = { '123': { __dataID__: '123', - id: '123', - }, + id: '123' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -389,14 +389,14 @@ describe('writePayload()', () => { isVerified: true, phoneNumber: { displayNumber: '1-800-555-1212', // directory assistance - countryCode: '1', - }, + countryCode: '1' + } }; var payload = { '123': { id: '123', - allPhones: [phone], - }, + allPhones: [phone] + } }; var tracker = new RelayQueryTracker(); writePayload(store, query, payload, tracker); @@ -417,8 +417,8 @@ describe('writePayload()', () => { var records = { '123': { __dataID__: '123', - id: '123', - }, + id: '123' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -444,12 +444,12 @@ describe('writePayload()', () => { cursor: 'c1', node: { id: '456', - name: 'Greg', - }, - }, - ], - }, - }, + name: 'Greg' + } + } + ] + } + } }; var tracker = new RelayQueryTracker(); writePayload(store, query, payload, tracker); @@ -477,8 +477,8 @@ describe('writePayload()', () => { var records = { '123': { __dataID__: '123', - id: '123', - }, + id: '123' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -504,12 +504,12 @@ describe('writePayload()', () => { cursor: 'c1', node: { id: '456', - name: 'Greg', - }, - }, - ], - }, - }, + name: 'Greg' + } + } + ] + } + } }; var tracker = new RelayQueryTracker(); writePayload(store, query, payload, tracker); @@ -540,12 +540,12 @@ describe('writePayload()', () => { cursor: 'c2', node: { id: '789', - name: 'Jing', - }, - }, - ], - }, - }, + name: 'Jing' + } + } + ] + } + } }; tracker = new RelayQueryTracker(); tracker.trackNodeForID.mockClear(); @@ -594,9 +594,9 @@ describe('writePayload()', () => { allPhones: [ { phoneNumber: { - displayNumber: '1-800-555-1212', // directory assistance - }, - }, + displayNumber: '1-800-555-1212' // directory assistance + } + } ], [alias]: { edges: [ @@ -604,12 +604,12 @@ describe('writePayload()', () => { cursor: 'c1', node: { id: '456', - name: 'Tim', - }, - }, - ], - }, - }, + name: 'Tim' + } + } + ] + } + } }; // populate the store and record the original tracked queries var tracker = new RelayQueryTracker(); @@ -627,7 +627,7 @@ describe('writePayload()', () => { tracker = new RelayQueryTracker(); tracker.trackNodeForID.mockClear(); writePayload(store, query, payload, tracker, { - updateTrackedQueries: true, + updateTrackedQueries: true }); var nextTracked = tracker.trackNodeForID.mock.calls; expect(nextTracked.length).toBe(prevTracked.length); diff --git a/src/traversal/__tests__/writeRelayQueryPayload_pluralLinkedField-test.js b/src/traversal/__tests__/writeRelayQueryPayload_pluralLinkedField-test.js index 51e4313b4c1b4..1b97007699726 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_pluralLinkedField-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_pluralLinkedField-test.js @@ -37,8 +37,8 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123', - }, + id: '123' + } }; var store = new RelayRecordStore({records}); @@ -56,15 +56,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - allPhones: [], - }, + allPhones: [] + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true, - }, + '123': true + } }); var phoneIDs = store.getLinkedRecordIDs('123', 'allPhones'); expect(phoneIDs).toEqual([]); @@ -74,16 +74,16 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123', - }, + id: '123' + } }; var store = new RelayRecordStore({records}); var phone = { isVerified: true, phoneNumber: { displayNumber: '1-800-555-1212', // directory assistance - countryCode: '1', - }, + countryCode: '1' + } }; var query = getNode(Relay.QL` query { @@ -101,18 +101,18 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - allPhones: [phone], - }, + allPhones: [phone] + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { 'client:1': true, - 'client:2': true, + 'client:2': true }, updated: { - '123': true, - }, + '123': true + } }); var phoneIDs = store.getLinkedRecordIDs('123', 'allPhones'); expect(phoneIDs).toEqual(['client:1']); @@ -133,36 +133,36 @@ describe('writeRelayQueryPayload()', () => { isVerified: true, phoneNumber: { displayNumber: '1-800-555-1212', - countryCode: '1', - }, + countryCode: '1' + } }; var records = { '123': { __dataID__: '123', id: '123', allPhones: [ - {__dataID__: 'client:1'}, - ], + {__dataID__: 'client:1'} + ] }, 'client:1': { isVerified: true, phoneNumber: { - __dataID__: 'client:2', - }, + __dataID__: 'client:2' + } }, 'client:2': { __dataID__: 'client:2', displayNumber: phone.phoneNumber.displayNumber, - countryCode: phone.phoneNumber.countryCode, - }, + countryCode: phone.phoneNumber.countryCode + } }; var store = new RelayRecordStore({records}); var newPhone = { isVerified: true, phoneNumber: { displayNumber: '1-800-555-1212', - countryCode: '*', // *changed* - }, + countryCode: '*' // *changed* + } }; var query = getNode(Relay.QL` query { @@ -180,16 +180,16 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - allPhones: [newPhone], - }, + allPhones: [newPhone] + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { // intermediate phone object has no changes - 'client:2': true, - }, + 'client:2': true + } }); var phoneIDs = store.getLinkedRecordIDs('123', 'allPhones'); expect(phoneIDs).toEqual(['client:1']); @@ -210,28 +210,28 @@ describe('writeRelayQueryPayload()', () => { isVerified: true, phoneNumber: { displayNumber: '1-800-555-1212', - countryCode: '1', - }, + countryCode: '1' + } }; var records = { '123': { __dataID__: '123', id: '123', allPhones: [ - {__dataID__: 'client:1'}, - ], + {__dataID__: 'client:1'} + ] }, 'client:1': { isVerified: true, phoneNumber: { - __dataID__: 'client:2', - }, + __dataID__: 'client:2' + } }, 'client:2': { __dataID__: 'client:2', displayNumber: phone.phoneNumber.displayNumber, - countryCode: phone.phoneNumber.countryCode, - }, + countryCode: phone.phoneNumber.countryCode + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -250,13 +250,13 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - allPhones: [phone], - }, + allPhones: [phone] + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, - updated: {}, + updated: {} }); var phoneIDs = store.getLinkedRecordIDs('123', 'allPhones'); expect(phoneIDs).toEqual(['client:1']); @@ -277,8 +277,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - allPhones: [], - }, + allPhones: [] + } }; var store = new RelayRecordStore({records}); @@ -296,13 +296,13 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - allPhones: [], - }, + allPhones: [] + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, - updated: {}, + updated: {} }); var phoneIDs = store.getLinkedRecordIDs('123', 'allPhones'); expect(phoneIDs).toEqual([]); diff --git a/src/traversal/__tests__/writeRelayQueryPayload_pluralScalarField-test.js b/src/traversal/__tests__/writeRelayQueryPayload_pluralScalarField-test.js index fa770ab826079..c7211f45366a9 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_pluralScalarField-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_pluralScalarField-test.js @@ -39,8 +39,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - emailAddresses: [email], - }, + emailAddresses: [email] + } }; var store = new RelayRecordStore({records}); var newEmail = 'user2@example.com'; @@ -54,15 +54,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - emailAddresses: [newEmail], - }, + emailAddresses: [newEmail] + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true, - }, + '123': true + } }); expect(store.getField('123', 'emailAddresses')).toEqual([newEmail]); }); @@ -73,8 +73,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - emailAddresses: [email], - }, + emailAddresses: [email] + } }; var store = new RelayRecordStore({records}); var newEmail = 'user2@example.com'; @@ -88,15 +88,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - emailAddresses: [newEmail, email], - }, + emailAddresses: [newEmail, email] + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true, - }, + '123': true + } }); expect(store.getField('123', 'emailAddresses')) .toEqual([newEmail, email]); @@ -108,8 +108,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - emailAddresses: [email], - }, + emailAddresses: [email] + } }; var store = new RelayRecordStore({records}); var newEmail = 'user2@example.com'; @@ -123,15 +123,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - emailAddresses: [email, newEmail], - }, + emailAddresses: [email, newEmail] + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true, - }, + '123': true + } }); expect(store.getField('123', 'emailAddresses')) .toEqual([email, newEmail]); @@ -143,8 +143,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - emailAddresses: [email], - }, + emailAddresses: [email] + } }; var store = new RelayRecordStore({records}); @@ -158,13 +158,13 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - emailAddresses: [email], - }, + emailAddresses: [email] + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, - updated: {}, + updated: {} }); expect(store.getField('123', 'emailAddresses')).toEqual([email]); }); diff --git a/src/traversal/__tests__/writeRelayQueryPayload_rootRecord-test.js b/src/traversal/__tests__/writeRelayQueryPayload_rootRecord-test.js index a8cba79f308ba..d3fabb0dc850e 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_rootRecord-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_rootRecord-test.js @@ -47,15 +47,15 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { me: { - id: '123', - }, + id: '123' + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - 123: true, + 123: true }, - updated: {}, + updated: {} }); expect(store.getRecordStatus('123')).toBe('EXISTENT'); expect(store.getField('123', 'id')).toBe('123'); @@ -77,17 +77,17 @@ describe('writeRelayQueryPayload()', () => { var payload = { viewer: { actor: { - id: '123', - }, - }, + id: '123' + } + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { 'client:viewer': true, - '123': true, + '123': true }, - updated: {}, + updated: {} }); expect(store.getRecordStatus('client:viewer')).toBe('EXISTENT'); expect(store.getLinkedRecordID('client:viewer', 'actor')).toBe('123'); @@ -106,15 +106,15 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { yuzhi: { - id: '1055790163', - }, + id: '1055790163' + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - '1055790163': true, + '1055790163': true }, - updated: {}, + updated: {} }); expect(store.getRecordStatus('1055790163')).toBe('EXISTENT'); expect(store.getField('1055790163', 'id')).toBe('1055790163'); @@ -137,15 +137,15 @@ describe('writeRelayQueryPayload()', () => { // no `id` value is present, so the root ID is autogenerated var payload = { 'yuzhi': { - name: 'Yuzhi Zheng', - }, + name: 'Yuzhi Zheng' + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - 'client:1': true, + 'client:1': true }, - updated: {}, + updated: {} }); expect(store.getRecordStatus('client:1')).toBe('EXISTENT'); expect(store.getField('client:1', 'name')).toBe('Yuzhi Zheng'); @@ -164,15 +164,15 @@ describe('writeRelayQueryPayload()', () => { `, {path: '$.*.id'}); // This path is bogus. var payload = { '123': { - id: '123', - }, + id: '123' + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - '123': true, + '123': true }, - updated: {}, + updated: {} }); expect(store.getRecordStatus('123')).toBe('EXISTENT'); expect(store.getField('123', 'id')).toBe('123'); @@ -189,7 +189,7 @@ describe('writeRelayQueryPayload()', () => { } `); var payload = { - '123': null, + '123': null }; expect(() => { writePayload(store, query, payload); @@ -210,12 +210,12 @@ describe('writeRelayQueryPayload()', () => { } `); var payload = { - '123': null, + '123': null }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, - updated: {}, + updated: {} }); expect(store.getRecordStatus('123')).toBe('NONEXISTENT'); }); @@ -224,8 +224,8 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123', - }, + id: '123' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -236,14 +236,14 @@ describe('writeRelayQueryPayload()', () => { } `); var payload = { - '123': null, + '123': null }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true, - }, + '123': true + } }); expect(store.getRecordStatus('123')).toBe('NONEXISTENT'); }); @@ -261,12 +261,12 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { __dataID__: '123', - id: '123', + id: '123' }, '456': { __dataID__: '456', - id: '456', - }, + id: '456' + } }; expect(() => { writePayload(store, query, payload); @@ -289,12 +289,12 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { __dataID__: '123', - id: '123', + id: '123' }, '456': { __dataID__: '456', - id: '456', - }, + id: '456' + } }; expect(() => { writePayload(store, query, payload); @@ -315,7 +315,7 @@ describe('writeRelayQueryPayload()', () => { } `); var payload = { - '123': undefined, + '123': undefined }; expect(() => { writePayload(store, query, payload); @@ -330,8 +330,8 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123', - }, + id: '123' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -344,7 +344,7 @@ describe('writeRelayQueryPayload()', () => { } `); var payload = { - '123': undefined, + '123': undefined }; expect(() => { writePayload(store, query, payload); @@ -367,15 +367,15 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123', - }, + id: '123' + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - '123': true, + '123': true }, - updated: {}, + updated: {} }); expect(store.getRecordStatus('123')).toBe('EXISTENT'); }); @@ -384,8 +384,8 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123', - }, + id: '123' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -397,13 +397,13 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { '123': { - id: '123', - }, + id: '123' + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, - updated: {}, + updated: {} }); expect(store.getRecordStatus('123')).toBe('EXISTENT'); }); @@ -413,8 +413,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - name: 'Joe', - }, + name: 'Joe' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -428,15 +428,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: 'Joseph', - }, + name: 'Joseph' + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true, - }, + '123': true + } }); expect(store.getRecordStatus('123')).toBe('EXISTENT'); expect(store.getField('123', 'name')).toBe('Joseph'); @@ -446,8 +446,8 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123', - }, + id: '123' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -460,13 +460,13 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: 'Joseph', - }, + name: 'Joseph' + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, - updated: {}, + updated: {} }); expect(store.getRecordStatus('123')).toBe('EXISTENT'); expect(store.getField('123', 'name')).toBe(undefined); diff --git a/src/traversal/__tests__/writeRelayQueryPayload_scalarField-test.js b/src/traversal/__tests__/writeRelayQueryPayload_scalarField-test.js index 777ee6853dc81..49ac356ec8c42 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_scalarField-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_scalarField-test.js @@ -47,15 +47,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: null, - }, + name: null + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - '123': true, + '123': true }, - updated: {}, + updated: {} }); expect(store.getField('123', 'name')).toBe(null); }); @@ -64,8 +64,8 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123', - }, + id: '123' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -78,15 +78,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: null, - }, + name: null + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true, - }, + '123': true + } }); expect(store.getField('123', 'name')).toBe(null); }); @@ -96,8 +96,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - name: 'Joe', - }, + name: 'Joe' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -110,15 +110,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: null, - }, + name: null + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true, - }, + '123': true + } }); expect(store.getField('123', 'name')).toBe(null); }); @@ -136,8 +136,8 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: undefined, - }, + name: undefined + } }; writePayload(store, query, payload); expect(store.getField('123', 'id')).toBe('123'); @@ -148,8 +148,8 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123', - }, + id: '123' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -162,8 +162,8 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: undefined, - }, + name: undefined + } }; writePayload(store, query, payload); expect(store.getField('123', 'id')).toBe('123'); @@ -175,8 +175,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - name: 'Joe', - }, + name: 'Joe' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -189,8 +189,8 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: undefined, - }, + name: undefined + } }; writePayload(store, query, payload); expect(store.getField('123', 'name')).toBe('Joe'); @@ -201,8 +201,8 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - name: 'Joe', - }, + name: 'Joe' + } }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -215,15 +215,15 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - name: 'Joseph', - }, + name: 'Joseph' + } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true, - }, + '123': true + } }); expect(store.getField('123', 'name')).toBe('Joseph'); }); diff --git a/src/traversal/__tests__/writeRelayUpdatePayload-test.js b/src/traversal/__tests__/writeRelayUpdatePayload-test.js index 8397d96cb2c99..1cdd7f57506cd 100644 --- a/src/traversal/__tests__/writeRelayUpdatePayload-test.js +++ b/src/traversal/__tests__/writeRelayUpdatePayload-test.js @@ -103,12 +103,12 @@ describe('writePayload()', () => { { cursor: commentID + ':cursor', node: { - id: commentID, - }, - }, - ], - }, - }, + id: commentID + } + } + ] + } + } }; writePayload(store, query, payload); connectionID = store.getLinkedRecordID( @@ -122,7 +122,7 @@ describe('writePayload()', () => { // create the mutation and payload var input = { [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', - deletedCommentId: commentID, + deletedCommentId: commentID }; var mutation = getNode(Relay.QL` mutation { @@ -136,12 +136,12 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input), + input: JSON.stringify(input) }); var configs = [{ type: RelayMutationType.RANGE_DELETE, deletedIDFieldName: 'deletedCommentId', - pathToConnection: ['feedback', 'topLevelComments'], + pathToConnection: ['feedback', 'topLevelComments'] }]; var payload = { @@ -151,9 +151,9 @@ describe('writePayload()', () => { feedback: { id: 'feedback_id', topLevelComments: { - count: 0, - }, - }, + count: 0 + } + } }; // write to the queued store @@ -176,9 +176,9 @@ describe('writePayload()', () => { created: {}, updated: { [connectionID]: true, // range edge deleted & count changed - [edgeID]: true, // edge deleted + [edgeID]: true // edge deleted // `commentID` is not modified - }, + } }); expect(queueStore.getField(connectionID, 'count')).toBe(0); @@ -197,7 +197,7 @@ describe('writePayload()', () => { connectionID, [{name: 'first', value: '1'}] ).requestedEdges.map(edge => edge.edgeID)).toEqual([ - edgeID, + edgeID ]); }); @@ -205,7 +205,7 @@ describe('writePayload()', () => { // create the mutation and payload var input = { [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', - deletedCommentId: commentID, + deletedCommentId: commentID }; var mutation = getNode(Relay.QL` mutation { @@ -219,12 +219,12 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input), + input: JSON.stringify(input) }); var configs = [{ type: RelayMutationType.RANGE_DELETE, deletedIDFieldName: 'deletedCommentId', - pathToConnection: ['feedback', 'topLevelComments'], + pathToConnection: ['feedback', 'topLevelComments'] }]; var payload = { @@ -234,9 +234,9 @@ describe('writePayload()', () => { feedback: { id: 'feedback_id', topLevelComments: { - count: 0, - }, - }, + count: 0 + } + } }; // write to the queued store @@ -259,9 +259,9 @@ describe('writePayload()', () => { created: {}, updated: { [connectionID]: true, // range edge deleted & count changed - [edgeID]: true, // edge deleted + [edgeID]: true // edge deleted // `commentID` is not modified - }, + } }); expect(store.getField(connectionID, 'count')).toBe(0); @@ -325,18 +325,18 @@ describe('writePayload()', () => { { cursor: firstCommentID + ':cursor', node: { - id: firstCommentID, - }, + id: firstCommentID + } }, { cursor: secondCommentID + ':cursor', node: { - id: secondCommentID, - }, - }, - ], - }, - }, + id: secondCommentID + } + } + ] + } + } }; writePayload(store, query, payload); @@ -350,7 +350,7 @@ describe('writePayload()', () => { var input = { actor_id: 'actor:123', [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', - deletedCommentId: firstCommentID, + deletedCommentId: firstCommentID }; var mutation = getNode(Relay.QL` mutation { @@ -365,11 +365,11 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input), + input: JSON.stringify(input) }); var configs = [{ type: RelayMutationType.NODE_DELETE, - deletedIDFieldName: 'deletedCommentId', + deletedIDFieldName: 'deletedCommentId' }]; var payload = { @@ -379,9 +379,9 @@ describe('writePayload()', () => { feedback: { id: feedbackID, topLevelComments: { - count: 0, - }, - }, + count: 0 + } + } }; // write to the queued store @@ -405,8 +405,8 @@ describe('writePayload()', () => { updated: { [connectionID]: true, // range item deleted & count changed [firstEdgeID]: true, // edge deleted - [firstCommentID]: true, // node deleted - }, + [firstCommentID]: true // node deleted + } }); // node is deleted @@ -420,7 +420,7 @@ describe('writePayload()', () => { connectionID, [{name: 'first', value: '2'}] ).requestedEdges.map(edge => edge.edgeID)).toEqual([ - secondEdgeID, + secondEdgeID ]); // connection metadata is merged into the queued store expect(queueStore.getField(connectionID, 'count')).toBe(0); @@ -437,7 +437,7 @@ describe('writePayload()', () => { [{name: 'first', value: '2'}] ).requestedEdges.map(edge => edge.edgeID)).toEqual([ firstEdgeID, - secondEdgeID, + secondEdgeID ]); }); @@ -446,7 +446,7 @@ describe('writePayload()', () => { var input = { actor_id: 'actor:123', [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', - deletedCommentId: firstCommentID, + deletedCommentId: firstCommentID }; var mutation = getNode(Relay.QL` mutation { @@ -461,11 +461,11 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input), + input: JSON.stringify(input) }); var configs = [{ type: RelayMutationType.NODE_DELETE, - deletedIDFieldName: 'deletedCommentId', + deletedIDFieldName: 'deletedCommentId' }]; var payload = { @@ -475,9 +475,9 @@ describe('writePayload()', () => { feedback: { id: feedbackID, topLevelComments: { - count: 0, - }, - }, + count: 0 + } + } }; // write to the base store @@ -501,8 +501,8 @@ describe('writePayload()', () => { updated: { [connectionID]: true, // range item deleted & count changed [firstEdgeID]: true, // edge deleted - [firstCommentID]: true, // node deleted - }, + [firstCommentID]: true // node deleted + } }); // node is deleted @@ -516,7 +516,7 @@ describe('writePayload()', () => { connectionID, [{name: 'first', value: '1'}] ).requestedEdges.map(edge => edge.edgeID)).toEqual([ - secondEdgeID, + secondEdgeID ]); // connection metadata is merged into the queued store expect(store.getField(connectionID, 'count')).toBe(0); @@ -556,14 +556,14 @@ describe('writePayload()', () => { `); var payload = { request1: { - id: firstRequestID, + id: firstRequestID }, request2: { - id: secondRequestID, + id: secondRequestID }, request3: { - id: secondRequestID, - }, + id: secondRequestID + } }; writePayload(store, query, payload); @@ -574,7 +574,7 @@ describe('writePayload()', () => { var input = { actor_id: 'actor:123', [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', - deletedRequestIds: [firstRequestID, secondRequestID], + deletedRequestIds: [firstRequestID, secondRequestID] }; var mutation = getNode(Relay.QL` mutation { @@ -583,17 +583,17 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input), + input: JSON.stringify(input) }); var configs = [{ type: RelayMutationType.NODE_DELETE, - deletedIDFieldName: 'deletedRequestIds', + deletedIDFieldName: 'deletedRequestIds' }]; var payload = { [RelayConnectionInterface.CLIENT_MUTATION_ID]: input[RelayConnectionInterface.CLIENT_MUTATION_ID], - deletedRequestIds: [firstRequestID, secondRequestID], + deletedRequestIds: [firstRequestID, secondRequestID] }; // write to the queued store @@ -616,8 +616,8 @@ describe('writePayload()', () => { created: {}, updated: { [firstRequestID]: true, // node deleted - [secondRequestID]: true, // node deleted - }, + [secondRequestID]: true // node deleted + } }); // node is deleted @@ -638,7 +638,7 @@ describe('writePayload()', () => { var input = { actor_id: 'actor:123', [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', - deletedRequestIds: [firstRequestID, secondRequestID], + deletedRequestIds: [firstRequestID, secondRequestID] }; var mutation = getNode(Relay.QL` mutation { @@ -647,17 +647,17 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input), + input: JSON.stringify(input) }); var configs = [{ type: RelayMutationType.NODE_DELETE, - deletedIDFieldName: 'deletedRequestIds', + deletedIDFieldName: 'deletedRequestIds' }]; var payload = { [RelayConnectionInterface.CLIENT_MUTATION_ID]: input[RelayConnectionInterface.CLIENT_MUTATION_ID], - deletedRequestIds: [firstRequestID, secondRequestID], + deletedRequestIds: [firstRequestID, secondRequestID] }; // write to the base store @@ -680,8 +680,8 @@ describe('writePayload()', () => { created: {}, updated: { [firstRequestID]: true, // node deleted - [secondRequestID]: true, - }, + [secondRequestID]: true + } }); // node is deleted @@ -740,12 +740,12 @@ describe('writePayload()', () => { { cursor: commentID + ':cursor', node: { - id: commentID, - }, - }, - ], - }, - }, + id: commentID + } + } + ] + } + } }; writePayload(store, query, payload); @@ -757,7 +757,7 @@ describe('writePayload()', () => { var input = { actor_id: 'actor:123', [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', - feedback_id: feedbackID, + feedback_id: feedbackID }; var mutation = getNode(Relay.QL` mutation { @@ -776,7 +776,7 @@ describe('writePayload()', () => { type: RelayMutationType.RANGE_ADD, connectionName: 'topLevelComments', edgeName: 'feedbackCommentEdge', - rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND}, + rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND} }]; var payload = { [RelayConnectionInterface.CLIENT_MUTATION_ID]: @@ -784,9 +784,9 @@ describe('writePayload()', () => { feedback: { id: feedbackID, topLevelComments: { - count: 2, - }, - }, + count: 2 + } + } }; // write to queued store @@ -809,7 +809,7 @@ describe('writePayload()', () => { 'writeRelayUpdatePayload(): Expected response payload to include the ' + 'newly created edge `%s` and its `node` field. Did you forget to ' + 'update the `RANGE_ADD` mutation config?', - 'feedbackCommentEdge', + 'feedbackCommentEdge' ]).toBeWarnedNTimes(1); // feedback is updated, but the edge is not added @@ -828,8 +828,8 @@ describe('writePayload()', () => { feedback_id: feedbackID, message: { text: 'Hello!', - ranges: [], - }, + ranges: [] + } }; var mutation = getNode(Relay.QL` @@ -856,13 +856,13 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input), + input: JSON.stringify(input) }); var configs = [{ type: RelayMutationType.RANGE_ADD, connectionName: 'topLevelComments', edgeName: 'feedbackCommentEdge', - rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND}, + rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND} }]; var nextCursor = 'comment789:cursor'; @@ -875,21 +875,21 @@ describe('writePayload()', () => { feedback: { id: feedbackID, topLevelComments: { - count: 2, - }, + count: 2 + } }, feedbackCommentEdge: { cursor: nextCursor, node: { id: nextNodeID, body: { - text: input.message.text, - }, + text: input.message.text + } }, source: { - id: feedbackID, - }, - }, + id: feedbackID + } + } }; // write to queued store @@ -912,11 +912,11 @@ describe('writePayload()', () => { created: { [nextNodeID]: true, // node added [nextEdgeID]: true, // edge added - [bodyID]: true, // `body` subfield + [bodyID]: true // `body` subfield }, updated: { - [connectionID]: true, // range item added & count changed - }, + [connectionID]: true // range item added & count changed + } }); // queued records are updated: edge/node added @@ -934,7 +934,7 @@ describe('writePayload()', () => { [{name: 'first', value: '2'}] ).requestedEdges.map(edge => edge.edgeID)).toEqual([ nextEdgeID, - edgeID, + edgeID ]); // base records are not modified @@ -946,7 +946,7 @@ describe('writePayload()', () => { connectionID, [{name: 'first', value: '2'}] ).requestedEdges.map(edge => edge.edgeID)).toEqual([ - edgeID, + edgeID ]); }); @@ -958,8 +958,8 @@ describe('writePayload()', () => { feedback_id: feedbackID, message: { text: 'Hello!', - ranges: [], - }, + ranges: [] + } }; var mutation = getNode(Relay.QL` @@ -986,13 +986,13 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input), + input: JSON.stringify(input) }); var configs = [{ type: RelayMutationType.RANGE_ADD, connectionName: 'topLevelComments', edgeName: 'feedbackCommentEdge', - rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND}, + rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND} }]; var nextCursor = 'comment789:cursor'; @@ -1005,21 +1005,21 @@ describe('writePayload()', () => { feedback: { id: feedbackID, topLevelComments: { - count: 2, - }, + count: 2 + } }, feedbackCommentEdge: { cursor: nextCursor, node: { id: nextNodeID, body: { - text: input.message.text, - }, + text: input.message.text + } }, source: { - id: feedbackID, - }, - }, + id: feedbackID + } + } }; // write to base store @@ -1042,11 +1042,11 @@ describe('writePayload()', () => { created: { [nextNodeID]: true, // node added [nextEdgeID]: true, // edge added - [bodyID]: true, // `body` subfield + [bodyID]: true // `body` subfield }, updated: { - [connectionID]: true, // range item added & count changed - }, + [connectionID]: true // range item added & count changed + } }); // base records are updated: edge/node added @@ -1064,7 +1064,7 @@ describe('writePayload()', () => { [{name: 'first', value: '2'}] ).requestedEdges.map(edge => edge.edgeID)).toEqual([ nextEdgeID, - edgeID, + edgeID ]); }); }); diff --git a/src/traversal/checkRelayQueryData.js b/src/traversal/checkRelayQueryData.js index c7e51509fdb88..615240a812170 100644 --- a/src/traversal/checkRelayQueryData.js +++ b/src/traversal/checkRelayQueryData.js @@ -48,7 +48,7 @@ function checkRelayQueryData( var state = { dataID: undefined, rangeInfo: undefined, - result: true, + result: true }; checker.visit(query, state); @@ -93,7 +93,7 @@ class RelayQueryChecker extends RelayQueryVisitor { nextState = { dataID, rangeInfo: undefined, - result: true, + result: true }; this.traverse(root, nextState); state.result = state.result && nextState.result; @@ -152,7 +152,7 @@ class RelayQueryChecker extends RelayQueryVisitor { var nextState = { dataID: dataIDs[ii], rangeInfo: undefined, - result: true, + result: true }; this.traverse(field, nextState); state.result = nextState.result; @@ -171,7 +171,7 @@ class RelayQueryChecker extends RelayQueryVisitor { var nextState = { dataID, rangeInfo: null, // Flow rejects `undefined` here - result: true, + result: true }; var metadata = this._store.getRangeMetadata(dataID, calls); if (metadata) { @@ -199,7 +199,7 @@ class RelayQueryChecker extends RelayQueryVisitor { var nextState = { dataID: edges[ii].edgeID, rangeInfo: undefined, - result: true, + result: true }; this.traverse(field, nextState); state.result = nextState.result; @@ -225,7 +225,7 @@ class RelayQueryChecker extends RelayQueryVisitor { var nextState = { dataID, rangeInfo: undefined, - result: true, + result: true }; this.traverse(field, nextState); state.result = state.result && nextState.result; diff --git a/src/traversal/containsRelayQueryRootCall.js b/src/traversal/containsRelayQueryRootCall.js index 3b4acfc0776f6..b821fd615f603 100644 --- a/src/traversal/containsRelayQueryRootCall.js +++ b/src/traversal/containsRelayQueryRootCall.js @@ -59,7 +59,7 @@ function containsRelayQueryRootCall( var canonicalRootCalls = { 'nodes': 'node', - 'usernames': 'username', + 'usernames': 'username' }; /** diff --git a/src/traversal/diffRelayQuery.js b/src/traversal/diffRelayQuery.js index 4b0a34d45a280..1d56b25bd6eda 100644 --- a/src/traversal/diffRelayQuery.js +++ b/src/traversal/diffRelayQuery.js @@ -211,7 +211,7 @@ class RelayDiffQueryBuilder { return rangeInfo.diffCalls.length > 0 ? { diffNode: node, - trackedNode: null, + trackedNode: null } : null; } @@ -224,7 +224,7 @@ class RelayDiffQueryBuilder { } else if (node.isGenerated()) { return { diffNode: node, - trackedNode: null, + trackedNode: null }; } else if (node.isConnection()) { return this.diffConnection(node, path, dataID); @@ -300,7 +300,7 @@ class RelayDiffQueryBuilder { return { diffNode, - trackedNode, + trackedNode }; } @@ -314,7 +314,7 @@ class RelayDiffQueryBuilder { if (this._store.getField(dataID, field.getStorageKey()) === undefined) { return { diffNode: field, - trackedNode: null, + trackedNode: null }; } return null; @@ -334,7 +334,7 @@ class RelayDiffQueryBuilder { if (nextDataID === undefined) { return { diffNode: field, - trackedNode: null, + trackedNode: null }; } if (nextDataID === null) { @@ -363,7 +363,7 @@ class RelayDiffQueryBuilder { // not fetched return { diffNode: field, - trackedNode: null, + trackedNode: null }; } else if (linkedIDs === null || linkedIDs.length === 0) { // empty array means nothing to fetch @@ -401,7 +401,7 @@ class RelayDiffQueryBuilder { if (hasSplitQueries) { return { diffNode: null, - trackedNode: field, + trackedNode: field }; } } else { @@ -440,7 +440,7 @@ class RelayDiffQueryBuilder { if (connectionID === undefined) { return { diffNode: field, - trackedNode: null, + trackedNode: null }; } // Skip if the connection is deleted. @@ -468,7 +468,7 @@ class RelayDiffQueryBuilder { connectionField: field, dataID: connectionID, edgeID: edge.edgeID, - rangeInfo, + rangeInfo }; var diffOutput = this.traverse( field, @@ -488,7 +488,7 @@ class RelayDiffQueryBuilder { connectionField: field, dataID: connectionID, edgeID: null, - rangeInfo, + rangeInfo }; // diff non-`edges` fields such as `count` var diffOutput = this.traverse( @@ -521,7 +521,7 @@ class RelayDiffQueryBuilder { return { diffNode, - trackedNode, + trackedNode }; } @@ -562,7 +562,7 @@ class RelayDiffQueryBuilder { if (diffNode) { var { edges: diffEdgesField, - node: diffNodeField, + node: diffNodeField } = splitNodeAndEdgesFields(diffNode); // split missing `node` fields into a `node(id)` root query @@ -613,7 +613,7 @@ class RelayDiffQueryBuilder { // be tracked. return { diffNode: null, - trackedNode: hasSplitQueries ? edgeField : trackedNode, + trackedNode: hasSplitQueries ? edgeField : trackedNode }; } } @@ -626,7 +626,7 @@ function makeScope(dataID: DataID): DiffScope { connectionField: null, dataID, edgeID: null, - rangeInfo: null, + rangeInfo: null }; } @@ -718,7 +718,7 @@ function splitNodeAndEdgesFields( } return { edges: hasEdgeChild ? edgeOrFragment.clone(edgeChildren) : null, - node: hasNodeChild ? edgeOrFragment.clone(nodeChildren) : null, + node: hasNodeChild ? edgeOrFragment.clone(nodeChildren) : null }; } diff --git a/src/traversal/flattenRelayQuery.js b/src/traversal/flattenRelayQuery.js index cba332cf134dc..40cca57ed7283 100644 --- a/src/traversal/flattenRelayQuery.js +++ b/src/traversal/flattenRelayQuery.js @@ -65,7 +65,7 @@ class RelayQueryFlattener extends RelayQueryVisitor { if (!flattenedField) { flattenedField = { node, - flattenedFieldMap: {}, + flattenedFieldMap: {} }; state.flattenedFieldMap[serializationKey] = flattenedField; } diff --git a/src/traversal/inferRelayFieldsFromData.js b/src/traversal/inferRelayFieldsFromData.js index 77a35d4054e22..12df81614972b 100644 --- a/src/traversal/inferRelayFieldsFromData.js +++ b/src/traversal/inferRelayFieldsFromData.js @@ -86,7 +86,7 @@ function buildField( var value = captures[2].split(','); return { name: captures[1], - value: value.length === 1 ? value[0] : value, + value: value.length === 1 ? value[0] : value }; }); } diff --git a/src/traversal/splitDeferredRelayQueries.js b/src/traversal/splitDeferredRelayQueries.js index 7fefa584ca039..4b22ab6324444 100644 --- a/src/traversal/splitDeferredRelayQueries.js +++ b/src/traversal/splitDeferredRelayQueries.js @@ -43,7 +43,7 @@ function splitDeferredRelayQueries(node: RelayQuery.Root): SplitQueries { __path__: [], __refQuery__: null, deferred: [], - required: null, + required: null }; splitter.visit(node, splitQueries); @@ -123,7 +123,7 @@ function wrapNode( node.getChildren(), { isDeferred: true, - rootArg: node.getRootCallArgument(), + rootArg: node.getRootCallArgument() }, node.getName() ); @@ -223,7 +223,7 @@ function createRefQuery( [node], { isDeferred: true, - rootArg: RelayNodeInterface.ID, + rootArg: RelayNodeInterface.ID }, context.getName() ); @@ -284,7 +284,7 @@ class GraphQLSplitDeferredQueries extends RelayQueryTransform { __path__: path, __refQuery__: null, deferred: [], - required: null, + required: null }; var result = this.traverse(node, deferred); if (result) { diff --git a/src/traversal/subtractRelayQuery.js b/src/traversal/subtractRelayQuery.js index 38fcb413cde69..3b2f4dd247d75 100644 --- a/src/traversal/subtractRelayQuery.js +++ b/src/traversal/subtractRelayQuery.js @@ -40,7 +40,7 @@ function subtractRelayQuery( var visitor = new RelayQuerySubtractor(); var state = { isEmpty: true, - subtrahend, + subtrahend }; var diff = visitor.visit(minuend, state); if (!state.isEmpty) { @@ -124,7 +124,7 @@ class RelayQuerySubtractor extends RelayQueryTransform { for (var ii = 0; ii < subtrahendRanges.length; ii++) { fieldState = { isEmpty: true, - subtrahend: subtrahendRanges[ii], + subtrahend: subtrahendRanges[ii] }; diff = this._subtractChildren(diff, fieldState); state.isEmpty = fieldState.isEmpty; @@ -151,7 +151,7 @@ class RelayQuerySubtractor extends RelayQueryTransform { var fieldState = { isEmpty: true, - subtrahend: subField, + subtrahend: subField }; var diff = this._subtractChildren(node, fieldState); state.isEmpty = fieldState.isEmpty; @@ -168,7 +168,7 @@ class RelayQuerySubtractor extends RelayQueryTransform { return node.clone(node.getChildren().map(child => { var childState = { isEmpty: true, - subtrahend: state.subtrahend, + subtrahend: state.subtrahend }; var diff = this.visit(child, childState); state.isEmpty = state.isEmpty && childState.isEmpty; diff --git a/src/traversal/writeRelayUpdatePayload.js b/src/traversal/writeRelayUpdatePayload.js index f6b5d656af031..f2c91d5ed4c39 100644 --- a/src/traversal/writeRelayUpdatePayload.js +++ b/src/traversal/writeRelayUpdatePayload.js @@ -54,7 +54,7 @@ var ID = 'id'; var IGNORED_KEYS = { error: true, /* $FlowIssue #7728187 - Computed Property */ - [CLIENT_MUTATION_ID]: true, + [CLIENT_MUTATION_ID]: true }; var STUB_CURSOR_ID = 'client:cursor'; @@ -326,8 +326,8 @@ function handleRangeAdd( cursor: cursor, node: { ...edge.node, - id: nodeID, - }, + id: nodeID + } }; // add the node to every connection for this field From 6bc0f835cd2d9d8fb3f5cc405edeb39bc3a86010 Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Fri, 14 Aug 2015 12:19:17 +0100 Subject: [PATCH 04/14] remove comma-dangle rule --- .eslintrc | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index c24006e1d6014..ec4c051d572b8 100644 --- a/.eslintrc +++ b/.eslintrc @@ -31,7 +31,6 @@ rules: brace-style: 2 space-after-keywords: 2 strict: [2, global] - comma-dangle: [2, never] # Make this a warning for now. We do this in a few places so we might need to # disable no-unused-expressions: 2 From 71ea52a6abc0c896612debcc5c87de4362e30b44 Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Sun, 16 Aug 2015 17:11:10 +0100 Subject: [PATCH 05/14] update travis config --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 77df38e729c61..df1b3cc17e810 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,8 @@ language: node_js node_js: - '0.10' +before_install: +- npm install -g npm@2 env: - TEST_DIR=. - TEST_DIR=scripts/babel-relay-plugin From 1a99f6ac99174d05e50733be56ed4479f1bf2e31 Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Sun, 16 Aug 2015 17:11:25 +0100 Subject: [PATCH 06/14] update lint script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f7061d05cc12e..4fa999b3e9c51 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "scripts": { "build": "[ $(ulimit -n) -lt 4096 ] && ulimit -n 4096; gulp", "prepublish": "npm run build", - "lint": "`npm bin`/eslint .", + "lint": "eslint .", "test": "NODE_ENV=test jest" }, "engines": { From 536814c9a583503833625b98bae9777e05437470 Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Sun, 16 Aug 2015 17:11:51 +0100 Subject: [PATCH 07/14] remove previous changes to /src --- src/__forks__/traversal/printRelayQuery.js | 12 ++++++------ src/container/__tests__/RelayRootContainer-test.js | 4 ++-- src/legacy/store/GraphQLDeferredQueryTracker.js | 2 +- src/legacy/store/GraphQLRange.js | 2 +- src/store/RelayPendingQueryTracker.js | 2 +- src/store/RelayStoreGarbageCollector.js | 2 +- src/store/__tests__/RelayRecordStore_write-test.js | 4 ++-- src/store/validateRelayReadQuery.js | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/__forks__/traversal/printRelayQuery.js b/src/__forks__/traversal/printRelayQuery.js index 93c91fb49cb09..9da6093bf00b3 100644 --- a/src/__forks__/traversal/printRelayQuery.js +++ b/src/__forks__/traversal/printRelayQuery.js @@ -147,17 +147,17 @@ function printChildren( node: RelayQuery.Node, fragmentMap: FragmentMap ): string { - var children = node.getChildren().map(childrenNode => { - if (childrenNode instanceof RelayQuery.Field) { - return printField(childrenNode, fragmentMap); + var children = node.getChildren().map(node => { + if (node instanceof RelayQuery.Field) { + return printField(node, fragmentMap); } else { invariant( - childrenNode instanceof RelayQuery.Fragment, + node instanceof RelayQuery.Fragment, 'printRelayQuery(): expected child node to be a `Field` or ' + '`Fragment`, got `%s`.', - childrenNode.constructor.name + node.constructor.name ); - return printInlineFragment(childrenNode, fragmentMap); + return printInlineFragment(node, fragmentMap); } }); if (!children.length) { diff --git a/src/container/__tests__/RelayRootContainer-test.js b/src/container/__tests__/RelayRootContainer-test.js index 38c89e28fc08f..2b8d63a3023a3 100644 --- a/src/container/__tests__/RelayRootContainer-test.js +++ b/src/container/__tests__/RelayRootContainer-test.js @@ -80,7 +80,7 @@ describe('RelayRootContainer', function() { }); var container = document.createElement('div'); jest.addMatchers({ - toRenderChildWithRoute(childRoute) { + toRenderChildWithRoute(route) { var context; function onRender() { context = this.context; @@ -95,7 +95,7 @@ describe('RelayRootContainer', function() { ReactDOM.render(element, container); var mockRequests = RelayStore.primeCache.mock.requests; mockRequests[mockRequests.length - 1].block(); - return context.route === childRoute; + return context.route === route; } }); }); diff --git a/src/legacy/store/GraphQLDeferredQueryTracker.js b/src/legacy/store/GraphQLDeferredQueryTracker.js index 5ac920b2298c2..2542e71493286 100644 --- a/src/legacy/store/GraphQLDeferredQueryTracker.js +++ b/src/legacy/store/GraphQLDeferredQueryTracker.js @@ -421,7 +421,7 @@ function processBroadcasts() { } } - subscribers = subscribers.filter(sub => sub !== null); + subscribers = subscribers.filter(subscriber => subscriber !== null); broadcastItems = null; } diff --git a/src/legacy/store/GraphQLRange.js b/src/legacy/store/GraphQLRange.js index 30a851805997d..c4a28dd2a434b 100644 --- a/src/legacy/store/GraphQLRange.js +++ b/src/legacy/store/GraphQLRange.js @@ -1044,7 +1044,7 @@ class GraphQLRange { range._hasLast = hasLast; range._staticQueriesMap = staticQueriesMap; range._orderedSegments = - orderedSegments.map(orderedSegment => GraphQLSegment.fromJSON(orderedSegment)); + orderedSegments.map(descriptor => GraphQLSegment.fromJSON(descriptor)); return range; } diff --git a/src/store/RelayPendingQueryTracker.js b/src/store/RelayPendingQueryTracker.js index 66b617eed0cfc..9f4be4d90391d 100644 --- a/src/store/RelayPendingQueryTracker.js +++ b/src/store/RelayPendingQueryTracker.js @@ -208,7 +208,7 @@ class PendingFetch { var queryID = this.getQuery().getID(); delete pendingFetchMap[queryID]; - warning(false, 'Cannot mark as rejected'); + warning(false, error.message); this._errors.push(error); this._updateResolvedDeferred(); diff --git a/src/store/RelayStoreGarbageCollector.js b/src/store/RelayStoreGarbageCollector.js index 651d87ce4e2ba..61c382e7f9485 100644 --- a/src/store/RelayStoreGarbageCollector.js +++ b/src/store/RelayStoreGarbageCollector.js @@ -246,7 +246,7 @@ class RelayStoreGarbageCollector { // client-site DataID the record will be added to `remainingRecords` and // it's DataID will be set to `true` in `removalStatusMap`. function enqueueField(field: FieldValue): void { - dataID = getClientIDFromLinkedRecord(field); + var dataID = getClientIDFromLinkedRecord(field); // If we have a dataID we haven't seen before we add it to the remaining // records if (dataID && !removalStatusMap[dataID]) { diff --git a/src/store/__tests__/RelayRecordStore_write-test.js b/src/store/__tests__/RelayRecordStore_write-test.js index d2c9fb03704e0..e2a86c49d1eb2 100644 --- a/src/store/__tests__/RelayRecordStore_write-test.js +++ b/src/store/__tests__/RelayRecordStore_write-test.js @@ -549,8 +549,8 @@ describe('RelayRecordStore', () => { ); // node are automatically associated with the range - nodes.forEach(node => { - expect(store.getConnectionIDsForRecord(node)).toEqual([connectionID]); + nodes.forEach(nodeID => { + expect(store.getConnectionIDsForRecord(nodeID)).toEqual([connectionID]); }); var rangeInfo = store.getRangeMetadata(connectionID, calls); diff --git a/src/store/validateRelayReadQuery.js b/src/store/validateRelayReadQuery.js index 4cbbc57a92061..48782d9f78db4 100644 --- a/src/store/validateRelayReadQuery.js +++ b/src/store/validateRelayReadQuery.js @@ -42,7 +42,7 @@ if (__DEV__) { * At the moment, "well-formed" means that the query does not contain * duplicate aliases. */ - validateRelayReadQuery = function( + validateRelayReadQuery = function validateRelayReadQuery( queryNode: RelayQuery.Node, options?: StoreReaderOptions ): void { From 0c741032f6e9c37654c7d184e92d7628a117ff58 Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Sun, 16 Aug 2015 19:44:34 +0100 Subject: [PATCH 08/14] update eslint packages, remove not needed eslint rules --- .eslintignore | 1 - .eslintrc | 7 -- eslint-rules/README.md | 5 - .../warning-and-invariant-args-test.js | 102 ------------------ eslint-rules/index.js | 7 -- eslint-rules/package.json | 4 - eslint-rules/warning-and-invariant-args.js | 88 --------------- package.json | 6 +- 8 files changed, 2 insertions(+), 218 deletions(-) delete mode 100644 eslint-rules/README.md delete mode 100644 eslint-rules/__tests__/warning-and-invariant-args-test.js delete mode 100644 eslint-rules/index.js delete mode 100644 eslint-rules/package.json delete mode 100644 eslint-rules/warning-and-invariant-args.js diff --git a/.eslintignore b/.eslintignore index 097fc6005174d..9e7436c5c2d20 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,4 +7,3 @@ scripts/ # for disable website but should be done as well website/ *.md -eslint-rules/ diff --git a/.eslintrc b/.eslintrc index ec4c051d572b8..07278ef7fb9cc 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,7 +3,6 @@ parser: babel-eslint plugins: - react - - react-internal env: browser: true @@ -33,11 +32,9 @@ rules: strict: [2, global] # Make this a warning for now. We do this in a few places so we might need to # disable - no-unused-expressions: 2 eol-last: 2 dot-notation: 2 dot-location: [2, property] - consistent-return: 2 no-unused-vars: [2, args: none] quotes: [2, single, avoid-escape] no-multi-spaces: 2 @@ -93,7 +90,3 @@ rules: # We don't care to do this react/sort-comp: 0 react/wrap-multilines: [2, {declaration: false, assignment: false}] - - # CUSTOM RULES - # the second argument of warning/invariant should be a literal string - react-internal/warning-and-invariant-args: 2 diff --git a/eslint-rules/README.md b/eslint-rules/README.md deleted file mode 100644 index 9d081e69e72f2..0000000000000 --- a/eslint-rules/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Custom ESLint Rules - -This is a dummy npm package that allows us to treat it as an eslint-plugin. It's not actually published, nor are the rules here useful for users of react. If you want to lint your react code, try . - -**If you modify this rule, you must re-run `npm install ./eslint-rules` for it to take effect.** diff --git a/eslint-rules/__tests__/warning-and-invariant-args-test.js b/eslint-rules/__tests__/warning-and-invariant-args-test.js deleted file mode 100644 index af1f26c74b3c5..0000000000000 --- a/eslint-rules/__tests__/warning-and-invariant-args-test.js +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright 2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @emails react-core - */ - -'use strict'; - -var rule = require('../warning-and-invariant-args'); -var RuleTester = require('eslint').RuleTester; -var ruleTester = new RuleTester(); - -ruleTester.run('eslint-rules/warning-and-invariant-args', rule, { - valid: [ - "warning(true, 'hello, world');", - "warning(true, 'expected %s, got %s', 42, 24);", - "invariant(true, 'hello, world');", - "invariant(true, 'expected %s, got %s', 42, 24);", - ], - invalid: [ - { - code: "warning('hello, world');", - errors: [ - { - message: 'warning takes at least two arguments', - }, - ], - }, - { - code: 'warning(true, null);', - errors: [ - { - message: 'The second argument to warning must be a string literal', - }, - ], - }, - { - code: 'var g = 5; invariant(true, g);', - errors: [ - { - message: 'The second argument to invariant must be a string literal', - }, - ], - }, - { - code: "warning(true, 'expected %s, got %s');", - errors: [ - { - message: - 'Expected 4 arguments in call to warning based on the number of ' + - '"%s" substitutions, but got 2', - }, - ], - }, - { - code: "warning(true, 'foo is a bar under foobar', 'junk argument');", - errors: [ - { - message: - 'Expected 2 arguments in call to warning based on the number of ' + - '"%s" substitutions, but got 3', - }, - ], - }, - { - code: "invariant(true, 'error!');", - errors: [ - { - message: - 'The invariant format should be able to uniquely identify this ' + - 'invariant. Please, use a more descriptive format than: error!', - }, - ], - }, - { - code: "warning(true, 'error!');", - errors: [ - { - message: - 'The warning format should be able to uniquely identify this ' + - 'warning. Please, use a more descriptive format than: error!', - }, - ], - }, - { - code: "warning(true, '%s %s, %s %s: %s (%s)', 1, 2, 3, 4, 5, 6);", - errors: [ - { - message: - 'The warning format should be able to uniquely identify this ' + - 'warning. Please, use a more descriptive format than: ' + - '%s %s, %s %s: %s (%s)', - }, - ], - }, - ], -}); diff --git a/eslint-rules/index.js b/eslint-rules/index.js deleted file mode 100644 index 5efee2d47caf2..0000000000000 --- a/eslint-rules/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = { - rules: { - 'warning-and-invariant-args': require('./warning-and-invariant-args'), - }, -}; diff --git a/eslint-rules/package.json b/eslint-rules/package.json deleted file mode 100644 index 6424cce415ee3..0000000000000 --- a/eslint-rules/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "eslint-plugin-react-internal", - "version": "0.0.0" -} diff --git a/eslint-rules/warning-and-invariant-args.js b/eslint-rules/warning-and-invariant-args.js deleted file mode 100644 index 3611935579da8..0000000000000 --- a/eslint-rules/warning-and-invariant-args.js +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright 2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @emails react-core -*/ - -'use strict'; - -/** - * The warning() and invariant() functions take format strings as their second - * argument. - */ - -module.exports = function(context) { - // we also allow literal strings and concatinated literal strings - function getLiteralString(node) { - if (node.type === 'Literal' && typeof node.value === 'string') { - return node.value; - } else if (node.type === 'BinaryExpression' && node.operator === '+') { - var l = getLiteralString(node.left); - var r = getLiteralString(node.right); - if (l !== null && r !== null) { - return l + r; - } - } - return null; - } - - return { - CallExpression: function(node) { - // This could be a little smarter by checking context.getScope() to see - // how warning/invariant was defined. - var isWarningOrInvariant = - node.callee.type === 'Identifier' && - (node.callee.name === 'warning' || node.callee.name === 'invariant'); - if (!isWarningOrInvariant) { - return; - } - if (node.arguments.length < 2) { - context.report( - node, - '{{name}} takes at least two arguments', - {name: node.callee.name} - ); - return; - } - var format = getLiteralString(node.arguments[1]); - if (format === null) { - context.report( - node, - 'The second argument to {{name}} must be a string literal', - {name: node.callee.name} - ); - return; - } - if (format.length < 10 || /^[s\W]*$/.test(format)) { - context.report( - node, - 'The {{name}} format should be able to uniquely identify this ' + - '{{name}}. Please, use a more descriptive format than: {{format}}', - {name: node.callee.name, format: format} - ); - return; - } - // count the number of formating substitutions, plus the first two args - var expectedNArgs = (format.match(/%s/g) || []).length + 2; - if (node.arguments.length !== expectedNArgs) { - context.report( - node, - 'Expected {{expectedNArgs}} arguments in call to {{name}} based on ' + - 'the number of "%s" substitutions, but got {{length}}', - { - expectedNArgs: expectedNArgs, - name: node.callee.name, - length: node.arguments.length, - } - ); - } - }, - }; -}; - -module.exports.schema = []; diff --git a/package.json b/package.json index 3d03ae18255e9..45baaac678be1 100644 --- a/package.json +++ b/package.json @@ -39,15 +39,13 @@ }, "devDependencies": { "babel-core": "5.8.21", - "babel-eslint": "^4.0.5", + "babel-eslint": "^4.0.7", "babel-loader": "5.3.2", "babel-relay-plugin": "^0.1.2", "del": "^1.2.0", "envify": "^3.4.0", "eslint": "^1.1.0", - "eslint-plugin-react": "^3.2.2", - "eslint-plugin-react-internal": "file:eslint-rules", - "eslint-tester": "^0.8.2", + "eslint-plugin-react": "^3.2.3", "gulp": "^3.9.0", "gulp-babel": "^5.1.0", "gulp-derequire": "^2.1.0", From c30fc0ccec999d2579657684d75a5b78cfbc490d Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Sun, 16 Aug 2015 19:44:48 +0100 Subject: [PATCH 09/14] fix code to respect new rules --- src/RelayPublic.js | 2 +- src/__forks__/Relay.js | 2 +- .../interface/RelayConnectionInterface.js | 6 +- src/__forks__/interface/RelayNodeInterface.js | 2 +- .../interface/__mocks__/RelayNodeInterface.js | 2 +- .../__tests__/printRelayQuery-test.js | 10 +- src/container/RelayContainer.js | 22 +- src/container/RelayContainerComparators.js | 2 +- src/container/RelayPropTypes.js | 4 +- src/container/RelayRootContainer.js | 16 +- .../__tests__/RelayContainer-test.js | 14 +- .../RelayContainer_setVariables-test.js | 20 +- .../__tests__/RelayRootContainer-test.js | 46 +-- .../__tests__/getRelayQueries-test.js | 12 +- src/legacy/query/GraphQL.js | 10 +- src/legacy/store/DliteFetchModeConstants.js | 2 +- .../store/GraphQLDeferredQueryTracker.js | 4 +- src/legacy/store/GraphQLQueryRunner.js | 8 +- src/legacy/store/GraphQLRange.js | 22 +- src/legacy/store/GraphQLSegment.js | 4 +- src/legacy/store/GraphQLStoreChangeEmitter.js | 2 +- src/legacy/store/GraphQLStoreRangeUtils.js | 2 +- .../__mocks__/GraphQLStoreQueryResolver.js | 2 +- .../store/__mocks__/GraphQLStoreTestUtils.js | 4 +- .../GraphQLDeferredQueryTracker-test.js | 4 +- .../__tests__/GraphQLQueryRunner-test.js | 54 ++-- .../store/__tests__/GraphQLRange-test.js | 56 ++-- .../GraphQLStoreQueryResolver-test.js | 17 +- src/mutation/RelayMutation.js | 4 +- src/mutation/RelayMutationQuery.js | 12 +- src/mutation/RelayMutationTransaction.js | 8 +- .../RelayMutationTransactionStatus.js | 2 +- src/mutation/RelayMutationType.js | 2 +- src/mutation/__tests__/RelayMutation-test.js | 6 +- .../__tests__/RelayMutationQuery-test.js | 61 ++-- .../RelayMutationTransaction-test.js | 12 +- .../default/RelayDefaultNetworkLayer.js | 10 +- .../RelayDefaultNetworkLayer-test.js | 48 +-- src/network/__mocks__/fetchRelayQuery.js | 2 +- .../__tests__/RelayNetworkLayer-test.js | 2 +- src/query/RelayQL.js | 2 +- src/query/RelayQuery.js | 6 +- src/query/RelayQueryPath.js | 2 +- src/query/RelayQuerySerializer.js | 10 +- .../__tests__/RelayFragmentReference-test.js | 16 +- src/query/__tests__/RelayQL-test.js | 2 - .../RelayQuery-getCallsWithValues-test.js | 48 +-- src/query/__tests__/RelayQuery-test.js | 72 ++--- src/query/__tests__/RelayQueryPath-test.js | 20 +- .../__tests__/RelayQuerySerializer-test.js | 62 ++-- .../__tests__/RelayQueryTransform-test.js | 2 +- src/query/__tests__/RelayQueryVisitor-test.js | 2 +- src/query/__tests__/buildRQL-test.js | 10 +- src/query/__tests__/callsToGraphQL-test.js | 8 +- src/query/__tests__/stableStringify-test.js | 8 +- src/query/__tests__/toGraphQL-test.js | 4 +- src/query/buildRQL.js | 2 +- src/query/fromGraphQL.js | 2 +- src/query/toGraphQL.js | 6 +- src/route/RelayMetaRoute.js | 2 +- src/route/RelayRoute.js | 12 +- src/store/RelayBufferedNeglectionStateMap.js | 8 +- src/store/RelayChangeTracker.js | 4 +- src/store/RelayMutationTracker.js | 2 +- src/store/RelayNeglectionStateMap.js | 2 +- src/store/RelayPendingQueryTracker.js | 4 +- src/store/RelayQueryTracker.js | 2 +- src/store/RelayQueryWriter.js | 14 +- src/store/RelayRecordStatus.js | 2 +- src/store/RelayRecordStore.js | 22 +- src/store/RelayStoreData.js | 6 +- src/store/RelayStoreGarbageCollector.js | 2 +- .../RelayBufferedNeglectionStateMap.js | 2 +- src/store/__mocks__/RelayMockCacheManager.js | 4 +- .../__mocks__/RelayNeglectionStateMap.js | 2 +- src/store/__mocks__/RelayStore.js | 4 +- .../__tests__/RelayNeglectionStateMap-test.js | 4 +- .../RelayPendingQueryTracker-test.js | 12 +- src/store/__tests__/RelayRecordStore-test.js | 130 ++++---- .../__tests__/RelayRecordStore_write-test.js | 29 +- src/store/__tests__/RelayStoreData-test.js | 38 +-- .../RelayStoreData_cacheManager-test.js | 162 +++++----- .../RelayStoreGarbageCollector-test.js | 46 +-- .../__tests__/filterExclusiveKeys-test.js | 10 +- .../observeAllRelayQueryData-test.js | 36 +-- .../__tests__/observeRelayQueryData-test.js | 26 +- .../__tests__/readRelayQueryData-test.js | 304 +++++++++--------- src/store/filterExclusiveKeys.js | 2 +- src/store/observeAllRelayQueryData.js | 10 +- src/store/observeRelayQueryData.js | 7 +- src/store/readRelayQueryData.js | 12 +- src/tools/RelayDeprecated.js | 10 +- src/tools/RelayError.js | 2 +- src/tools/RelayProfiler.js | 2 +- src/tools/__mocks__/RelayProfiler.js | 2 +- src/tools/__mocks__/RelayTestUtils.js | 8 +- src/tools/__tests__/RelayProfiler-test.js | 10 +- .../__tests__/checkRelayQueryData-test.js | 62 ++-- .../__tests__/diffRelayQuery-test.js | 76 ++--- .../diffRelayQuery_connection-test.js | 76 ++--- .../flattenSplitRelayQueries-test.js | 28 +- .../inferRelayFieldsFromData-test.js | 40 ++- .../__tests__/printRelayQueryCall-test.js | 20 +- .../__tests__/refragmentRelayQuery-test.js | 2 +- .../splitDeferredRelayQueries-test.js | 4 +- ...eRelayQueryPayload_connectionField-test.js | 134 ++++---- ...writeRelayQueryPayload_linkedField-test.js | 82 ++--- .../writeRelayQueryPayload_paths-test.js | 140 ++++---- ...elayQueryPayload_pluralLinkedField-test.js | 24 +- .../writeRelayQueryPayload_rootRecord-test.js | 94 +++--- ...writeRelayQueryPayload_scalarField-test.js | 10 +- .../__tests__/writeRelayUpdatePayload-test.js | 206 ++++++------ src/traversal/checkRelayQueryData.js | 12 +- src/traversal/diffRelayQuery.js | 26 +- src/traversal/inferRelayFieldsFromData.js | 2 +- src/traversal/splitDeferredRelayQueries.js | 6 +- src/traversal/subtractRelayQuery.js | 6 +- src/traversal/writeRelayUpdatePayload.js | 2 +- 118 files changed, 1401 insertions(+), 1411 deletions(-) diff --git a/src/RelayPublic.js b/src/RelayPublic.js index 0a607e44e1b9e..10fe1aa3d51cf 100644 --- a/src/RelayPublic.js +++ b/src/RelayPublic.js @@ -49,7 +49,7 @@ var RelayPublic = { getQueries: getRelayQueries, injectNetworkLayer: RelayNetworkLayer.injectNetworkLayer, injectTaskScheduler: RelayTaskScheduler.injectScheduler, - isContainer: isRelayContainer + isContainer: isRelayContainer, }; module.exports = RelayPublic; diff --git a/src/__forks__/Relay.js b/src/__forks__/Relay.js index 324d941895c0f..8b0c2e8e6a6e0 100644 --- a/src/__forks__/Relay.js +++ b/src/__forks__/Relay.js @@ -22,5 +22,5 @@ RelayPublic.injectNetworkLayer(new RelayDefaultNetworkLayer('/graphql')); module.exports = { ...RelayPublic, // Expose the default network layer to allow convenient re-configuration. - DefaultNetworkLayer: RelayDefaultNetworkLayer + DefaultNetworkLayer: RelayDefaultNetworkLayer, }; diff --git a/src/__forks__/interface/RelayConnectionInterface.js b/src/__forks__/interface/RelayConnectionInterface.js index 2beed348acf34..835871afd0586 100644 --- a/src/__forks__/interface/RelayConnectionInterface.js +++ b/src/__forks__/interface/RelayConnectionInterface.js @@ -21,12 +21,12 @@ var CONNECTION_CALLS = { 'find': true, 'first': true, 'last': true, - 'surrounds': true + 'surrounds': true, }; var REQUIRED_RANGE_CALLS = { 'find': true, 'first': true, - 'last': true + 'last': true, }; /** @@ -77,7 +77,7 @@ var RelayConnectionInterface = { pageInfo[RelayConnectionInterface.HAS_NEXT_PAGE] = false; pageInfo[RelayConnectionInterface.HAS_PREV_PAGE] = false; return pageInfo; - } + }, }; module.exports = RelayConnectionInterface; diff --git a/src/__forks__/interface/RelayNodeInterface.js b/src/__forks__/interface/RelayNodeInterface.js index db660df3bcba7..fcb36b4fcd245 100644 --- a/src/__forks__/interface/RelayNodeInterface.js +++ b/src/__forks__/interface/RelayNodeInterface.js @@ -94,7 +94,7 @@ var RelayNodeInterface = { } return results; - } + }, }; function getPayloadRecords( diff --git a/src/__forks__/interface/__mocks__/RelayNodeInterface.js b/src/__forks__/interface/__mocks__/RelayNodeInterface.js index 28598ff68501b..b5a4b4dccfa25 100644 --- a/src/__forks__/interface/__mocks__/RelayNodeInterface.js +++ b/src/__forks__/interface/__mocks__/RelayNodeInterface.js @@ -99,7 +99,7 @@ var RelayNodeInterface = { } return results; - } + }, }; /** diff --git a/src/__forks__/traversal/__tests__/printRelayQuery-test.js b/src/__forks__/traversal/__tests__/printRelayQuery-test.js index 5e22306cb6bd4..b46ea260d7717 100644 --- a/src/__forks__/traversal/__tests__/printRelayQuery-test.js +++ b/src/__forks__/traversal/__tests__/printRelayQuery-test.js @@ -169,7 +169,7 @@ describe('printRelayQuery', () => { } } `, { - q: value + q: value, }); expect(printRelayQuery(query)).toEqual(trimQuery(` @@ -187,12 +187,12 @@ describe('printRelayQuery', () => { new GraphQL.BatchCallVariable('q0', '$.*.actor.id'), [ RelayQuery.Node.buildField('id'), - RelayQuery.Node.buildField('name') + RelayQuery.Node.buildField('name'), ], { isDeferred: true, rootArg: RelayNodeInterface.ID, - type: RelayNodeInterface.NODE_TYPE + type: RelayNodeInterface.NODE_TYPE, }, 'RefQueryName' ); @@ -327,7 +327,7 @@ describe('printRelayQuery', () => { var alias = generateRQLFieldAlias('profilePicture.size(32,64)'); var variables = { height: 64, - width: 32 + width: 32, }; var fragment = getNode(Relay.QL` fragment on Actor { @@ -364,7 +364,7 @@ describe('printRelayQuery', () => { `, { first: 10, orderby: ['name'], - isViewerFriend: false + isViewerFriend: false, }); var alias = fragment.getChildren()[0].getSerializationKey(); expect(printRelayQuery(fragment)).toEqual(trimQuery(` diff --git a/src/container/RelayContainer.js b/src/container/RelayContainer.js index 0b1e466542ec9..da2ef142b3165 100644 --- a/src/container/RelayContainer.js +++ b/src/container/RelayContainer.js @@ -11,8 +11,6 @@ * @flow */ -/* eslint no-unused-expressions: 1 */ - 'use strict'; var ErrorUtils = require('ErrorUtils'); @@ -80,7 +78,7 @@ GraphQLStoreChangeEmitter.injectBatchingStrategy( ); var containerContextTypes = { - route: RelayPropTypes.QueryConfig.isRequired + route: RelayPropTypes.QueryConfig.isRequired, }; var nextContainerID = 0; @@ -163,7 +161,7 @@ function createContainerComponent( this.pending = null; this.state = { variables: {}, - queryData: {} + queryData: {}, }; } @@ -258,7 +256,7 @@ function createContainerComponent( var completeProfiler = RelayProfiler.profile( 'RelayContainer.setVariables', { containerName, - nextVariables + nextVariables, } ); @@ -318,7 +316,7 @@ function createContainerComponent( variables: nextVariables, request: forceFetch ? RelayStore.forceFetch(querySet, onReadyStateChange) : - RelayStore.primeCache(querySet, onReadyStateChange) + RelayStore.primeCache(querySet, onReadyStateChange), }; this.pending = current; } @@ -450,7 +448,7 @@ function createContainerComponent( fragmentID, { onSuccess: this._handleDeferredSuccess.bind(this), - onFailure: this._handleDeferredFailure.bind(this) + onFailure: this._handleDeferredFailure.bind(this), } ); } @@ -476,7 +474,7 @@ function createContainerComponent( this.setState({ queryData, - variables + variables, }); } @@ -495,7 +493,7 @@ function createContainerComponent( this._updateQueryResolvers(); return { variables, - queryData: this._getQueryData(nextProps) + queryData: this._getQueryData(nextProps), }; }); @@ -778,7 +776,7 @@ function createContainerComponent( hasOptimisticUpdate: this.hasOptimisticUpdate, route: this.context.route, setVariables: this.setVariables, - variables: this.state.variables + variables: this.state.variables, }; return ( { var BadContainer = Relay.createContainer(MockComponent, { fragments: { - viewer: () => Relay.QL`query{node(id:"123"){id}}` + viewer: () => Relay.QL`query{node(id:"123"){id}}`, } }); var badFragmentReference = BadContainer.getFragment('viewer'); @@ -118,7 +118,7 @@ describe('RelayContainer', function() { var TEST_PHOTO_SIZE = 100; var MockProfilePhoto = Relay.createContainer(MockComponent, { initialVariables: { - testPhotoSize: TEST_PHOTO_SIZE + testPhotoSize: TEST_PHOTO_SIZE, }, fragments: { photo: variables => Relay.QL` @@ -207,14 +207,14 @@ describe('RelayContainer', function() { sideshowFragment = new GraphQL.QueryFragment('Test', 'Viewer'); feedFragment = new GraphQL.QueryFragment('Test', 'Viewer', [ - new GraphQL.Field('newsFeed') + new GraphQL.Field('newsFeed'), ]); }); it('can conditionally include a fragment based on variables', () => { var MockSideshow = Relay.createContainer(MockComponent, { initialVariables: { - hasSideshow: null + hasSideshow: null, }, fragments: { viewer: variables => Relay.QL` @@ -252,7 +252,7 @@ describe('RelayContainer', function() { it('can conditionally exclude a fragment based on variables', () => { var MockSideshow = Relay.createContainer(MockComponent, { initialVariables: { - hasSideshow: null + hasSideshow: null, }, fragments: { viewer: variables => Relay.QL` @@ -422,7 +422,7 @@ describe('RelayContainer', function() { 'you are purposely passing in mock data that conforms to ' + 'the shape of this component\'s fragment.', 'foo', - 'MockComponent' + 'MockComponent', ]).toBeWarnedNTimes(1); }); @@ -443,7 +443,7 @@ describe('RelayContainer', function() { 'a prop from the parent. Pass an explicit `null` if this is ' + 'intentional.', 'bar', - 'MockComponent' + 'MockComponent', ]).toBeWarnedNTimes(1); }); diff --git a/src/container/__tests__/RelayContainer_setVariables-test.js b/src/container/__tests__/RelayContainer_setVariables-test.js index 111c9bdc1a91b..2ce85cbdf082e 100644 --- a/src/container/__tests__/RelayContainer_setVariables-test.js +++ b/src/container/__tests__/RelayContainer_setVariables-test.js @@ -74,7 +74,7 @@ describe('RelayContainer.setVariables', function() { error: null, mounted: true, ready: false, - stale: false + stale: false, }; domContainer = document.createElement('div'); mockInstance = RelayTestUtils.createRenderer(domContainer).render( @@ -129,7 +129,7 @@ describe('RelayContainer.setVariables', function() { profilePicture: { uri: '//url' } - } + }, ]; }); @@ -178,7 +178,7 @@ describe('RelayContainer.setVariables', function() { var updatedQueryData = [ {__dataID__: '21', id: '21', url: '//www'}, - {__dataID__: '42', id: '42', url: '//www'} + {__dataID__: '42', id: '42', url: '//www'}, ]; GraphQLStoreQueryResolver.mockDefaultResolveImplementation(pointer => { expect(pointer.getFragment().getVariables()).toEqual({site: 'www'}); @@ -355,7 +355,7 @@ describe('RelayContainer.setVariables', function() { expect(mockFunction.mock.calls).toEqual([ [{...defaultState, done: false, ready: false}], - [{...defaultState, done: true, ready: true}] + [{...defaultState, done: true, ready: true}], ]); }); @@ -416,7 +416,7 @@ describe('RelayContainer.setVariables', function() { entity: entityQuery }, initialVariables: {site: 'mobile'}, - prepareVariables + prepareVariables, }); mockInstance = RelayTestUtils.createRenderer(domContainer).render( genMockPointer => @@ -474,7 +474,7 @@ describe('RelayContainer.setVariables', function() { }).not.toThrow(); expect(mockCallback.mock.calls).toEqual([ - [{...defaultState, aborted: true, mounted: false}] + [{...defaultState, aborted: true, mounted: false}], ]); }); }); @@ -547,7 +547,7 @@ describe('RelayContainer.setVariables', function() { }, initialVariables: { site: undefined, - size: 48 + size: 48, } }); @@ -583,7 +583,7 @@ describe('RelayContainer.setVariables', function() { Relay.Store.primeCache.mock.requests[0].succeed(); expect(innerComponent.state.variables).toEqual({ site: 'mobile', - size: 32 + size: 32, }); mockInstance.setVariables({site: 'www'}); @@ -591,12 +591,12 @@ describe('RelayContainer.setVariables', function() { Relay.Store.primeCache.mock.requests[1].succeed(); expect(mockInstance.state.variables).toEqual({ - site: 'www' + site: 'www', }); expect(innerComponent.state.variables).toEqual({ site: 'www', - size: 48 + size: 48, }); }); }); diff --git a/src/container/__tests__/RelayRootContainer-test.js b/src/container/__tests__/RelayRootContainer-test.js index 2b8d63a3023a3..340275a8e09c9 100644 --- a/src/container/__tests__/RelayRootContainer-test.js +++ b/src/container/__tests__/RelayRootContainer-test.js @@ -60,7 +60,7 @@ describe('RelayRootContainer', function() { }, toBeShallowRenderedChild() { return ShallowRenderer.getRenderOutput().props.children === this.actual; - } + }, }); }); @@ -71,12 +71,12 @@ describe('RelayRootContainer', function() { /* jslint validthis: true */ RouteAwareComponent = React.createClass({ contextTypes: { - route: Relay.PropTypes.QueryConfig.isRequired + route: Relay.PropTypes.QueryConfig.isRequired, }, render: function() { this.props.onRender.call(this); return null; - } + }, }); var container = document.createElement('div'); jest.addMatchers({ @@ -96,7 +96,7 @@ describe('RelayRootContainer', function() { var mockRequests = RelayStore.primeCache.mock.requests; mockRequests[mockRequests.length - 1].block(); return context.route === route; - } + }, }); }); @@ -254,7 +254,7 @@ describe('RelayRootContainer', function() { ); expect(getRelayQueries.mock.calls).toEqual([ [RelayContainer, route], - [AnotherContainer, route] + [AnotherContainer, route], ]); expect(RelayStore.primeCache.mock.calls.length).toBe(2); }); @@ -266,7 +266,7 @@ describe('RelayRootContainer', function() { ); expect(getRelayQueries.mock.calls).toEqual([ [RelayContainer, route], - [RelayContainer, anotherRoute] + [RelayContainer, anotherRoute], ]); expect(RelayStore.primeCache.mock.calls.length).toBe(2); }); @@ -363,7 +363,7 @@ describe('RelayRootContainer', function() { var index = RelayStore.primeCache.mock.calls.length - 1; return { abort: RelayStore.primeCache.mock.abort[index], - request: RelayStore.primeCache.mock.requests[index] + request: RelayStore.primeCache.mock.requests[index], }; } jest.addMatchers({ @@ -378,7 +378,7 @@ describe('RelayRootContainer', function() { this.actual(request); ShallowRenderer.unmount(); return abort.mock.calls.length > 0; - } + }, }); }); @@ -438,12 +438,12 @@ describe('RelayRootContainer', function() { elements = { loading:
, resolve:
, - failure:
+ failure:
, }; callbacks = { renderLoading: jest.genMockFunction().mockReturnValue(elements.loading), renderFetched: jest.genMockFunction().mockReturnValue(elements.resolve), - renderFailure: jest.genMockFunction().mockReturnValue(elements.failure) + renderFailure: jest.genMockFunction().mockReturnValue(elements.failure), }; }); @@ -521,7 +521,7 @@ describe('RelayRootContainer', function() { var MockRoute = RelayRoute.genMock(); route = new MockRoute({ routeParam: '42', - viewer: 'this-will-be-overwritten' + viewer: 'this-will-be-overwritten', }); var data = null; @@ -563,15 +563,15 @@ describe('RelayRootContainer', function() { expect(callbacks.renderFetched.mock.calls.map(args => args[1])).toEqual([ { done: false, - stale: true + stale: true, }, { done: false, - stale: false + stale: false, }, { done: true, - stale: false + stale: false, } ]); }); @@ -663,7 +663,7 @@ describe('RelayRootContainer', function() { error: null, mounted: true, ready: false, - stale: false + stale: false, }; onReadyStateChange = jest.genMockFunction(); ShallowRenderer.render( @@ -683,7 +683,7 @@ describe('RelayRootContainer', function() { RelayStore.primeCache.mock.requests[0].block(); expect(onReadyStateChange.mock.calls).toEqual([ - [{...defaultState}] + [{...defaultState}], ]); }); @@ -693,7 +693,7 @@ describe('RelayRootContainer', function() { expect(onReadyStateChange.mock.calls).toEqual([ [{...defaultState, ready: false}], - [{...defaultState, ready: true}] + [{...defaultState, ready: true}], ]); }); @@ -705,7 +705,7 @@ describe('RelayRootContainer', function() { expect(onReadyStateChange.mock.calls).toEqual([ [{...defaultState, done: false, ready: false}], [{...defaultState, done: false, ready: true}], - [{...defaultState, done: true, ready: true}] + [{...defaultState, done: true, ready: true}], ]); }); @@ -715,7 +715,7 @@ describe('RelayRootContainer', function() { expect(onReadyStateChange.mock.calls).toEqual([ [{...defaultState, done: false, ready: true}], - [{...defaultState, done: true, ready: true}] + [{...defaultState, done: true, ready: true}], ]); }); @@ -728,7 +728,7 @@ describe('RelayRootContainer', function() { expect(onReadyStateChange.mock.calls).toEqual([ [{...defaultState, error: null, ready: false}], [{...defaultState, error: null, ready: true}], - [{...defaultState, error, ready: true}] + [{...defaultState, error, ready: true}], ]); }); @@ -739,7 +739,7 @@ describe('RelayRootContainer', function() { expect(onReadyStateChange.mock.calls).toEqual([ [{...defaultState, error: null}], - [{...defaultState, error}] + [{...defaultState, error}], ]); }); @@ -748,7 +748,7 @@ describe('RelayRootContainer', function() { RelayStore.primeCache.mock.requests[0].fail(error); expect(onReadyStateChange.mock.calls).toEqual([ - [{...defaultState, error}] + [{...defaultState, error}], ]); }); @@ -771,7 +771,7 @@ describe('RelayRootContainer', function() { jest.runAllTimers(); expect(onReadyStateChange.mock.calls).toEqual([ - [{...defaultState, aborted: true, mounted: false}] + [{...defaultState, aborted: true, mounted: false}], ]); }); }); diff --git a/src/container/__tests__/getRelayQueries-test.js b/src/container/__tests__/getRelayQueries-test.js index 52493cef80a26..57c3ef3a166f9 100644 --- a/src/container/__tests__/getRelayQueries-test.js +++ b/src/container/__tests__/getRelayQueries-test.js @@ -43,7 +43,7 @@ describe('getRelayQueries', () => { MockPageContainer = Relay.createContainer(MockPageComponent, { fragments: { first: () => Relay.QL`fragment on Node{id,firstName}`, - last: () => Relay.QL`fragment on Node{id,lastName}` + last: () => Relay.QL`fragment on Node{id,lastName}`, } }); @@ -55,7 +55,7 @@ describe('getRelayQueries', () => { id: { type: 'String', id: true - } + }, }; MockRoute.queries = { first: (Component, params) => Relay.QL` @@ -71,7 +71,7 @@ describe('getRelayQueries', () => { ${Component.getFragment('last')} } } - ` + `, }; return MockRoute; }; @@ -86,7 +86,7 @@ describe('getRelayQueries', () => { var expected = { first: getNode(Relay.QL`query{node(id:"123"){${Relay.QL`fragment on Node{id,firstName}`}}}`), - last: getNode(Relay.QL`query{node(id:"123"){${Relay.QL`fragment on Node{id,lastName}`}}}`) + last: getNode(Relay.QL`query{node(id:"123"){${Relay.QL`fragment on Node{id,lastName}`}}}`), }; expect(queries.first).toEqualQueryRoot(expected.first); @@ -103,7 +103,7 @@ describe('getRelayQueries', () => { expect(queries).toEqual({ first: null, - last: null + last: null, }); }); @@ -111,7 +111,7 @@ describe('getRelayQueries', () => { class BadRoute extends Relay.Route {} BadRoute.routeName = 'BadRoute'; BadRoute.queries = { - first: () => Relay.QL`fragment on Node{id}` + first: () => Relay.QL`fragment on Node{id}`, }; var badRoute = new BadRoute({}); diff --git a/src/legacy/query/GraphQL.js b/src/legacy/query/GraphQL.js index 2792b0d7e27d5..2b09579e7d834 100644 --- a/src/legacy/query/GraphQL.js +++ b/src/legacy/query/GraphQL.js @@ -45,7 +45,7 @@ var JSON_TYPES = { BATCH_VARIABLE: 7, MUTATION: 8, QUERY_WITH_VALUES: 9, - SUBSCRIPTION: 10 + SUBSCRIPTION: 10, }; /** @@ -267,7 +267,7 @@ class GraphQLFieldNode extends GraphQLNode { isPlural: !!metadata.plural, isRequisite: !!metadata.requisite, isUnionOrInterface: !!metadata.dynamic, - parentType: metadata.parentType + parentType: metadata.parentType, }; } @@ -386,7 +386,7 @@ class GraphQLQuery extends GraphQLNode { this.kind = QUERY; this.metadata = { ...this.__metadata__, - rootArg + rootArg, }; this.name = queryName; this.fieldName = rootCall; @@ -500,7 +500,7 @@ class GraphQLOperation extends GraphQLNode { this.calls[0], this.fields.length ? this.fields : null, this.fragments.length ? this.fragments : null, - this.metadata === EMPTY_OBJECT ? null : this.metadata + this.metadata === EMPTY_OBJECT ? null : this.metadata, ]); } } @@ -750,7 +750,7 @@ var GraphQL = { isMutation, isQuery, isQueryWithValues, - isSubscription + isSubscription, }; module.exports = GraphQL; diff --git a/src/legacy/store/DliteFetchModeConstants.js b/src/legacy/store/DliteFetchModeConstants.js index b555f232e0308..85b1915b329aa 100644 --- a/src/legacy/store/DliteFetchModeConstants.js +++ b/src/legacy/store/DliteFetchModeConstants.js @@ -17,7 +17,7 @@ var keyMirror = require('keyMirror'); var DliteFetchModeConstants = keyMirror({ FETCH_MODE_CLIENT: null, FETCH_MODE_PRELOAD: null, - FETCH_MODE_REFETCH: null + FETCH_MODE_REFETCH: null, }); module.exports = DliteFetchModeConstants; diff --git a/src/legacy/store/GraphQLDeferredQueryTracker.js b/src/legacy/store/GraphQLDeferredQueryTracker.js index 2542e71493286..a44925ba8570d 100644 --- a/src/legacy/store/GraphQLDeferredQueryTracker.js +++ b/src/legacy/store/GraphQLDeferredQueryTracker.js @@ -101,7 +101,7 @@ var GraphQLDeferredQueryTracker = { var subscriber = { callbacks, dataID, - fragmentID + fragmentID, }; subscribers.push(subscriber); return { @@ -399,7 +399,7 @@ function processBroadcasts() { var { dataID, error, - fragmentID + fragmentID, } = broadcastItems[jj]; var method; var args; diff --git a/src/legacy/store/GraphQLQueryRunner.js b/src/legacy/store/GraphQLQueryRunner.js index 111a03f963171..37382075aa120 100644 --- a/src/legacy/store/GraphQLQueryRunner.js +++ b/src/legacy/store/GraphQLQueryRunner.js @@ -11,8 +11,6 @@ * @flow */ - /* eslint no-unused-expressions: 1 */ - 'use strict'; var DliteFetchModeConstants = require('DliteFetchModeConstants'); @@ -121,7 +119,7 @@ var GraphQLQueryRunner = { var fetchMode = DliteFetchModeConstants.FETCH_MODE_REFETCH; return runQueries(queries, callback, fetchMode, profiler); - } + }, }; @@ -179,7 +177,7 @@ function runQueries( done: false, error: null, ready: false, - stale: false + stale: false, }; var scheduled = false; function setReadyState(partial: PartialReadyState): void { @@ -198,7 +196,7 @@ function runQueries( done: partial.done != null ? partial.done : readyState.done, error: partial.error != null ? partial.error : readyState.error, ready: partial.ready != null ? partial.ready : readyState.ready, - stale: partial.stale != null ? partial.stale : readyState.stale + stale: partial.stale != null ? partial.stale : readyState.stale, }; if (scheduled) { return; diff --git a/src/legacy/store/GraphQLRange.js b/src/legacy/store/GraphQLRange.js index c4a28dd2a434b..71116c584ff83 100644 --- a/src/legacy/store/GraphQLRange.js +++ b/src/legacy/store/GraphQLRange.js @@ -26,7 +26,7 @@ var { END_CURSOR, HAS_NEXT_PAGE, HAS_PREV_PAGE, - START_CURSOR + START_CURSOR, } = RelayConnectionInterface; /** @@ -756,7 +756,7 @@ class GraphQLRange { return { requestedEdgeIDs: [], diffCalls: [], - pageInfo: RelayConnectionInterface.getDefaultPageInfo() + pageInfo: RelayConnectionInterface.getDefaultPageInfo(), }; } if ((calls.first && calls.before) || (calls.last && calls.after)) { @@ -768,7 +768,7 @@ class GraphQLRange { return { requestedEdgeIDs: [], diffCalls: [], - pageInfo: RelayConnectionInterface.getDefaultPageInfo() + pageInfo: RelayConnectionInterface.getDefaultPageInfo(), }; } if (!isValidRangeCallValues(calls)) { @@ -779,7 +779,7 @@ class GraphQLRange { return { requestedEdgeIDs: [], diffCalls: [], - pageInfo: RelayConnectionInterface.getDefaultPageInfo() + pageInfo: RelayConnectionInterface.getDefaultPageInfo(), }; } if (calls.first) { @@ -811,8 +811,8 @@ class GraphQLRange { [START_CURSOR]: storedInfo.cursors[0], [END_CURSOR]: storedInfo.cursors[storedInfo.cursors.length - 1], [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: true - } + [HAS_PREV_PAGE]: true, + }, }; } @@ -821,7 +821,7 @@ class GraphQLRange { return { requestedEdgeIDs: [], diffCalls: queryCalls, - pageInfo: RelayConnectionInterface.getDefaultPageInfo() + pageInfo: RelayConnectionInterface.getDefaultPageInfo(), }; } @@ -860,7 +860,7 @@ class GraphQLRange { return { requestedEdgeIDs: [], diffCalls: [], - pageInfo: pageInfo + pageInfo: pageInfo, }; } segment = this._orderedSegments[segmentIndex]; @@ -925,7 +925,7 @@ class GraphQLRange { return { requestedEdgeIDs: requestedEdgeIDs, diffCalls: diffCalls, - pageInfo: pageInfo + pageInfo: pageInfo, }; } @@ -963,7 +963,7 @@ class GraphQLRange { return { requestedEdgeIDs: [], diffCalls: [], - pageInfo: pageInfo + pageInfo: pageInfo, }; } segment = this._orderedSegments[segmentIndex]; @@ -1028,7 +1028,7 @@ class GraphQLRange { return { requestedEdgeIDs: requestedEdgeIDs, diffCalls: diffCalls, - pageInfo: pageInfo + pageInfo: pageInfo, }; } diff --git a/src/legacy/store/GraphQLSegment.js b/src/legacy/store/GraphQLSegment.js index e8386d8f09476..caaf786324597 100644 --- a/src/legacy/store/GraphQLSegment.js +++ b/src/legacy/store/GraphQLSegment.js @@ -281,7 +281,7 @@ class GraphQLSegment { this._indexToMetadataMap[index] = { edgeID: edgeID, cursor: cursor, - deleted: false + deleted: false, }; this._idToIndicesMap[edgeID] = this._idToIndicesMap[edgeID] || []; this._idToIndicesMap[edgeID].unshift(index); @@ -495,7 +495,7 @@ class GraphQLSegment { return { count: this._count, maxIndex: this._maxIndex, - minIndex: this._minIndex + minIndex: this._minIndex, }; } diff --git a/src/legacy/store/GraphQLStoreChangeEmitter.js b/src/legacy/store/GraphQLStoreChangeEmitter.js index 9ba80667374e7..c68e54dac453c 100644 --- a/src/legacy/store/GraphQLStoreChangeEmitter.js +++ b/src/legacy/store/GraphQLStoreChangeEmitter.js @@ -131,7 +131,7 @@ function getBroadcastID(id: string): string { RelayProfiler.instrumentMethods(GraphQLStoreChangeEmitter, { addListenerForIDs: 'GraphQLStoreChangeEmitter.addListenerForIDs', broadcastChangeForID: 'GraphQLStoreChangeEmitter.broadcastChangeForID', - _processSubscribers: 'GraphQLStoreChangeEmitter.processSubscribers' + _processSubscribers: 'GraphQLStoreChangeEmitter.processSubscribers', }); module.exports = GraphQLStoreChangeEmitter; diff --git a/src/legacy/store/GraphQLStoreRangeUtils.js b/src/legacy/store/GraphQLStoreRangeUtils.js index 8d5a8fe238c56..c5d582cccd8c4 100644 --- a/src/legacy/store/GraphQLStoreRangeUtils.js +++ b/src/legacy/store/GraphQLStoreRangeUtils.js @@ -93,7 +93,7 @@ var GraphQLStoreRangeUtils = { */ getCanonicalClientID: function(dataID) { return rangeData[dataID] ? rangeData[dataID].dataID : dataID; - } + }, }; module.exports = GraphQLStoreRangeUtils; diff --git a/src/legacy/store/__mocks__/GraphQLStoreQueryResolver.js b/src/legacy/store/__mocks__/GraphQLStoreQueryResolver.js index 18d40932b503b..8ef3c90007d4a 100644 --- a/src/legacy/store/__mocks__/GraphQLStoreQueryResolver.js +++ b/src/legacy/store/__mocks__/GraphQLStoreQueryResolver.js @@ -16,7 +16,7 @@ class GraphQLStoreQueryResolver { this.mock = { callback, index: mockInstances.length, - queryFragment + queryFragment, }; this.resolve = jest.genMockFunction().mockImplementation((...args) => { var mockConstructor = GraphQLStoreQueryResolver.mock; diff --git a/src/legacy/store/__mocks__/GraphQLStoreTestUtils.js b/src/legacy/store/__mocks__/GraphQLStoreTestUtils.js index 1c98b18cb392f..1b23490e6dd9d 100644 --- a/src/legacy/store/__mocks__/GraphQLStoreTestUtils.js +++ b/src/legacy/store/__mocks__/GraphQLStoreTestUtils.js @@ -107,7 +107,7 @@ var GraphQLStoreTestUtils = { } return true; - } + }, }, /** * @param {GraphQLNode} node @@ -154,7 +154,7 @@ var GraphQLStoreTestUtils = { jest .dontMock('GraphQL') .dontMock('GraphQLFragmentPointer'); - } + }, }; module.exports = GraphQLStoreTestUtils; diff --git a/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js b/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js index 1fc6aa148d988..212e3d5ab05b4 100644 --- a/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js +++ b/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js @@ -68,7 +68,7 @@ describe('GraphQLDeferredQueryTracker', () => { fragmentID, { onSuccess: onSuccess, - onFailure: onFailure + onFailure: onFailure, } ); GraphQLDeferredQueryTracker.recordQuery(mockDeferred); @@ -103,7 +103,7 @@ describe('GraphQLDeferredQueryTracker', () => { dataID, fragmentID, { - onSuccess: onSuccess + onSuccess: onSuccess, } ); GraphQLDeferredQueryTracker.recordQuery(mockDeferred); diff --git a/src/legacy/store/__tests__/GraphQLQueryRunner-test.js b/src/legacy/store/__tests__/GraphQLQueryRunner-test.js index 2bccd1d2b45ab..fa36c43cb6dc0 100644 --- a/src/legacy/store/__tests__/GraphQLQueryRunner-test.js +++ b/src/legacy/store/__tests__/GraphQLQueryRunner-test.js @@ -61,7 +61,7 @@ describe('GraphQLQueryRunner', () => { splitDeferredRelayQueries.mockImplementation( query => ({ required: query, - deferred: [] + deferred: [], }) ); } @@ -85,7 +85,7 @@ describe('GraphQLQueryRunner', () => { warning = require('warning'); RelayNetworkLayer.injectNetworkLayer({ - supports: () => true + supports: () => true, }); mockCallback = jest.genMockFunction(); @@ -104,7 +104,7 @@ describe('GraphQLQueryRunner', () => { expect(mockCallback).not.toBeCalled(); jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: false, done: true, error: null, ready: true, stale: false}] + [{aborted: false, done: true, error: null, ready: true, stale: false}], ]); }); @@ -119,7 +119,7 @@ describe('GraphQLQueryRunner', () => { expect(diffQueryCalls[0][0]).toEqualQueryNode(mockQuerySet.foo); expect(diffQueryCalls[1][0]).toEqualQueryNode(mockQuerySet.bar); expect(mockCallback.mock.calls).toEqual([ - [{aborted: false, done: true, error: null, ready: true, stale: false}] + [{aborted: false, done: true, error: null, ready: true, stale: false}], ]); }); @@ -127,12 +127,12 @@ describe('GraphQLQueryRunner', () => { diffRelayQuery.mockImplementation(query => [query]); checkRelayQueryData.mockImplementation(() => false); RelayNetworkLayer.injectNetworkLayer({ - supports: () => false + supports: () => false, }); var fragment = Relay.QL`fragment on Node{id}`; var querySet = { - foo: getNode(Relay.QL`query{node(id:"123"){${defer(fragment)}}}`) + foo: getNode(Relay.QL`query{node(id:"123"){${defer(fragment)}}}`), }; warning.mockClear(); @@ -148,7 +148,7 @@ describe('GraphQLQueryRunner', () => { 'Relay: Query `%s` contains a deferred fragment (e.g. ' + '`getFragment(\'foo\').defer()`) which is not supported by the ' + 'default network layer. This query will be sent without deferral.', - querySet.foo.getName() + querySet.foo.getName(), ]); }); @@ -163,7 +163,7 @@ describe('GraphQLQueryRunner', () => { jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: false, done: false, error: null, ready: false, stale: false}] + [{aborted: false, done: false, error: null, ready: false, stale: false}], ]); }); @@ -191,7 +191,7 @@ describe('GraphQLQueryRunner', () => { RelayPendingQueryTracker.add.mock.fetches[0].resolve(); jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: false, done: false, error: null, ready: false, stale: false}] + [{aborted: false, done: false, error: null, ready: false, stale: false}], ]); RelayPendingQueryTracker.add.mock.fetches[1].resolve(); @@ -223,15 +223,15 @@ describe('GraphQLQueryRunner', () => { required: null, deferred: [{ required: deferQuery(query), - deferred: [] - }] + deferred: [], + }], })); GraphQLQueryRunner.run(mockQuerySet, mockCallback); jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: false, done: false, error: null, ready: true, stale: false}] + [{aborted: false, done: false, error: null, ready: true, stale: false}], ]); }); @@ -241,7 +241,7 @@ describe('GraphQLQueryRunner', () => { if (query.getRootCall().name === 'viewer') { return { required: query, - deferred: [] + deferred: [], }; } else { // Treat `mockQuerySet.bar` as deferred. @@ -249,8 +249,8 @@ describe('GraphQLQueryRunner', () => { query: null, deferred: [{ required: deferQuery(query), - deferred: [] - }] + deferred: [], + }], }; } }); @@ -263,7 +263,7 @@ describe('GraphQLQueryRunner', () => { expect(mockCallback.mock.calls).toEqual([ [{aborted: false, done: false, error: null, ready: false, stale: false}], - [{aborted: false, done: false, error: null, ready: true, stale: false}] + [{aborted: false, done: false, error: null, ready: true, stale: false}], ]); RelayPendingQueryTracker.add.mock.fetches[1].resolve(); @@ -282,7 +282,7 @@ describe('GraphQLQueryRunner', () => { jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: false, done: false, error: null, ready: false, stale: false}] + [{aborted: false, done: false, error: null, ready: false, stale: false}], ]); RelayPendingQueryTracker.add.mock.fetches[0].resolve(); @@ -291,7 +291,7 @@ describe('GraphQLQueryRunner', () => { expect(mockCallback.mock.calls).toEqual([ [{aborted: false, done: false, error: null, ready: false, stale: false}], - [{aborted: false, done: true, error: null, ready: true, stale: false}] + [{aborted: false, done: true, error: null, ready: true, stale: false}], ]); }); @@ -319,7 +319,7 @@ describe('GraphQLQueryRunner', () => { jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: true, done: false, error: null, ready: false, stale: false}] + [{aborted: true, done: false, error: null, ready: false, stale: false}], ]); }); @@ -335,7 +335,7 @@ describe('GraphQLQueryRunner', () => { jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: true, done: false, error: null, ready: false, stale: false}] + [{aborted: true, done: false, error: null, ready: false, stale: false}], ]); }); @@ -372,7 +372,7 @@ describe('GraphQLQueryRunner', () => { jest.runAllTimers(); expect(mockCallback.mock.calls).toEqual([ - [{aborted: true, done: false, error: null, ready: false, stale: false}] + [{aborted: true, done: false, error: null, ready: false, stale: false}], ]); }); @@ -402,7 +402,7 @@ describe('GraphQLQueryRunner', () => { expect(mockCallback.mock.calls).toEqual([ [{aborted: false, done: false, error: null, ready: false, stale: false}], - [{aborted: false, done: false, error: null, ready: true, stale: true}] + [{aborted: false, done: false, error: null, ready: true, stale: true}], ]); expect(RelayPendingQueryTracker.add.mock.calls.length).toBe(1); @@ -452,10 +452,10 @@ describe('GraphQLQueryRunner', () => { query { viewer{actor{id,lastName}} } - ` + `, ].map(query => ({ required: deferQuery(getNode(query)), - deferred: [] + deferred: [], })) }; @@ -482,13 +482,13 @@ describe('GraphQLQueryRunner', () => { done: false, error: null, ready: false, - stale: false + stale: false, }; // Only called once after both splitQuery#0 and splitQuery#1. expect(mockCallback.mock.calls).toEqual([ [{...defaultState}], - [{...defaultState, ready: true}] + [{...defaultState, ready: true}], ]); resolveSplitQueryByIndex(2); @@ -499,7 +499,7 @@ describe('GraphQLQueryRunner', () => { expect(mockCallback.mock.calls).toEqual([ [{...defaultState, ready: false}], [{...defaultState, ready: true}], - [{...defaultState, ready: true}] + [{...defaultState, ready: true}], ]); resolveSplitQueryByIndex(4); diff --git a/src/legacy/store/__tests__/GraphQLRange-test.js b/src/legacy/store/__tests__/GraphQLRange-test.js index 784a8f66867fc..5a3413fb453a7 100644 --- a/src/legacy/store/__tests__/GraphQLRange-test.js +++ b/src/legacy/store/__tests__/GraphQLRange-test.js @@ -128,7 +128,7 @@ describe('GraphQLRange', () => { it('should add for after().first() query', () => { var queryCalls = [ {name: 'after', value: null}, - {name: 'first', value: 3} + {name: 'first', value: 3}, ]; var pageInfo = { [HAS_NEXT_PAGE]: true, @@ -149,7 +149,7 @@ describe('GraphQLRange', () => { queryCalls = [ {name: 'after', value: 'cursor3'}, - {name: 'first', value: 2} + {name: 'first', value: 2}, ]; range.addItems( queryCalls, @@ -160,7 +160,7 @@ describe('GraphQLRange', () => { // Request the full set queryCalls = [ {name: 'after', value: null}, - {name: 'first', value: 5} + {name: 'first', value: 5}, ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -177,7 +177,7 @@ describe('GraphQLRange', () => { it('should add for after().first() query in last segment', () => { var queryCalls = [ - {name: 'last', value: 3} + {name: 'last', value: 3}, ]; var pageInfo = { [HAS_NEXT_PAGE]: false, @@ -204,7 +204,7 @@ describe('GraphQLRange', () => { // Request the full set queryCalls = [ - {name: 'last', value: 5} + {name: 'last', value: 5}, ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -467,7 +467,7 @@ describe('GraphQLRange', () => { it('should add for after().last() with gap', () => { var queryCalls = [ {name: 'after', value: null}, - {name: 'last', value: 3} + {name: 'last', value: 3}, ]; var pageInfo = { @@ -490,7 +490,7 @@ describe('GraphQLRange', () => { // Request the super set queryCalls = [ {name: 'after', value: null}, - {name: 'last', value: 5} + {name: 'last', value: 5}, ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -585,7 +585,7 @@ describe('GraphQLRange', () => { it('should retrieve for after().first() queries', () => { var queryCalls = [ {name: 'after', value: null}, - {name: 'first', value: 3} + {name: 'first', value: 3}, ]; var pageInfo = { @@ -602,7 +602,7 @@ describe('GraphQLRange', () => { // Request a subset with after queryCalls = [ {name: 'after', value: 'cursor1'}, - {name: 'first', value: 2} + {name: 'first', value: 2}, ]; var result = range.retrieveRangeInfoForQuery(queryCalls); @@ -633,7 +633,7 @@ describe('GraphQLRange', () => { // Request a non-intersecting superset with after queryCalls = [ {name: 'after', value: 'cursor3'}, - {name: 'first', value: 2} + {name: 'first', value: 2}, ]; result = range.retrieveRangeInfoForQuery(queryCalls); @@ -648,7 +648,7 @@ describe('GraphQLRange', () => { it('should retrieve for last() queries', () => { var queryCalls = [ - {name: 'last', value: 3} + {name: 'last', value: 3}, ]; // Request the from empty range @@ -859,7 +859,7 @@ describe('GraphQLRange', () => { it('should support calls with no arguments', () => { var queryCalls = [ {name: 'first', value: 3}, - {name: 'dummy_call', value: null} + {name: 'dummy_call', value: null}, ]; var pageInfo = { @@ -872,7 +872,7 @@ describe('GraphQLRange', () => { // Request the full set var result = range.retrieveRangeInfoForQuery([ {name: 'first', value: 3}, - {name: 'dummy_call', value: null} + {name: 'dummy_call', value: null}, ]); expect(result.requestedEdgeIDs).toEqual( @@ -1115,7 +1115,7 @@ describe('GraphQLRange', () => { it('should add and retrieve for surrounds() query', () => { var queryCalls = [ - {name: 'surrounds', value: ['id2', 1]} + {name: 'surrounds', value: ['id2', 1]}, ]; var pageInfo = { @@ -1134,7 +1134,7 @@ describe('GraphQLRange', () => { it('should not return surrounds query data for first query', () => { var surroundQueryCalls = [ - {name: 'surrounds', value: ['id2', 1]} + {name: 'surrounds', value: ['id2', 1]}, ]; var pageInfo = { @@ -1555,7 +1555,7 @@ describe('GraphQLRange', () => { var nullCursorEdges = [ edgeWithNullCursor1, edgeWithNullCursor2, - edgeWithNullCursor3 + edgeWithNullCursor3, ]; range.addItems(queryCalls, nullCursorEdges, pageInfo); @@ -1564,7 +1564,7 @@ describe('GraphQLRange', () => { expect(result.requestedEdgeIDs).toEqual([ 'edgeWithNullCursor1', 'edgeWithNullCursor2', - 'edgeWithNullCursor3' + 'edgeWithNullCursor3', ]); expect(result.diffCalls).toEqual(five); }); @@ -1575,13 +1575,13 @@ describe('GraphQLRange', () => { ]; var pageInfo = { - [HAS_NEXT_PAGE]: true + [HAS_NEXT_PAGE]: true, }; var nullCursorEdges = [ edgeWithNullCursor1, edgeWithNullCursor2, - edgeWithNullCursor3 + edgeWithNullCursor3, ]; // we don't replace empty ranges @@ -1604,7 +1604,7 @@ describe('GraphQLRange', () => { var cursorEdges = [ edge0, edge1, - edge2 + edge2, ]; range = new GraphQLRange(); segment = getFirstSegment(range); @@ -1620,13 +1620,13 @@ describe('GraphQLRange', () => { ]; var pageInfo = { - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }; var nullCursorEdges = [ edgeWithNullCursor1, edgeWithNullCursor2, - edgeWithNullCursor3 + edgeWithNullCursor3, ]; // we don't replace empty ranges @@ -1649,7 +1649,7 @@ describe('GraphQLRange', () => { var cursorEdges = [ edge0, edge1, - edge2 + edge2, ]; range = new GraphQLRange(); segment = getLastSegment(range); @@ -1671,14 +1671,14 @@ describe('GraphQLRange', () => { var nullCursorEdges = [ edgeWithNullCursor1, edgeWithNullCursor2, - edgeWithNullCursor3 + edgeWithNullCursor3, ]; range.addItems(three, nullCursorEdges, pageInfo); var result = range.retrieveRangeInfoForQuery(two); expect(result.requestedEdgeIDs).toEqual([ 'edgeWithNullCursor1', - 'edgeWithNullCursor2' + 'edgeWithNullCursor2', ]); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(true); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(false); @@ -1687,7 +1687,7 @@ describe('GraphQLRange', () => { expect(result.requestedEdgeIDs).toEqual([ 'edgeWithNullCursor1', 'edgeWithNullCursor2', - 'edgeWithNullCursor3' + 'edgeWithNullCursor3', ]); expect(result.pageInfo[HAS_NEXT_PAGE]).toBe(false); expect(result.pageInfo[HAS_PREV_PAGE]).toBe(false); @@ -1930,7 +1930,7 @@ describe('GraphQLRange', () => { it('returns the DataIDs of all edges', () => { // Add a static edges var surroundQueryCalls = [ - {name: 'surrounds', value: ['id2', 1]} + {name: 'surrounds', value: ['id2', 1]}, ]; var pageInfo = { [HAS_NEXT_PAGE]: false, @@ -1950,7 +1950,7 @@ describe('GraphQLRange', () => { edge2.__dataID__, edge3.__dataID__, edge98.__dataID__, - edge99.__dataID__ + edge99.__dataID__, ]); }); }); diff --git a/src/legacy/store/__tests__/GraphQLStoreQueryResolver-test.js b/src/legacy/store/__tests__/GraphQLStoreQueryResolver-test.js index 3a995dcdaa9eb..accc8e52fc535 100644 --- a/src/legacy/store/__tests__/GraphQLStoreQueryResolver-test.js +++ b/src/legacy/store/__tests__/GraphQLStoreQueryResolver-test.js @@ -34,7 +34,7 @@ describe('GraphQLStoreQueryResolver', () => { readRelayQueryData.mockImplementation((_, __, dataID) => { return { dataIDs: {[dataID]: true}, - data: mockResult[dataID] + data: mockResult[dataID], }; }); } @@ -83,7 +83,7 @@ describe('GraphQLStoreQueryResolver', () => { mockQueryFragment ); var mockResult = { - '1038750002': {__dataID__: '1038750002', id: '1038750002', name: 'Tim'} + '1038750002': {__dataID__: '1038750002', id: '1038750002', name: 'Tim'}, }; mockReader(mockResult); @@ -158,7 +158,7 @@ describe('GraphQLStoreQueryResolver', () => { mockQueryFragment ); var mockResult = { - '1038750002': {__dataID__: '1038750002', id: '1038750002', name: 'Tim'} + '1038750002': {__dataID__: '1038750002', id: '1038750002', name: 'Tim'}, }; var resolver = new GraphQLStoreQueryResolver( @@ -348,11 +348,11 @@ describe('GraphQLStoreQueryResolver', () => { ); var mockResult = { __dataID__: 'chris', - address: {__dataID__: 'address', city: 'menlo park'} + address: {__dataID__: 'address', city: 'menlo park'}, }; readRelayQueryData.mockReturnValue({ data: mockResult, - dataIDs: { chris: true, address: true } + dataIDs: { chris: true, address: true }, }); var resolver = new GraphQLStoreQueryResolver( @@ -366,18 +366,17 @@ describe('GraphQLStoreQueryResolver', () => { GraphQLStoreChangeEmitter.addListenerForIDs.mock.calls[0][1]; // On first resolve we get data for all added ids expect(getIncreaseSubscriptionsParameters(2)).toEqual([ - 'address', - 'chris' + 'address', 'chris' ]); // New mock data for the resolve mockResult = { __dataID__: 'chris', - birthdate: {__dataID__: 'date', day: 15} + birthdate: {__dataID__: 'date', day: 15}, }; readRelayQueryData.mockReturnValue({ data: mockResult, - dataIDs: { chris: true, date: true } + dataIDs: { chris: true, date: true }, }); // Notify resolve that data has changed callback(['chris']); diff --git a/src/mutation/RelayMutation.js b/src/mutation/RelayMutation.js index fb3041d180921..294f68c5081cf 100644 --- a/src/mutation/RelayMutation.js +++ b/src/mutation/RelayMutation.js @@ -332,7 +332,7 @@ class RelayMutation { if (processQueryParams && !this.prepareVariables) { RelayDeprecated.warn({ was: this.name + '.getQuery', - now: this.name + '.getFragment' + now: this.name + '.getFragment', }); this.prepareVariables = (prevVariables, route) => processQueryParams(route, prevVariables); @@ -360,7 +360,7 @@ class RelayMutation { static getQuery(): RelayFragmentReference { RelayDeprecated.warn({ was: this.name + '.getQuery', - now: this.name + '.getFragment' + now: this.name + '.getFragment', }); return this.getFragment.apply(this, arguments); } diff --git a/src/mutation/RelayMutationQuery.js b/src/mutation/RelayMutationQuery.js index 69e3692c8e716..c69a75ff5bab2 100644 --- a/src/mutation/RelayMutationQuery.js +++ b/src/mutation/RelayMutationQuery.js @@ -269,8 +269,8 @@ var RelayMutationQuery = { var children = [ nullthrows(RelayMutationQuery.buildFragmentForOptimisticUpdate({ response, - fatQuery - })) + fatQuery, + })), ]; // TODO: Can this method ever return null? Task #7705258. return nullthrows(flattenRelayQuery(RelayQuery.Node.buildMutation( @@ -333,7 +333,7 @@ var RelayMutationQuery = { parentID: config.parentID, parentName: config.parentName, rangeBehaviors: config.rangeBehaviors, - tracker + tracker, })); break; @@ -344,7 +344,7 @@ var RelayMutationQuery = { fatQuery, parentID: config.parentID, parentName: config.parentName, - tracker + tracker, })); children.push(RelayQuery.Node.buildField(config.deletedIDFieldName)); break; @@ -353,7 +353,7 @@ var RelayMutationQuery = { children.push(RelayMutationQuery.buildFragmentForFields({ fatQuery, fieldIDs: config.fieldIDs, - tracker + tracker, })); break; } @@ -417,7 +417,7 @@ function buildEdgeField( edgeFields: Array ): RelayQuery.Field { var fields = [ - RelayQuery.Node.buildField('cursor') + RelayQuery.Node.buildField('cursor'), ]; if (RelayConnectionInterface.EDGES_HAVE_SOURCE_FIELD && !GraphQLStoreDataHandler.isClientID(parentID)) { diff --git a/src/mutation/RelayMutationTransaction.js b/src/mutation/RelayMutationTransaction.js index 1606c8ff752be..c67b2ba2e47ea 100644 --- a/src/mutation/RelayMutationTransaction.js +++ b/src/mutation/RelayMutationTransaction.js @@ -197,7 +197,7 @@ class RelayMutationTransaction { configs: this._getConfigs(), fatQuery: this._getFatQuery(), mutationName: this._mutation.constructor.name, - mutation: this._getMutationNode() + mutation: this._getMutationNode(), }); } return this._query; @@ -208,7 +208,7 @@ class RelayMutationTransaction { var input = { ...this._mutation.getVariables(), /* $FlowIssue #7728187 - Computed Property */ - [CLIENT_MUTATION_ID]: this._id + [CLIENT_MUTATION_ID]: this._id, }; this._variables = {input}; } @@ -239,14 +239,14 @@ class RelayMutationTransaction { configs: optimisticConfigs, fatQuery: this._getFatQuery(), mutationName: this._mutation.constructor.name, - mutation: this._getMutationNode() + mutation: this._getMutationNode(), }); } else { this._optimisticQuery = RelayMutationQuery.buildQueryForOptimisticUpdate({ response: optimisticResponse, fatQuery: this._getFatQuery(), - mutation: this._getMutationNode() + mutation: this._getMutationNode(), }); } } else { diff --git a/src/mutation/RelayMutationTransactionStatus.js b/src/mutation/RelayMutationTransactionStatus.js index 03d1926d91352..c42fd4cbec078 100644 --- a/src/mutation/RelayMutationTransactionStatus.js +++ b/src/mutation/RelayMutationTransactionStatus.js @@ -43,7 +43,7 @@ var RelayMutationTransactionStatus = { /** * Transaction was sent to the server for comitting but was failed. */ - COMMIT_FAILED: 'COMMIT_FAILED' + COMMIT_FAILED: 'COMMIT_FAILED', }; module.exports = RelayMutationTransactionStatus; diff --git a/src/mutation/RelayMutationType.js b/src/mutation/RelayMutationType.js index 5d8695a3aa715..144985fa99a83 100644 --- a/src/mutation/RelayMutationType.js +++ b/src/mutation/RelayMutationType.js @@ -18,7 +18,7 @@ var RelayMutationType = { NODE_DELETE: 'NODE_DELETE', RANGE_ADD: 'RANGE_ADD', RANGE_DELETE: 'RANGE_DELETE', - REQUIRED_CHILDREN: 'REQUIRED_CHILDREN' + REQUIRED_CHILDREN: 'REQUIRED_CHILDREN', }; module.exports = RelayMutationType; diff --git a/src/mutation/__tests__/RelayMutation-test.js b/src/mutation/__tests__/RelayMutation-test.js index 0976503c5971d..25633f71a30da 100644 --- a/src/mutation/__tests__/RelayMutation-test.js +++ b/src/mutation/__tests__/RelayMutation-test.js @@ -50,7 +50,7 @@ describe('RelayMutation', function() { fragment on Node { id, } - ` + `, }; return MockMutationClass; }; @@ -69,7 +69,7 @@ describe('RelayMutation', function() { it('resolves props', () => { new MockMutation({ bar: mockBarPointer, - foo: mockFooPointer + foo: mockFooPointer, }); expect(Relay.Store.read.mock.calls.length).toBe(2); @@ -84,7 +84,7 @@ describe('RelayMutation', function() { it('throws if mutation defines invalid `Relay.QL` fragment', () => { class BadMutation extends Relay.Mutation {} BadMutation.fragments = { - foo: () => Relay.QL`query{node(id:"123"){id}}` + foo: () => Relay.QL`query{node(id:"123"){id}}`, }; var badFragmentReference = BadMutation.getFragment('foo'); expect(() => { diff --git a/src/mutation/__tests__/RelayMutationQuery-test.js b/src/mutation/__tests__/RelayMutationQuery-test.js index 53022d6c03d03..2bb0198d707fc 100644 --- a/src/mutation/__tests__/RelayMutationQuery-test.js +++ b/src/mutation/__tests__/RelayMutationQuery-test.js @@ -180,7 +180,7 @@ describe('RelayMutationQuery', () => { }, seenState } - `) + `), }; tracker.getTrackedChildrenForID.mockImplementation( dataID => [trackedNodes[dataID]] @@ -234,7 +234,7 @@ describe('RelayMutationQuery', () => { tracker, connectionName: 'comments', parentID: '123', - parentName: 'story' + parentName: 'story', }); }).toFailInvariant( 'RelayMutationQuery: Invalid field name on fat query, `story`.' @@ -262,7 +262,7 @@ describe('RelayMutationQuery', () => { tracker, connectionName: 'comments', parentID: '123', - parentName: 'feedback' + parentName: 'feedback', }); var expected = getNodeWithoutSource(Relay.QL` fragment on CommentDeleteResponsePayload { @@ -282,6 +282,7 @@ describe('RelayMutationQuery', () => { }); describe('edge insertion', () => { + var GraphQLMutatorConstants; var fatQuery, rangeBehaviors; beforeEach(() => { @@ -303,7 +304,7 @@ describe('RelayMutationQuery', () => { `); rangeBehaviors = { '': GraphQLMutatorConstants.PREPEND, - 'orderby(toplevel)': GraphQLMutatorConstants.PREPEND + 'orderby(toplevel)': GraphQLMutatorConstants.PREPEND, }; }); @@ -601,11 +602,11 @@ describe('RelayMutationQuery', () => { id: '1', likers: { count: 4 - } - } + }, + }, }, fatQuery, - mutation + mutation, }); var variables = {input: ''}; @@ -662,7 +663,7 @@ describe('RelayMutationQuery', () => { var connectionName = 'comments'; var edgeName = 'feedbackCommentEdge'; var rangeBehaviors = { - '': GraphQLMutatorConstants.PREPEND + '': GraphQLMutatorConstants.PREPEND, }; var configs = [ { @@ -671,8 +672,8 @@ describe('RelayMutationQuery', () => { parentID, connectionName, edgeName, - rangeBehaviors - } + rangeBehaviors, + }, ]; var mutation = Relay.QL`mutation{commentCreate(input:$input)}`; @@ -683,7 +684,7 @@ describe('RelayMutationQuery', () => { fatQuery, configs, mutationName, - mutation + mutation, }); var expectedMutationQuery = getNodeWithoutSource(Relay.QL` @@ -745,8 +746,8 @@ describe('RelayMutationQuery', () => { parentName, parentID, connectionName, - deletedIDFieldName - } + deletedIDFieldName, + }, ]; var mutation = Relay.QL`mutation{commentDelete(input:$input)}`; @@ -757,7 +758,7 @@ describe('RelayMutationQuery', () => { fatQuery, configs, mutationName, - mutation + mutation, }); var expectedMutationQuery = getNodeWithoutSource(Relay.QL` @@ -808,8 +809,8 @@ describe('RelayMutationQuery', () => { parentName, parentID, connectionName, - deletedIDFieldName - } + deletedIDFieldName, + }, ]; var mutation = Relay.QL`mutation{commentDelete(input:$input)}`; @@ -820,7 +821,7 @@ describe('RelayMutationQuery', () => { fatQuery, configs, mutationName, - mutation + mutation, }); var expectedMutationQuery = getNodeWithoutSource(Relay.QL` @@ -855,13 +856,13 @@ describe('RelayMutationQuery', () => { } `); var fieldIDs = { - feedback: '123' + feedback: '123', }; var configs = [ { type: RelayMutationType.FIELDS_CHANGE, - fieldIDs - } + fieldIDs, + }, ]; var mutation = Relay.QL`mutation{feedbackLike(input:$input)}`; @@ -872,7 +873,7 @@ describe('RelayMutationQuery', () => { fatQuery, configs, mutationName, - mutation + mutation, }); var expectedMutationQuery = getNodeWithoutSource(Relay.QL` @@ -923,7 +924,7 @@ describe('RelayMutationQuery', () => { var connectionName = 'comments'; var edgeName = 'feedbackCommentEdge'; var rangeBehaviors = { - '': GraphQLMutatorConstants.PREPEND + '': GraphQLMutatorConstants.PREPEND, }; var configs = [ { @@ -932,7 +933,7 @@ describe('RelayMutationQuery', () => { parentID, connectionName, edgeName, - rangeBehaviors + rangeBehaviors, }, { type: RelayMutationType.REQUIRED_CHILDREN, @@ -942,7 +943,7 @@ describe('RelayMutationQuery', () => { doesViewerLike, }, } - `] + `], } ]; @@ -954,7 +955,7 @@ describe('RelayMutationQuery', () => { fatQuery, configs, mutationName, - mutation + mutation, }); var expectedMutationQuery = getNodeWithoutSource(Relay.QL` @@ -1022,10 +1023,10 @@ describe('RelayMutationQuery', () => { var connectionName = 'comments'; var edgeName = 'feedbackCommentEdge'; var rangeBehaviors = { - '': GraphQLMutatorConstants.PREPEND + '': GraphQLMutatorConstants.PREPEND, }; var fieldIDs = { - feedback: '123' + feedback: '123', }; var configs = [ { @@ -1038,8 +1039,8 @@ describe('RelayMutationQuery', () => { }, { type: RelayMutationType.FIELDS_CHANGE, - fieldIDs - } + fieldIDs, + }, ]; var mutation = Relay.QL`mutation{commentCreate(input:$input)}`; @@ -1050,7 +1051,7 @@ describe('RelayMutationQuery', () => { fatQuery, configs, mutationName, - mutation + mutation, }); var expectedMutationQuery = getNodeWithoutSource(Relay.QL` diff --git a/src/mutation/__tests__/RelayMutationTransaction-test.js b/src/mutation/__tests__/RelayMutationTransaction-test.js index 68be451021d22..9d31e743e9955 100644 --- a/src/mutation/__tests__/RelayMutationTransaction-test.js +++ b/src/mutation/__tests__/RelayMutationTransaction-test.js @@ -85,12 +85,12 @@ describe('RelayMutationTransaction', () => { configs: 'optimisticConfigs', fatQuery: 'fatQuery', mutation: mutationNode, - mutationName: 'RelayMutation' + mutationName: 'RelayMutation', }]]); expect(storeData.handleUpdatePayload.mock.calls).toEqual([[ 'optimisticQuery', {[RelayConnectionInterface.CLIENT_MUTATION_ID]: '0'}, - {configs: 'optimisticConfigs', isOptimisticUpdate: true} + {configs: 'optimisticConfigs', isOptimisticUpdate: true}, ]]); }); @@ -108,13 +108,13 @@ describe('RelayMutationTransaction', () => { fatQuery: 'fatQuery', mutation: mutationNode, response: { - [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0' - } + [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', + }, }]]); expect(storeData.handleUpdatePayload.mock.calls).toEqual([[ 'optimisticQuery', {[RelayConnectionInterface.CLIENT_MUTATION_ID]: '0'}, - {configs: 'configs', isOptimisticUpdate: true} + {configs: 'configs', isOptimisticUpdate: true}, ]]); }); }); @@ -413,7 +413,7 @@ describe('RelayMutationTransaction', () => { ); transaction1.commit({ onSuccess: successCallback1, - onFailure: failureCallback1 + onFailure: failureCallback1, }); expect(RelayNetworkLayer.sendMutation.mock.calls.length).toBe(1); diff --git a/src/network-layer/default/RelayDefaultNetworkLayer.js b/src/network-layer/default/RelayDefaultNetworkLayer.js index 83eb89d29ca77..a95803fda585c 100644 --- a/src/network-layer/default/RelayDefaultNetworkLayer.js +++ b/src/network-layer/default/RelayDefaultNetworkLayer.js @@ -122,17 +122,17 @@ class RelayDefaultNetworkLayer { } init = { body: formData, - method: 'POST' + method: 'POST', }; } else { init = { body: JSON.stringify({ query: request.getQueryString(), - variables: request.getVariables() + variables: request.getVariables(), }), credentials: 'same-origin', headers: {'Content-Type': 'application/json'}, - method: 'POST' + method: 'POST', }; } return fetch(this._uri, init).then(throwOnServerError); @@ -145,13 +145,13 @@ class RelayDefaultNetworkLayer { return fetchWithRetries(this._uri, { body: JSON.stringify({ query: request.getQueryString(), - variables: request.getVariables() + variables: request.getVariables(), }), credentials: 'same-origin', fetchTimeout: this._timeout, headers: {'Content-Type': 'application/json'}, method: 'POST', - retryDelays: this._retryDelays + retryDelays: this._retryDelays, }); } } diff --git a/src/network-layer/default/__tests__/RelayDefaultNetworkLayer-test.js b/src/network-layer/default/__tests__/RelayDefaultNetworkLayer-test.js index ab7c674eda9a2..74af593ac37b7 100644 --- a/src/network-layer/default/__tests__/RelayDefaultNetworkLayer-test.js +++ b/src/network-layer/default/__tests__/RelayDefaultNetworkLayer-test.js @@ -33,7 +33,7 @@ describe('RelayDefaultNetworkLayer', () => { function genResponse(data) { return { json: () => Promise.resolve(data), - status: 200 + status: 200, }; } @@ -55,7 +55,7 @@ describe('RelayDefaultNetworkLayer', () => { networkConfig = { uri: '/graphql', timeout: 15000, - retryDelays: [1000, 3000] + retryDelays: [1000, 3000], }; // Spread properties to test that functions are bound correctly. networkLayer = { @@ -63,7 +63,7 @@ describe('RelayDefaultNetworkLayer', () => { networkConfig.uri, networkConfig.timeout, networkConfig.retryDelays - ) + ), }; jest.addMatchers(RelayTestUtils.matchers); @@ -89,8 +89,8 @@ describe('RelayDefaultNetworkLayer', () => { variables = { input: { [RelayConnectionInterface.CLIENT_MUTATION_ID]: 'client:a', - actor_id: 4 - } + actor_id: 4, + }, }; request = new RelayMutationRequest(mutation, variables); request.getPromise().then(responseCallback).catch(rejectCallback); @@ -111,7 +111,7 @@ describe('RelayDefaultNetworkLayer', () => { }); expect(body).toEqual(JSON.stringify({ query: request.getQueryString(), - variables: variables + variables: variables, })); }); @@ -120,8 +120,8 @@ describe('RelayDefaultNetworkLayer', () => { data: { test_call: { field: 1 - } - } + }, + }, }; expect(fetch).not.toBeCalled(); @@ -134,7 +134,7 @@ describe('RelayDefaultNetworkLayer', () => { expect(rejectCallback.mock.calls.length).toBe(0); expect(responseCallback.mock.calls.length).toBe(1); expect(responseCallback.mock.calls[0][0]).toEqual({ - response: response.data + response: response.data, }); }); @@ -144,9 +144,9 @@ describe('RelayDefaultNetworkLayer', () => { message: 'Something went wrong.', locations: [{ column: 10, - line: 1 - }] - }] + line: 1, + }], + }], }; expect(fetch).not.toBeCalled(); @@ -165,7 +165,7 @@ describe('RelayDefaultNetworkLayer', () => { '', '1. Something went wrong.', ' ' + request.getQueryString().substr(0, 60), - ' ^^^' + ' ^^^', ].join('\n')); expect(error.source).toEqual(response); }); @@ -195,7 +195,7 @@ describe('RelayDefaultNetworkLayer', () => { var {body, fetchTimeout, method, retryDelays} = call[1]; expect(body).toBe(JSON.stringify({ query: requestA.getQueryString(), - variables: queryA.getVariables() + variables: queryA.getVariables(), })); expect(fetchTimeout).toBe(networkConfig.timeout); expect(method).toBe('POST'); @@ -211,10 +211,10 @@ describe('RelayDefaultNetworkLayer', () => { jest.runAllTimers(); var payloadA = { - data: {'123': {id: '123'}} + data: {'123': {id: '123'}}, }; var payloadB = { - data: {'456': {id: '456'}} + data: {'456': {id: '456'}}, }; fetchWithRetries.mock.deferreds[0].resolve(genResponse(payloadA)); fetchWithRetries.mock.deferreds[1].resolve(genResponse(payloadB)); @@ -222,11 +222,11 @@ describe('RelayDefaultNetworkLayer', () => { expect(resolveACallback.mock.calls.length).toBe(1); expect(resolveACallback.mock.calls[0][0]).toEqual({ - response: payloadA.data + response: payloadA.data, }); expect(resolveBCallback.mock.calls.length).toBe(1); expect(resolveBCallback.mock.calls[0][0]).toEqual({ - response: payloadB.data + response: payloadB.data, }); }); @@ -238,7 +238,7 @@ describe('RelayDefaultNetworkLayer', () => { fetchWithRetries.mock.deferreds[0].resolve({ json: () => Promise.reject(JSON.parse('{ // invalid')), - status: 200 + status: 200, }); jest.runAllTimers(); @@ -260,9 +260,9 @@ describe('RelayDefaultNetworkLayer', () => { message: 'Something went wrong.', locations: [{ column: 7, - line: 1 - }] - }] + line: 1, + }], + }], }; fetchWithRetries.mock.deferreds[0].resolve(genResponse(payloadA)); jest.runAllTimers(); @@ -275,7 +275,7 @@ describe('RelayDefaultNetworkLayer', () => { '', '1. Something went wrong.', ' ' + requestA.getQueryString().substr(0, 60), - ' ^^^' + ' ^^^', ].join('\n')); expect(error.source).toEqual(payloadA); }); @@ -289,7 +289,7 @@ describe('RelayDefaultNetworkLayer', () => { jest.runAllTimers(); var payload = { - data: {'456': {id: '456'}} + data: {'456': {id: '456'}}, }; fetchWithRetries.mock.deferreds[0].resolve(genResponse({})); fetchWithRetries.mock.deferreds[1].resolve(genResponse(payload)); diff --git a/src/network/__mocks__/fetchRelayQuery.js b/src/network/__mocks__/fetchRelayQuery.js index fb78241f1742b..39ec68bad1bfc 100644 --- a/src/network/__mocks__/fetchRelayQuery.js +++ b/src/network/__mocks__/fetchRelayQuery.js @@ -34,7 +34,7 @@ function genMockRequest(resolve, reject) { resolve(response, error) { resolve({error: error || null, response}); }, - reject + reject, }); } diff --git a/src/network/__tests__/RelayNetworkLayer-test.js b/src/network/__tests__/RelayNetworkLayer-test.js index 78d7d104807ae..ed28d42aa2281 100644 --- a/src/network/__tests__/RelayNetworkLayer-test.js +++ b/src/network/__tests__/RelayNetworkLayer-test.js @@ -32,7 +32,7 @@ describe('RelayNetworkLayer', () => { injectedNetworkLayer = { sendMutation: jest.genMockFunction(), sendQueries: jest.genMockFunction(), - supports: jest.genMockFunction() + supports: jest.genMockFunction(), }; RelayNetworkLayer.injectNetworkLayer(injectedNetworkLayer); diff --git a/src/query/RelayQL.js b/src/query/RelayQL.js index 7e57f1e197a3d..5f8ce96f2e737 100644 --- a/src/query/RelayQL.js +++ b/src/query/RelayQL.js @@ -80,7 +80,7 @@ Object.assign(RelayQL, { ); } return substitution; - } + }, }); module.exports = RelayQL; diff --git a/src/query/RelayQuery.js b/src/query/RelayQuery.js index b9da5a1c063f8..b9b417aaa155b 100644 --- a/src/query/RelayQuery.js +++ b/src/query/RelayQuery.js @@ -501,7 +501,7 @@ class RelayQueryRoot extends RelayQueryNode { batchCall = { refParamName: REF_PARAM_PREFIX + callArg.sourceQueryID, sourceQueryID: callArg.sourceQueryID, - sourceQueryPath: callArg.jsonPath + sourceQueryPath: callArg.jsonPath, }; } else { batchCall = null; @@ -971,7 +971,7 @@ class RelayQueryField extends RelayQueryNode { field.__children__ = []; field.__metadata__ = { ...field.__metadata__, - isRefQueryDependency: true + isRefQueryDependency: true, }; return field; } @@ -1152,5 +1152,5 @@ module.exports = { Node: RelayQueryNode, Operation: RelayQueryOperation, Root: RelayQueryRoot, - Subscription: RelayQuerySubscription + Subscription: RelayQuerySubscription, }; diff --git a/src/query/RelayQueryPath.js b/src/query/RelayQueryPath.js index c768b6e9016c8..11fad193932a0 100644 --- a/src/query/RelayQueryPath.js +++ b/src/query/RelayQueryPath.js @@ -151,7 +151,7 @@ class RelayQueryPath { [child, (node: $FlowIssue).getFieldByStorageKey('id')], { ...node.__concreteNode__.metatada, - rootArg: node.getRootCallArgument() + rootArg: node.getRootCallArgument(), }, this.getName() ); diff --git a/src/query/RelayQuerySerializer.js b/src/query/RelayQuerySerializer.js index 49c138a0df50f..f428352603c37 100644 --- a/src/query/RelayQuerySerializer.js +++ b/src/query/RelayQuerySerializer.js @@ -144,7 +144,7 @@ var RelayQuerySerializer = { alias: alias !== name ? alias : null, calls: node.getCallsWithValues(), children, - metadata: node.__concreteNode__.__metadata__ + metadata: node.__concreteNode__.__metadata__, }; } else if (node instanceof RelayQuery.Fragment) { return { @@ -155,8 +155,8 @@ var RelayQuerySerializer = { metadata: { ...node.__concreteNode__.__metadata__, isDeferred: node.isDeferred(), - isReferenceFragment: node.isReferenceFragment() - } + isReferenceFragment: node.isReferenceFragment(), + }, }; } else { invariant( @@ -171,10 +171,10 @@ var RelayQuerySerializer = { name: node.getName(), calls: [rootCall], children, - metadata: node.__concreteNode__.__metadata__ + metadata: node.__concreteNode__.__metadata__, }; } - } + }, }; module.exports = RelayQuerySerializer; diff --git a/src/query/__tests__/RelayFragmentReference-test.js b/src/query/__tests__/RelayFragmentReference-test.js index 4d4d8246a37ae..985d8cf5daa88 100644 --- a/src/query/__tests__/RelayFragmentReference-test.js +++ b/src/query/__tests__/RelayFragmentReference-test.js @@ -46,7 +46,7 @@ describe('RelayFragmentReference', () => { var reference = new RelayFragmentReference( () => node, { - size: 'default' + size: 'default', } ); var variables = {size: 'ignored'}; @@ -54,7 +54,7 @@ describe('RelayFragmentReference', () => { // size ignored because no variables are passed into the fragment expect(reference.getFragment(variables)).toBe(node); expect(reference.getVariables(route, variables)).toEqual({ - size: 'default' + size: 'default', }); }); @@ -70,24 +70,24 @@ describe('RelayFragmentReference', () => { var reference = new RelayFragmentReference( () => node, { - size: 'default' + size: 'default', }, { - size: new GraphQL.CallVariable('outerSize') + size: new GraphQL.CallVariable('outerSize'), } ); // no outer variable, default is used var variables = {}; expect(reference.getFragment(variables)).toBe(node); expect(reference.getVariables(route, variables)).toEqual({ - size: 'default' + size: 'default', }); // outer variable overrides inner default variables = {outerSize: 'override'}; expect(reference.getFragment(variables)).toBe(node); expect(reference.getVariables(route, variables)).toEqual({ - size: 'override' + size: 'override', }); }); @@ -127,7 +127,7 @@ describe('RelayFragmentReference', () => { var reference = new RelayFragmentReference( () => node, { - size: 'default' + size: 'default', }, {}, prepareVariables @@ -135,7 +135,7 @@ describe('RelayFragmentReference', () => { var customVariables = { size: 'override', - other: 'custom' + other: 'custom', }; prepareVariables.mockImplementation(() => customVariables); diff --git a/src/query/__tests__/RelayQL-test.js b/src/query/__tests__/RelayQL-test.js index 51f4fc6180bbb..5eb786195073d 100644 --- a/src/query/__tests__/RelayQL-test.js +++ b/src/query/__tests__/RelayQL-test.js @@ -9,8 +9,6 @@ * @emails oncall+relay */ - /* eslint no-unused-expressions: 1 */ - 'use strict'; var RelayTestUtils = require('RelayTestUtils'); diff --git a/src/query/__tests__/RelayQuery-getCallsWithValues-test.js b/src/query/__tests__/RelayQuery-getCallsWithValues-test.js index 34de5d3fb2e59..0621f2695e3e7 100644 --- a/src/query/__tests__/RelayQuery-getCallsWithValues-test.js +++ b/src/query/__tests__/RelayQuery-getCallsWithValues-test.js @@ -41,7 +41,7 @@ describe('RelayQueryNode.prototype.getCallsWithValues()', function() { var field = getProfilePicture(); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: null + value: null, }]); }); @@ -49,7 +49,7 @@ describe('RelayQueryNode.prototype.getCallsWithValues()', function() { var field = getProfilePicture(new GraphQL.CallValue(32)); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: 32 + value: 32, }]); }); }); @@ -57,41 +57,41 @@ describe('RelayQueryNode.prototype.getCallsWithValues()', function() { describe('with variables', () => { it('return `null` for empty values', () => { var field = getProfilePicture(new GraphQL.CallVariable('size'), { - size: null + size: null, }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: null + value: null, }]); }); it('return empty arrays', () => { var field = getProfilePicture(new GraphQL.CallVariable('size'), { - size: [] + size: [], }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [] + value: [], }]); }); it('return singular values', () => { var field = getProfilePicture(new GraphQL.CallVariable('size'), { - size: 32 + size: 32, }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: 32 + value: 32, }]); }); it('return array values', () => { var field = getProfilePicture(new GraphQL.CallVariable('size'), { - size: [32] + size: [32], }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [32] + value: [32], }]); }); }); @@ -103,17 +103,17 @@ describe('RelayQueryNode.prototype.getCallsWithValues()', function() { var field = getProfilePicture([]); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [] + value: [], }]); }); it('return an array of values', () => { var field = getProfilePicture([ - new GraphQL.CallValue(64) + new GraphQL.CallValue(64), ]); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [64] + value: [64], }]); }); }); @@ -121,55 +121,55 @@ describe('RelayQueryNode.prototype.getCallsWithValues()', function() { describe('with variable', () => { it('return `[null]` for empty values', () => { var field = getProfilePicture([new GraphQL.CallVariable('size')], { - size: null + size: null, }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [null] + value: [null], }]); }); it('return empty arrays', () => { var field = getProfilePicture([new GraphQL.CallVariable('size')], { - size: [] + size: [], }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [[]] + value: [[]], }]); }); it('return arrays for singular values', () => { var field = getProfilePicture([new GraphQL.CallVariable('size')], { - size: 32 + size: 32, }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [32] + value: [32], }]); }); it('return nested ararys for array values', () => { var field = getProfilePicture([new GraphQL.CallVariable('size')], { - size: [32] + size: [32], }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [[32]] + value: [[32]], }]); }); it('returns flat arrays for scalar values', () => { var field = getProfilePicture([ new GraphQL.CallVariable('width'), - new GraphQL.CallVariable('height') + new GraphQL.CallVariable('height'), ], { width: 32, - height: 64 + height: 64, }); expect(field.getCallsWithValues()).toEqual([{ name: 'size', - value: [32, 64] + value: [32, 64], }]); }); }); diff --git a/src/query/__tests__/RelayQuery-test.js b/src/query/__tests__/RelayQuery-test.js index 5c7a11e238e2e..39997f0beca12 100644 --- a/src/query/__tests__/RelayQuery-test.js +++ b/src/query/__tests__/RelayQuery-test.js @@ -162,14 +162,14 @@ describe('RelayQuery', () => { new GraphQL.BatchCallVariable('q0', '$.*.actor.id'), [ new GraphQL.Field('id'), - new GraphQL.Field('name') + new GraphQL.Field('name'), ] )); var batchCall = root.getBatchCall(); expect(batchCall).toEqual({ refParamName: 'ref_q0', sourceQueryID: 'q0', - sourceQueryPath: '$.*.actor.id' + sourceQueryPath: '$.*.actor.id', }); }); @@ -257,7 +257,7 @@ describe('RelayQuery', () => { new GraphQL.BatchCallVariable('q0', '$.*.actor.id'), [ new GraphQL.Field('id'), - new GraphQL.Field('name') + new GraphQL.Field('name'), ] )); var other = getNode(new GraphQL.Query( @@ -265,7 +265,7 @@ describe('RelayQuery', () => { new GraphQL.BatchCallVariable('q0', '$.*.actor.id'), [ new GraphQL.Field('id'), - new GraphQL.Field('name') + new GraphQL.Field('name'), ] )); expect(node.equals(other)).toBe(true); @@ -277,7 +277,7 @@ describe('RelayQuery', () => { new GraphQL.BatchCallVariable('q0', '$.*.actor.id'), [ new GraphQL.Field('id'), - new GraphQL.Field('name') + new GraphQL.Field('name'), ] )); var other = getNode(new GraphQL.Query( @@ -285,7 +285,7 @@ describe('RelayQuery', () => { new GraphQL.BatchCallVariable('q0', '$.*.actor.current_city.id'), [ new GraphQL.Field('id'), - new GraphQL.Field('name') + new GraphQL.Field('name'), ] )); expect(node.equals(other)).toBe(false); @@ -312,7 +312,7 @@ describe('RelayQuery', () => { query.__concreteNode__.metadata = {rootCallType: 'scalar'}; expect(query.getCallType()).toBe('scalar'); - me = getNode(Relay.QL`query{me{id}}`); + var me = getNode(Relay.QL`query{me{id}}`); expect(me.getCallType()).toBe(undefined); }); @@ -481,7 +481,7 @@ describe('RelayQuery', () => { country, } `; - fragment = getNode(node); + var fragment = getNode(node); expect(fragment.getDebugName()).toBe('UnknownFile'); expect(fragment.getType()).toBe('StreetAddress'); expect(fragment.getFragmentID()).toBe(generateRQLFieldAlias( @@ -493,7 +493,7 @@ describe('RelayQuery', () => { var node = Relay.QL`fragment on Node{id}`; var route = RelayMetaRoute.get('Foo'); var variables = {}; - fragment = RelayQuery.Node.create(node, route, variables); + var fragment = RelayQuery.Node.create(node, route, variables); var fragmentID = generateRQLFieldAlias('0.Foo.{}'); expect(fragment.getFragmentID()).toBe(fragmentID); @@ -582,7 +582,7 @@ describe('RelayQuery', () => { city } `; - fragment = getNode(fragmentRQL); + var fragment = getNode(fragmentRQL); var node = fragment.createNode(fragmentRQL); expect(node instanceof RelayQuery.Fragment).toBe(true); expect(node.getType()).toBe('StreetAddress'); @@ -672,7 +672,7 @@ describe('RelayQuery', () => { `; var variables = { after: 'offset', - first: 10 + first: 10, }; friendVariable = getNode(friendVariableRQL, variables).getChildren()[0]; expect(friendVariable.getSchemaName()).toBe('friends'); @@ -857,7 +857,7 @@ describe('RelayQuery', () => { `; var variables = { width: null, - height: undefined + height: undefined, }; var pictureField = getNode(pictureFragment, variables).getChildren()[0]; expect(pictureField.getCallsWithValues()).toEqual([ @@ -865,9 +865,9 @@ describe('RelayQuery', () => { name: 'size', value: [ null, - undefined - ] - } + undefined, + ], + }, ]); }); @@ -895,7 +895,7 @@ describe('RelayQuery', () => { `; var variables = { height: 64, - width: 32 + width: 32, }; var pictureVariable = getNode(pictureVariableRQL, variables).getChildren()[0]; @@ -968,7 +968,7 @@ describe('RelayQuery', () => { `; var variables = { height: 64, - width: 32 + width: 32, }; var pictureVariable = getNode(pictureVariableRQL, variables).getChildren()[0]; @@ -981,7 +981,7 @@ describe('RelayQuery', () => { expect(friendScalar.getCallsWithValues()).toEqual([ {name: 'first', value: '10'}, {name: 'after', value: 'offset'}, - {name: 'orderby', value: 'name'} + {name: 'orderby', value: 'name'}, ]); // variables return their values expect(friendVariable.getCallsWithValues()).toEqual([ @@ -1006,7 +1006,7 @@ describe('RelayQuery', () => { `; var variables = { height: '64', - width: 32 + width: 32, }; var pictureVariable = getNode(pictureVariableRQL, variables).getChildren()[0]; @@ -1047,7 +1047,7 @@ describe('RelayQuery', () => { friendVariable.getChildren(), [ {name: 'first', value: 10}, - {name: 'after', value: 'offset'} + {name: 'after', value: 'offset'}, ] ); expect(clonedFeed).toBe(friendVariable); @@ -1134,8 +1134,8 @@ describe('RelayQuery', () => { actor: 'actor:id', feedback_id: 'feedback:id', message: { - text: 'comment!' - } + text: 'comment!', + }, }); var mutationQuery = getNode(Relay.QL` mutation { @@ -1154,7 +1154,7 @@ describe('RelayQuery', () => { ); expect(mutationQuery.getCall()).toEqual({ name: 'commentCreate', - value: input + value: input, }); var children = mutationQuery.getChildren(); expect(children.length).toBe(2); @@ -1175,8 +1175,8 @@ describe('RelayQuery', () => { actor: 'actor:id', feedback_id: 'feedback:id', message: { - text: 'comment!' - } + text: 'comment!', + }, }); var mutationQuery = getNode(Relay.QL` mutation { @@ -1211,8 +1211,8 @@ describe('RelayQuery', () => { actor: 'actor:id', feedback_id: 'feedback:id', message: { - text: 'comment!' - } + text: 'comment!', + }, }); var mutationQuery = getNode(Relay.QL` mutation { @@ -1299,7 +1299,7 @@ describe('RelayQuery', () => { expect(root.getBatchCall()).toEqual({ refParamName: 'ref_q0', sourceQueryID: 'q0', - sourceQueryPath: '$.*.id' + sourceQueryPath: '$.*.id', }); }); }); @@ -1359,16 +1359,16 @@ describe('RelayQuery', () => { it('builds fields with calls', () => { var field = RelayQuery.Node.buildField('profilePicture', [ - {name: 'size', value: 32} + {name: 'size', value: 32}, ]); expect(field.getCallsWithValues()).toEqual([ - {name: 'size', value: 32} + {name: 'size', value: 32}, ]); field = RelayQuery.Node.buildField('profilePicture', [ - {name: 'size', value: ['32']} + {name: 'size', value: ['32']}, ]); expect(field.getCallsWithValues()).toEqual([ - {name: 'size', value: ['32']} + {name: 'size', value: ['32']}, ]); }); }); @@ -1423,10 +1423,10 @@ describe('RelayQuery', () => { var reference = new RelayFragmentReference( () => innerFragment, { - size: 'default' + size: 'default', }, { - size: new GraphQL.CallVariable('outerSize') + size: new GraphQL.CallVariable('outerSize'), } ); var fragment = getNode(Relay.QL` @@ -1435,7 +1435,7 @@ describe('RelayQuery', () => { ${reference}, } `, { - outerSize: 'override' + outerSize: 'override', }); var children = fragment.getChildren(); expect(children.length).toBe(2); @@ -1449,7 +1449,7 @@ describe('RelayQuery', () => { expect(grandchildren[0].getSchemaName()).toBe('id'); expect(grandchildren[1].getSchemaName()).toBe('profilePicture'); expect(grandchildren[1].getCallsWithValues()).toEqual([ - {name: 'size', value: 'override'} + {name: 'size', value: 'override'}, ]); }); }); diff --git a/src/query/__tests__/RelayQueryPath-test.js b/src/query/__tests__/RelayQueryPath-test.js index 02631769f9c7e..946ed34699b00 100644 --- a/src/query/__tests__/RelayQueryPath-test.js +++ b/src/query/__tests__/RelayQueryPath-test.js @@ -28,8 +28,8 @@ describe('RelayQueryPath', () => { children: [], metadata: { isDeferred: false, - isReferenceFragment: false - } + isReferenceFragment: false, + }, }; beforeEach(() => { @@ -213,10 +213,10 @@ describe('RelayQueryPath', () => { metadata: { requisite: true, parentType: 'Node' - } - } + }, + }, ], - metadata: {} + metadata: {}, }]); var fragment = Relay.QL`fragment on Node { name }`; @@ -251,7 +251,7 @@ describe('RelayQueryPath', () => { name: 'UnknownFile', calls: [{name: 'viewer', value: null}], children: [EMPTY_FRAGMENT], - metadata: {} + metadata: {}, }]); var fragment = Relay.QL`fragment on Viewer { pendingPosts { count } }`; @@ -301,9 +301,9 @@ describe('RelayQueryPath', () => { metadata: { requisite: true, parentType: 'Node' - } + }, }], - metadata: {} + metadata: {}, }, { kind: 'Field', @@ -313,8 +313,8 @@ describe('RelayQueryPath', () => { children: [EMPTY_FRAGMENT], metadata: { parentType: 'Actor' - } - } + }, + }, ]); var fragment = Relay.QL`fragment on StreetAddress { country }`; diff --git a/src/query/__tests__/RelayQuerySerializer-test.js b/src/query/__tests__/RelayQuerySerializer-test.js index 2dce10af8934e..537856bd9e742 100644 --- a/src/query/__tests__/RelayQuerySerializer-test.js +++ b/src/query/__tests__/RelayQuerySerializer-test.js @@ -33,8 +33,8 @@ describe('RelayQuerySerializer', () => { metadata: { generated: true, requisite: true, - parentType - } + parentType, + }, }; } @@ -46,8 +46,8 @@ describe('RelayQuerySerializer', () => { calls: [], children: [], metadata: { - parentType - } + parentType, + }, }; } @@ -104,17 +104,17 @@ describe('RelayQuerySerializer', () => { calls: [], children: [ scalarField('name', 'Actor'), - idField('Actor') + idField('Actor'), ], metadata: { dynamic: true, pk: 'id', rootCall: 'node', - parentType: 'Viewer' - } - } + parentType: 'Viewer', + }, + }, ], - metadata: {} + metadata: {}, }); var clone = fromJSON(toJSON(query)); expect(clone.equals(query)).toBe(true); @@ -136,9 +136,9 @@ describe('RelayQuerySerializer', () => { calls: [{name: 'node', value: '123'}], children: [ scalarField('name', 'Node'), - idField('Node') + idField('Node'), ], - metadata: {} + metadata: {}, }); var clone = fromJSON(toJSON(query)); expect(clone.equals(query)).toBe(true); @@ -160,9 +160,9 @@ describe('RelayQuerySerializer', () => { calls: [{name: 'nodes', value: ['1', '2', '3']}], children: [ scalarField('name', 'Node'), - idField('Node') + idField('Node'), ], - metadata: {varargs: 1} + metadata: {varargs: 1}, }); var clone = fromJSON(toJSON(query)); expect(clone.equals(query)).toBe(true); @@ -182,13 +182,13 @@ describe('RelayQuerySerializer', () => { ...idField('Node'), metadata: { requisite: true, - parentType: 'Node' + parentType: 'Node', } }], metadata: { isDeferred: false, - isReferenceFragment: false - } + isReferenceFragment: false, + }, }); expect(fromJSON(toJSON(fragment)).equals(fragment)).toBe(true); }); @@ -209,13 +209,13 @@ describe('RelayQuerySerializer', () => { ...idField('Node'), metadata: { requisite: true, - parentType: 'Node' + parentType: 'Node', } }], metadata: { isDeferred: true, - isReferenceFragment: true - } + isReferenceFragment: true, + }, }); var deserialized = fromJSON(toJSON(fragment)); @@ -240,7 +240,7 @@ describe('RelayQuerySerializer', () => { name: 'profilePicture', alias: 'photo', calls: [ - {name: 'size', value: '32'} + {name: 'size', value: '32'}, ], children: [{ kind: 'Field', @@ -248,9 +248,9 @@ describe('RelayQuerySerializer', () => { alias: null, calls: [], children: [], - metadata: {parentType: 'Image'} + metadata: {parentType: 'Image'}, }], - metadata: {parentType: 'User'} + metadata: {parentType: 'User'}, }); expect(fromJSON(toJSON(field)).equals(field)).toBe(true); }); @@ -269,7 +269,7 @@ describe('RelayQuerySerializer', () => { name: 'profilePicture', alias: 'photo', calls: [ - {name: 'size', value: ['32', '64']} + {name: 'size', value: ['32', '64']}, ], children: [{ kind: 'Field', @@ -277,9 +277,9 @@ describe('RelayQuerySerializer', () => { alias: null, calls: [], children: [], - metadata: {parentType: 'Image'} + metadata: {parentType: 'Image'}, }], - metadata: {parentType: 'User'} + metadata: {parentType: 'User'}, }); expect(fromJSON(toJSON(field)).equals(field)).toBe(true); }); @@ -302,7 +302,7 @@ describe('RelayQuerySerializer', () => { name: 'friends', alias: null, calls: [ - {name: 'isViewerFriend', value: true} + {name: 'isViewerFriend', value: true}, ], children: [{ kind: 'Field', @@ -318,19 +318,19 @@ describe('RelayQuerySerializer', () => { ...idField('User'), metadata: { requisite: true, - parentType: 'User' - } + parentType: 'User', + }, }], metadata: { pk: 'id', requisite: true, rootCall: 'node', parentType: 'FriendsEdge' - } + }, }], - metadata: {plural: true, parentType: 'FriendsConnection'} + metadata: {plural: true, parentType: 'FriendsConnection'}, }], - metadata: {connection: true, parentType: 'User'} + metadata: {connection: true, parentType: 'User'}, }); expect(fromJSON(toJSON(field)).equals(field)).toBe(true); }); diff --git a/src/query/__tests__/RelayQueryTransform-test.js b/src/query/__tests__/RelayQueryTransform-test.js index bab129d13fb5b..25eeabbc25bd0 100644 --- a/src/query/__tests__/RelayQueryTransform-test.js +++ b/src/query/__tests__/RelayQueryTransform-test.js @@ -32,7 +32,7 @@ describe('RelayQueryTransform', () => { var variables = { first: 10, - after: 'offset' + after: 'offset', }; var fragment = Relay.QL` diff --git a/src/query/__tests__/RelayQueryVisitor-test.js b/src/query/__tests__/RelayQueryVisitor-test.js index ce9146f05ab60..4d320483315e6 100644 --- a/src/query/__tests__/RelayQueryVisitor-test.js +++ b/src/query/__tests__/RelayQueryVisitor-test.js @@ -32,7 +32,7 @@ describe('RelayQueryVisitor', () => { var variables = { first: 10, - after: 'offset' + after: 'offset', }; var fragment = Relay.QL` diff --git a/src/query/__tests__/buildRQL-test.js b/src/query/__tests__/buildRQL-test.js index ae99ce36def1e..fb006897fa1a3 100644 --- a/src/query/__tests__/buildRQL-test.js +++ b/src/query/__tests__/buildRQL-test.js @@ -44,7 +44,7 @@ describe('buildRQL', () => { }); MockComponent = React.createClass({render}); MockContainer = Relay.createContainer(MockComponent, { - fragments: {} + fragments: {}, }); MockContainer.getQuery = jest.genMockFunction().mockReturnValue( Relay.QL`fragment on Node { name }` @@ -93,7 +93,7 @@ describe('buildRQL', () => { // Confirm that `${variables.sizeVariable}` is a variable by applying // variable values using `RelayQuery`: var fragment = getNode(node, { - sizeVariable: '32' + sizeVariable: '32', }); expect(fragment instanceof RelayQuery.Fragment).toBe(true); var children = fragment.getChildren(); @@ -101,7 +101,7 @@ describe('buildRQL', () => { expect(children[1].getSchemaName()).toBe('profilePicture'); // Variable has the applied value, not initial value. expect(children[1].getCallsWithValues()).toEqual([ - {name: 'size', value: '32'} + {name: 'size', value: '32'}, ]); }); @@ -149,7 +149,7 @@ describe('buildRQL', () => { expect(query instanceof RelayQuery.Root).toBe(true); expect(query.getRootCall()).toEqual({ name: 'node', - value: '123' + value: '123', }); expect(query.getChildren()[1].equals( getNode(MockContainer.getQuery(), variables) @@ -171,7 +171,7 @@ describe('buildRQL', () => { it('returns different queries for different components', () => { var MockContainer2 = Relay.createContainer(MockComponent, { - fragments: {} + fragments: {}, }); MockContainer2.getQuery = jest.genMockFunction().mockReturnValue( Relay.QL`fragment on Node { name }` diff --git a/src/query/__tests__/callsToGraphQL-test.js b/src/query/__tests__/callsToGraphQL-test.js index 86bb923fab2e3..1d74dc1f0a822 100644 --- a/src/query/__tests__/callsToGraphQL-test.js +++ b/src/query/__tests__/callsToGraphQL-test.js @@ -30,7 +30,7 @@ describe('callsToGraphQL', function() { it('converts array calls with null values', () => { var relayCalls = [{ name: 'size', - value: null + value: null, }]; var graphqlCalls = [new GraphQL.Callv('size', null)]; expect(callsFromGraphQL(graphqlCalls)).toEqual(relayCalls); @@ -40,7 +40,7 @@ describe('callsToGraphQL', function() { it('converts array calls without values', () => { var relayCalls = [{ name: 'size', - value: [] + value: [], }]; var graphqlCalls = [new GraphQL.Callv('size', [])]; expect(callsFromGraphQL(graphqlCalls)).toEqual(relayCalls); @@ -50,7 +50,7 @@ describe('callsToGraphQL', function() { it('converts calls with array values', () => { var relayCalls = [{ name: 'size', - value: [32, 64] + value: [32, 64], }]; var graphqlCalls = [new GraphQL.Callv('size', [32, 64])]; expect(callsFromGraphQL(graphqlCalls)).toEqual(relayCalls); @@ -60,7 +60,7 @@ describe('callsToGraphQL', function() { it('converts singular calls with null values', () => { var relayCalls = [{ name: 'size', - value: 32 + value: 32, }]; var graphqlCalls = [new GraphQL.Callv('size', 32)]; expect(callsFromGraphQL(graphqlCalls)).toEqual(relayCalls); diff --git a/src/query/__tests__/stableStringify-test.js b/src/query/__tests__/stableStringify-test.js index 00fbcdfac26e8..5b4baf4dd3ff8 100644 --- a/src/query/__tests__/stableStringify-test.js +++ b/src/query/__tests__/stableStringify-test.js @@ -52,16 +52,16 @@ describe('stableStringify', () => { top2: { middle: { inner: [1, 'foo', ['bar', 2]], - other: false - } + other: false, + }, }, top1: [ {first: true}, {first: false}, - 'random' + 'random', ], misc: true, - extra: null + extra: null, }; var expected = diff --git a/src/query/__tests__/toGraphQL-test.js b/src/query/__tests__/toGraphQL-test.js index 1fe2fd91e39c5..63426e719fb0e 100644 --- a/src/query/__tests__/toGraphQL-test.js +++ b/src/query/__tests__/toGraphQL-test.js @@ -147,7 +147,7 @@ describe('toGraphQL', function() { } } `, { - q: value + q: value, }); expect(relayQuery.getRootCall().value).toEqual(value); var convertedQuery = toGraphQL.Query(relayQuery); @@ -163,7 +163,7 @@ describe('toGraphQL', function() { } } `, { - q: value + q: value, }); expect(relayQuery.getRootCall().value).toEqual(value); var convertedQuery = toGraphQL.Query(relayQuery); diff --git a/src/query/buildRQL.js b/src/query/buildRQL.js index 5409d2b1b40cc..b1d555943971c 100644 --- a/src/query/buildRQL.js +++ b/src/query/buildRQL.js @@ -105,7 +105,7 @@ var buildRQL = { return GraphQL.isQuery(node) ? node : undefined; } return null; - } + }, }; function toVariables(variableNames: VariableNames): { diff --git a/src/query/fromGraphQL.js b/src/query/fromGraphQL.js index dfa3a305cc1f5..86f49ca71cf0d 100644 --- a/src/query/fromGraphQL.js +++ b/src/query/fromGraphQL.js @@ -77,7 +77,7 @@ RelayProfiler.instrumentMethods(fromGraphQL, { Node: 'fromGraphQL.Node', Field: 'fromGraphQL.Field', Fragment: 'fromGraphQL.Fragment', - Query: 'fromGraphQL.Query' + Query: 'fromGraphQL.Query', }); module.exports = fromGraphQL; diff --git a/src/query/toGraphQL.js b/src/query/toGraphQL.js index ca98b4ed21664..1ce39b0a61f9b 100644 --- a/src/query/toGraphQL.js +++ b/src/query/toGraphQL.js @@ -103,7 +103,7 @@ var toGraphQL = { metadata ); }); - } + }, }; RelayProfiler.instrumentMethods(toGraphQL, { @@ -111,7 +111,7 @@ RelayProfiler.instrumentMethods(toGraphQL, { QueryWithValues: 'toGraphQL.QueryWithValues', Query: 'toGraphQL.Query', Fragment: 'toGraphQL.Fragment', - Field: 'toGraphQL.Field' + Field: 'toGraphQL.Field', }); function toGraphQLChildren( @@ -136,7 +136,7 @@ function toGraphQLChildren( function toGraphQLMetadata(node: RelayQuery.Node): ?Object { var metadata = { ...node.__concreteNode__.__metadata__, - ...node.__metadata__ + ...node.__metadata__, }; if (Object.keys(metadata).length) { return metadata; diff --git a/src/route/RelayMetaRoute.js b/src/route/RelayMetaRoute.js index fff314cef6b9f..3bf9855455867 100644 --- a/src/route/RelayMetaRoute.js +++ b/src/route/RelayMetaRoute.js @@ -24,7 +24,7 @@ class RelayMetaRoute { Object.defineProperty(this, 'name', { enumerable: true, value: name, - writable: false + writable: false, }); } diff --git a/src/route/RelayRoute.js b/src/route/RelayRoute.js index ec129fb437bf9..d40578050d9a6 100644 --- a/src/route/RelayRoute.js +++ b/src/route/RelayRoute.js @@ -54,7 +54,7 @@ class RelayRoute { queries, paramDefinitions, path, - prepareParams + prepareParams, } = constructor; invariant( constructor !== RelayRoute, @@ -70,7 +70,7 @@ class RelayRoute { if (processQueryParams && !prepareParams) { RelayDeprecated.warn({ was: routeName + '.processQueryParams', - now: routeName + '.prepareParams' + now: routeName + '.prepareParams', }); prepareParams = processQueryParams; } @@ -104,22 +104,22 @@ class RelayRoute { Object.defineProperty(this, 'name', { enumerable: true, value: routeName, - writable: false + writable: false, }); Object.defineProperty(this, 'params', { enumerable: true, value: params, - writable: false + writable: false, }); Object.defineProperty(this, 'queries', { enumerable: true, value: queries, - writable: false + writable: false, }); Object.defineProperty(this, 'uri', { enumerable: true, value: uri, - writable: false + writable: false, }); if (__DEV__) { Object.freeze(this.params); diff --git a/src/store/RelayBufferedNeglectionStateMap.js b/src/store/RelayBufferedNeglectionStateMap.js index 72213b7fba5f2..9645c25f7cabd 100644 --- a/src/store/RelayBufferedNeglectionStateMap.js +++ b/src/store/RelayBufferedNeglectionStateMap.js @@ -48,7 +48,7 @@ class RelayBufferedNeglectionStateMap { decreaseSubscriptionsFor(dataID: DataID): void { this._bufferedChanges.push({ type: 'decrease', - dataID + dataID, }); } @@ -59,7 +59,7 @@ class RelayBufferedNeglectionStateMap { increaseSubscriptionsFor(dataID: DataID): void { this._bufferedChanges.push({ type: 'increase', - dataID + dataID, }); } @@ -70,7 +70,7 @@ class RelayBufferedNeglectionStateMap { register(dataID: DataID): void { this._bufferedChanges.push({ type: 'register', - dataID + dataID, }); } @@ -81,7 +81,7 @@ class RelayBufferedNeglectionStateMap { remove(dataID: DataID): void { this._bufferedChanges.push({ type: 'remove', - dataID + dataID, }); } diff --git a/src/store/RelayChangeTracker.js b/src/store/RelayChangeTracker.js index 767af2f114cfa..79b304e0e02c7 100644 --- a/src/store/RelayChangeTracker.js +++ b/src/store/RelayChangeTracker.js @@ -74,12 +74,12 @@ class RelayChangeTracker { if (__DEV__) { return { created: Object.freeze(this._created), - updated: Object.freeze(this._updated) + updated: Object.freeze(this._updated), }; } return { created: this._created, - updated: this._updated + updated: this._updated, }; } } diff --git a/src/store/RelayMutationTracker.js b/src/store/RelayMutationTracker.js index 2298ae7cc8d23..a3e265a781f12 100644 --- a/src/store/RelayMutationTracker.js +++ b/src/store/RelayMutationTracker.js @@ -151,7 +151,7 @@ var RelayMutationTracker = { clientMutationID: ClientMutationID ): void { delete clientMutationIDToErrorNodeID[clientMutationID]; - } + }, }; module.exports = RelayMutationTracker; diff --git a/src/store/RelayNeglectionStateMap.js b/src/store/RelayNeglectionStateMap.js index 3a313cf69a52f..f966e26b1a21d 100644 --- a/src/store/RelayNeglectionStateMap.js +++ b/src/store/RelayNeglectionStateMap.js @@ -124,7 +124,7 @@ class RelayNeglectionStateMap { dataID, collectible: false, generations: 0, - subscriptions + subscriptions, }); } diff --git a/src/store/RelayPendingQueryTracker.js b/src/store/RelayPendingQueryTracker.js index 9f4be4d90391d..ca9883fdba5cf 100644 --- a/src/store/RelayPendingQueryTracker.js +++ b/src/store/RelayPendingQueryTracker.js @@ -100,7 +100,7 @@ class PendingFetch { if (subtractedQuery) { pendingFetchMap[queryID] = { fetch: this, - query: subtractedQuery + query: subtractedQuery, }; GraphQLDeferredQueryTracker.recordQuery(subtractedQuery); this._fetchSubtractedQueryPromise.done( @@ -318,7 +318,7 @@ var RelayPendingQueryTracker = { }, // TODO: Use `export type`. - PendingFetch + PendingFetch, }; diff --git a/src/store/RelayQueryTracker.js b/src/store/RelayQueryTracker.js index 9a6383f028caa..81665856d2d63 100644 --- a/src/store/RelayQueryTracker.js +++ b/src/store/RelayQueryTracker.js @@ -60,7 +60,7 @@ class RelayQueryTracker { this._trackedNodesByID[dataID] = this._trackedNodesByID[dataID] || { trackedNodes: [], - isFlattened: false + isFlattened: false, }; this._trackedNodesByID[dataID].trackedNodes.push(node); this._trackedNodesByID[dataID].isFlattened = false; diff --git a/src/store/RelayQueryWriter.js b/src/store/RelayQueryWriter.js index dadc1049c601d..9ea881f542b49 100644 --- a/src/store/RelayQueryWriter.js +++ b/src/store/RelayQueryWriter.js @@ -88,7 +88,7 @@ class RelayQueryWriter extends RelayQueryVisitor { nodeID: null, recordID, responseData, - path + path, }; if (node instanceof RelayQuery.Field && !node.isScalar()) { @@ -191,7 +191,7 @@ class RelayQueryWriter extends RelayQueryVisitor { ): ?RelayQuery.Node { var { recordID, - responseData + responseData, } = state; invariant( this._store.getRecordStatus(recordID) === RelayRecordStatus.EXISTENT, @@ -319,7 +319,7 @@ class RelayQueryWriter extends RelayQueryVisitor { path, nodeID: null, recordID: connectionID, - responseData: connectionData + responseData: connectionData, }; this._traverseConnection(field, field, connectionState); } @@ -360,7 +360,7 @@ class RelayQueryWriter extends RelayQueryVisitor { ): void { var { recordID: connectionID, - responseData: connectionData + responseData: connectionData, } = state; var storageKey = connection.getStorageKey(); invariant( @@ -464,7 +464,7 @@ class RelayQueryWriter extends RelayQueryVisitor { path, nodeID, recordID: edgeID, - responseData: edgeData + responseData: edgeData, }); isUpdate = isUpdate || this.hasChangeToRecord(edgeID); }); @@ -543,7 +543,7 @@ class RelayQueryWriter extends RelayQueryVisitor { path, nodeID: null, // never propagate `nodeID` past the first linked field recordID: nextLinkedID, - responseData: nextRecord + responseData: nextRecord, }); isUpdate = isUpdate || this.hasChangeToRecord(nextLinkedID); nextIndex++; @@ -605,7 +605,7 @@ class RelayQueryWriter extends RelayQueryVisitor { path, nodeID: null, recordID: nextLinkedID, - responseData: fieldData + responseData: fieldData, }); } } diff --git a/src/store/RelayRecordStatus.js b/src/store/RelayRecordStatus.js index 718c7f0d2dcd7..af29d6640fb0b 100644 --- a/src/store/RelayRecordStatus.js +++ b/src/store/RelayRecordStatus.js @@ -32,7 +32,7 @@ var RelayRecordStatus = { * Record status is unknown because it has not yet been fetched from the * server. */ - UNKNOWN: 'UNKNOWN' + UNKNOWN: 'UNKNOWN', }; module.exports = RelayRecordStatus; diff --git a/src/store/RelayRecordStore.js b/src/store/RelayRecordStore.js index f4adb53b16743..bace350534235 100644 --- a/src/store/RelayRecordStore.js +++ b/src/store/RelayRecordStore.js @@ -242,7 +242,7 @@ class RelayRecordStore { return; } var nextRecord: Record = ({ - __dataID__: dataID + __dataID__: dataID, }: $FixMe); if (target === this._queuedRecords) { this._setClientMutationID(nextRecord); @@ -457,7 +457,7 @@ class RelayRecordStore { parentID ); var fieldValue = { - __dataID__: recordID + __dataID__: recordID, }; parent[storageKey] = fieldValue; if (!this._queuedRecords && this._cacheManager) { @@ -522,7 +522,7 @@ class RelayRecordStore { parentID ); return { - __dataID__: recordID + __dataID__: recordID, }; }); parent[storageKey] = records; @@ -562,7 +562,7 @@ class RelayRecordStore { var connectionIDs; forEachObject(record, (datum, key) => { if (datum && getFieldNameFromKey(key) === schemaName) { - dataID = datum.__dataID__; + var dataID = datum.__dataID__; if (dataID) { connectionIDs = connectionIDs || []; connectionIDs.push(dataID); @@ -632,7 +632,7 @@ class RelayRecordStore { diffCalls: calls, filterCalls, pageInfo: undefined, - requestedEdges: [] + requestedEdges: [], }; } // Convert ordered `{name,value}` objects to `GraphQL.Call`s @@ -643,7 +643,7 @@ class RelayRecordStore { var { diffCalls, pageInfo, - requestedEdgeIDs + requestedEdgeIDs, } = range.retrieveRangeInfoForQuery(calls, queuedRecord); if (diffCalls && diffCalls.length) { diffCalls = filterCalls.concat(diffCalls); @@ -655,7 +655,7 @@ class RelayRecordStore { requestedEdges = requestedEdgeIDs .map(edgeID => ({ edgeID, - nodeID: this.getLinkedRecordID(edgeID, NODE) + nodeID: this.getLinkedRecordID(edgeID, NODE), })) .filter(edge => this._getRecord(edge.nodeID)); } else { @@ -665,7 +665,7 @@ class RelayRecordStore { diffCalls, filterCalls, pageInfo, - requestedEdges + requestedEdges, }; } @@ -785,8 +785,8 @@ class RelayRecordStore { __dataID__: edgeID, cursor: this.getField(edgeID, CURSOR), node: { - __dataID__: nodeID - } + __dataID__: nodeID, + }, }; } @@ -925,7 +925,7 @@ class RelayRecordStore { var source = this._queuedRecords || this._records; if (!source[dataID]) { record = source[dataID] = ({ - __dataID__: dataID + __dataID__: dataID, }: $FixMe); } if (source === this._queuedRecords) { diff --git a/src/store/RelayStoreData.js b/src/store/RelayStoreData.js index d6942161b3d4d..9096cae1f4b9a 100644 --- a/src/store/RelayStoreData.js +++ b/src/store/RelayStoreData.js @@ -192,7 +192,7 @@ class RelayStoreData { changeTracker, { forceIndex, - updateTrackedQueries: true + updateTrackedQueries: true, } ); writeRelayQueryPayload( @@ -221,7 +221,7 @@ class RelayStoreData { changeTracker, { forceIndex: generateForceIndex(), - updateTrackedQueries: false + updateTrackedQueries: false, } ); writeRelayUpdatePayload( @@ -364,7 +364,7 @@ class RelayStoreData { } RelayProfiler.instrumentMethods(RelayStoreData.prototype, { - handleQueryPayload: 'RelayStoreData.prototype.handleQueryPayload' + handleQueryPayload: 'RelayStoreData.prototype.handleQueryPayload', }); module.exports = RelayStoreData; diff --git a/src/store/RelayStoreGarbageCollector.js b/src/store/RelayStoreGarbageCollector.js index 61c382e7f9485..abef163667b15 100644 --- a/src/store/RelayStoreGarbageCollector.js +++ b/src/store/RelayStoreGarbageCollector.js @@ -332,7 +332,7 @@ RelayProfiler.instrumentMethods(RelayStoreGarbageCollector.prototype, { increaseSubscriptionsFor: 'RelayStoreGarbageCollector.prototype.increaseSubscriptionsFor', register: - 'RelayStoreGarbageCollector.prototype.register' + 'RelayStoreGarbageCollector.prototype.register', }); module.exports = RelayStoreGarbageCollector; diff --git a/src/store/__mocks__/RelayBufferedNeglectionStateMap.js b/src/store/__mocks__/RelayBufferedNeglectionStateMap.js index 7dc4c833bd84b..6277b7794625c 100644 --- a/src/store/__mocks__/RelayBufferedNeglectionStateMap.js +++ b/src/store/__mocks__/RelayBufferedNeglectionStateMap.js @@ -27,7 +27,7 @@ class RelayBufferedNeglectionStateMap { } RelayBufferedNeglectionStateMap.mock = { - instances: [] + instances: [], }; module.exports = RelayBufferedNeglectionStateMap; diff --git a/src/store/__mocks__/RelayMockCacheManager.js b/src/store/__mocks__/RelayMockCacheManager.js index b3f1a9b4b0d26..a4468ecd10c61 100644 --- a/src/store/__mocks__/RelayMockCacheManager.js +++ b/src/store/__mocks__/RelayMockCacheManager.js @@ -15,9 +15,9 @@ var RelayMockCacheManager = { cacheNode: jest.genMockFunction(), cacheField: jest.genMockFunction(), cacheRootCall: jest.genMockFunction(), - readAllData: jest.genMockFunction() + readAllData: jest.genMockFunction(), }; - } + }, }; module.exports = RelayMockCacheManager; diff --git a/src/store/__mocks__/RelayNeglectionStateMap.js b/src/store/__mocks__/RelayNeglectionStateMap.js index 1e348f4da1219..7f7d3d22f7db4 100644 --- a/src/store/__mocks__/RelayNeglectionStateMap.js +++ b/src/store/__mocks__/RelayNeglectionStateMap.js @@ -27,7 +27,7 @@ class RelayNeglectionStateMap { } RelayNeglectionStateMap.mock = { - instances: [] + instances: [], }; module.exports = RelayNeglectionStateMap; diff --git a/src/store/__mocks__/RelayStore.js b/src/store/__mocks__/RelayStore.js index 7ada56b832f70..017f404ad38ba 100644 --- a/src/store/__mocks__/RelayStore.js +++ b/src/store/__mocks__/RelayStore.js @@ -49,7 +49,7 @@ function genMockRequest(args) { }, fail(error) { args[1]({aborted: false, done: false, error, ready, stale: false}); - } + }, }; } @@ -85,7 +85,7 @@ RelayStore.mock = { setMockRecords: records => { RelayStore.mock.recordStore = new RelayRecordStore({records}); }, - recordStore: null + recordStore: null, }; RelayStore.observe.mockImplementation((...args) => { diff --git a/src/store/__tests__/RelayNeglectionStateMap-test.js b/src/store/__tests__/RelayNeglectionStateMap-test.js index 07ec2c1498d4b..65ad411ef7696 100644 --- a/src/store/__tests__/RelayNeglectionStateMap-test.js +++ b/src/store/__tests__/RelayNeglectionStateMap-test.js @@ -118,14 +118,14 @@ describe('RelayNeglectionStateMap', () => { dataID: 'a', collectible: false, generations: 0, - subscriptions: 0 + subscriptions: 0, }; neglectionStateB = { dataID: 'b', collectible: false, generations: 0, - subscriptions: 1 + subscriptions: 1, }; }); diff --git a/src/store/__tests__/RelayPendingQueryTracker-test.js b/src/store/__tests__/RelayPendingQueryTracker-test.js index b9e34222bc758..549b9a10b5ef2 100644 --- a/src/store/__tests__/RelayPendingQueryTracker-test.js +++ b/src/store/__tests__/RelayPendingQueryTracker-test.js @@ -53,7 +53,7 @@ describe('RelayPendingQueryTracker', () => { query, fetchMode, forceIndex: null, - storeData: RelayStoreData.getDefaultInstance() + storeData: RelayStoreData.getDefaultInstance(), }); }; @@ -96,7 +96,7 @@ describe('RelayPendingQueryTracker', () => { jest.runAllTimers(); expect(subtractRelayQuery.mock.calls).toEqual([ - [mockQueryC, mockQueryA] + [mockQueryC, mockQueryA], ]); fetchRelayQuery.mock.requests[1].resolve({}); @@ -137,7 +137,7 @@ describe('RelayPendingQueryTracker', () => { expect(subtractRelayQuery.mock.calls).toEqual([ [mockQueryB, mockQueryA], - [mockQueryC, mockQueryA] + [mockQueryC, mockQueryA], ]); }); @@ -353,7 +353,7 @@ describe('RelayPendingQueryTracker', () => { addPending({ query: mockQuery, - fetchMode: DliteFetchModeConstants.FETCH_MODE_PRELOAD + fetchMode: DliteFetchModeConstants.FETCH_MODE_PRELOAD, }); RelayPendingQueryTracker.resolvePreloadQuery( @@ -384,7 +384,7 @@ describe('RelayPendingQueryTracker', () => { addPending({ query: mockQuery, - fetchMode: DliteFetchModeConstants.FETCH_MODE_PRELOAD + fetchMode: DliteFetchModeConstants.FETCH_MODE_PRELOAD, }); jest.runAllTimers(); @@ -405,7 +405,7 @@ describe('RelayPendingQueryTracker', () => { var mockPending = addPending({ query: mockQuery, - fetchMode: DliteFetchModeConstants.FETCH_MODE_PRELOAD + fetchMode: DliteFetchModeConstants.FETCH_MODE_PRELOAD, }); var mockCallback = jest.genMockFunction(); mockPending.getResolvedPromise().catch(mockCallback); diff --git a/src/store/__tests__/RelayRecordStore-test.js b/src/store/__tests__/RelayRecordStore-test.js index b96c35e3fe577..41737a4752907 100644 --- a/src/store/__tests__/RelayRecordStore-test.js +++ b/src/store/__tests__/RelayRecordStore-test.js @@ -53,8 +53,8 @@ describe('RelayRecordStore', () => { var records = { '4': { id: '4', - __dataID__: '4' - } + __dataID__: '4', + }, }; var store = new RelayRecordStore({records}); expect(store.getRecordStatus('4')).toBe('EXISTENT'); @@ -63,11 +63,11 @@ describe('RelayRecordStore', () => { it('prefers queued records over non-existent records', () => { var queuedRecord = { id: '4', - __dataID__: '4' + __dataID__: '4', }; var store = new RelayRecordStore({ records: {}, - queuedRecords: {'4': queuedRecord} + queuedRecords: {'4': queuedRecord}, }); expect(store.getRecordStatus('4')).toBe('EXISTENT'); }); @@ -75,11 +75,11 @@ describe('RelayRecordStore', () => { it('prefers queued records over deleted records', () => { var queuedRecord = { id: '4', - __dataID__: '4' + __dataID__: '4', }; var store = new RelayRecordStore({ records: {'4': null}, - queuedRecords: {'4': queuedRecord} + queuedRecords: {'4': queuedRecord}, }); expect(store.getRecordStatus('4')).toBe('EXISTENT'); }); @@ -87,11 +87,11 @@ describe('RelayRecordStore', () => { it('prefers queued records when they are deleted', () => { var record = { id: '4', - __dataID__: '4' + __dataID__: '4', }; var store = new RelayRecordStore({ records: {'4': record}, - queuedRecords: {'4': null} + queuedRecords: {'4': null}, }); expect(store.getRecordStatus('4')).toBe('NONEXISTENT'); }); @@ -99,12 +99,12 @@ describe('RelayRecordStore', () => { it('prefers queued records over cached records', () => { var record = { id: '4', - __dataID__: '4' + __dataID__: '4', }; var store = new RelayRecordStore({ queuedRecords: {'4': record}, records: {}, - cachedRecords: {'4': null} + cachedRecords: {'4': null}, }); expect(store.getRecordStatus('4')).toBe('EXISTENT'); }); @@ -112,11 +112,11 @@ describe('RelayRecordStore', () => { it('prefers existing records over cached records', () => { var record = { id: '4', - __dataID__: '4' + __dataID__: '4', }; var store = new RelayRecordStore({ records: {'4': record}, - cachedRecords: {'4': null} + cachedRecords: {'4': null}, }); expect(store.getRecordStatus('4')).toBe('EXISTENT'); }); @@ -124,11 +124,11 @@ describe('RelayRecordStore', () => { it('falls back to cached records when necessary', () => { var record = { id: '4', - __dataID__: '4' + __dataID__: '4', }; var store = new RelayRecordStore({ records: {}, - cachedRecords: {'4': record} + cachedRecords: {'4': record}, }); expect(store.getRecordStatus('4')).toBe('EXISTENT'); }); @@ -138,7 +138,7 @@ describe('RelayRecordStore', () => { it('returns true if record is queued', () => { var store = new RelayRecordStore({ records: {}, - queuedRecords: {'4': {__dataID__: '4'}} + queuedRecords: {'4': {__dataID__: '4'}}, }); expect(store.hasOptimisticUpdate('4')).toBe(true); }); @@ -146,14 +146,14 @@ describe('RelayRecordStore', () => { it('returns false if record is not queued', () => { var store = new RelayRecordStore({ records: {'4': {__dataID__: '4'}}, - queuedRecords: {} + queuedRecords: {}, }); expect(store.hasOptimisticUpdate('4')).toBe(false); }); it('throws if called on a non-queued record store', () => { var store = new RelayRecordStore({ - records: {'4': {__dataID__: '4'}} + records: {'4': {__dataID__: '4'}}, }); expect(() => { store.hasOptimisticUpdate('4'); @@ -169,8 +169,8 @@ describe('RelayRecordStore', () => { var queuedRecords = { '1': { __dataID__: '1', - __hasError__: true - } + __hasError__: true, + }, }; var store = new RelayRecordStore({queuedRecords}); expect(store.hasMutationError('1')).toBe(true); @@ -180,8 +180,8 @@ describe('RelayRecordStore', () => { var queuedRecords = { '1': { __dataID__: '1', - __hasError__: false - } + __hasError__: false, + }, }; var store = new RelayRecordStore({queuedRecords}); expect(store.hasMutationError('1')).toBe(false); @@ -196,8 +196,8 @@ describe('RelayRecordStore', () => { it('throws if queuedRecords are not available', () => { var records = { '1': { - __dataID__: '1' - } + __dataID__: '1', + }, }; var store = new RelayRecordStore({records}); expect(() => { @@ -221,8 +221,8 @@ describe('RelayRecordStore', () => { it('updates the error status for existing queued records', () => { var queuedRecords = { '1': { - __dataID__: '1' - } + __dataID__: '1', + }, }; var store = new RelayRecordStore({queuedRecords}); store.setMutationErrorStatus('1', true); @@ -313,8 +313,8 @@ describe('RelayRecordStore', () => { '4': { id: '4', __dataID__: '4', - name: 'Zuck' - } + name: 'Zuck', + }, }; var store = new RelayRecordStore({records}); expect(store.getField('4', 'name')).toBe('Zuck'); @@ -333,16 +333,16 @@ describe('RelayRecordStore', () => { var record = { id: '4', name: 'Zuck', - __dataID__: '4' + __dataID__: '4', }; var queuedRecord = { id: '4', name: 'Mark', - __dataID__: '4' + __dataID__: '4', }; var store = new RelayRecordStore({ records: {'4': record}, - queuedRecords: {'4': queuedRecord} + queuedRecords: {'4': queuedRecord}, }); expect(store.getField('4', 'name')).toBe('Mark'); }); @@ -351,16 +351,16 @@ describe('RelayRecordStore', () => { var record = { id: '4', name: 'Zuck', - __dataID__: '4' + __dataID__: '4', }; var cachedRecord = { id: '4', name: 'Mark', - __dataID__: '4' + __dataID__: '4', }; var store = new RelayRecordStore({ records: {'4': record}, - cachedRecords: {'4': cachedRecord} + cachedRecords: {'4': cachedRecord}, }); expect(store.getField('4', 'name')).toBe('Zuck'); }); @@ -370,15 +370,15 @@ describe('RelayRecordStore', () => { var record = { id: '4', name: 'Zuck', - __dataID__: '4' + __dataID__: '4', }; var queuedRecord = { id: '4', - __dataID__: '4' + __dataID__: '4', }; var store = new RelayRecordStore({ records: {'4': record}, - queuedRecords: {'4': queuedRecord} + queuedRecords: {'4': queuedRecord}, }); expect(store.getField('4', 'name')).toBe('Zuck'); } @@ -388,16 +388,16 @@ describe('RelayRecordStore', () => { () => { var record = { id: '4', - __dataID__: '4' + __dataID__: '4', }; var cachedRecord = { id: '4', name: 'Mark', - __dataID__: '4' + __dataID__: '4', }; var store = new RelayRecordStore({ cachedRecords: {'4': cachedRecord}, - records: {'4': record} + records: {'4': record}, }); expect(store.getField('4', 'name')).toBe('Mark'); } @@ -421,7 +421,7 @@ describe('RelayRecordStore', () => { var records = { '4': { id: '4', - __dataID__: '4' + __dataID__: '4', } }; var store = new RelayRecordStore({records}); @@ -434,7 +434,7 @@ describe('RelayRecordStore', () => { id: '4', __dataID__: '4', address: null - } + }, }; var store = new RelayRecordStore({records}); expect(store.getLinkedRecordID('4', 'address')).toBe(null); @@ -446,12 +446,12 @@ describe('RelayRecordStore', () => { id: '4', __dataID__: '4', address: { - __dataID__: 'client:1' + __dataID__: 'client:1', } }, 'client:1': { - street: '1 Hacker Way' - } + street: '1 Hacker Way', + }, }; var store = new RelayRecordStore({records}); expect(store.getLinkedRecordID('4', 'address')).toBe('client:1'); @@ -501,7 +501,7 @@ describe('RelayRecordStore', () => { __dataID__: '4', actors: [ {__dataID__: 'item:1'}, - {__dataID__: 'item:2'} + {__dataID__: 'item:2'}, ] } }; @@ -524,10 +524,10 @@ describe('RelayRecordStore', () => { __dataID__: '4', 'friends': { __dataID__: 'client:1' - } + }, }, 'client:1': { - __range__: mockRange + __range__: mockRange, }, 'edge:1': { __dataID__: 'edge:1', @@ -536,8 +536,8 @@ describe('RelayRecordStore', () => { } }, 'node:1': { - __dataID__: 'node:1' - } + __dataID__: 'node:1', + }, }; }); @@ -571,7 +571,7 @@ describe('RelayRecordStore', () => { records['node:1'] = null; var store = new RelayRecordStore({records}); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ - requestedEdgeIDs: ['edge:1'] + requestedEdgeIDs: ['edge:1'], }); var metadata = store.getRangeMetadata( 'client:1', @@ -595,19 +595,19 @@ describe('RelayRecordStore', () => { requestedEdgeIDs: ['edge:1'], diffCalls: [ {name: 'first', value: '1'}, - {name: 'after', value: 'edge:1'} + {name: 'after', value: 'edge:1'}, ] }); var store = new RelayRecordStore({records}); var rangeInfo = store.getRangeMetadata('client:1', [ {name: 'orderby', value: ['TOP_STORIES']}, - {name: 'first', value: 2} + {name: 'first', value: 2}, ]); expect(mockRange.retrieveRangeInfoForQuery).toBeCalled(); expect(rangeInfo.diffCalls).toEqual([ {name: 'orderby', value: ['TOP_STORIES']}, {name: 'first', value: '1'}, - {name: 'after', value: 'edge:1'} + {name: 'after', value: 'edge:1'}, ]); expect(rangeInfo.requestedEdges).toEqual([{ edgeID: 'edge:1', @@ -623,7 +623,7 @@ describe('RelayRecordStore', () => { it('returns null/undefined for deleted/unfetched records', () => { var records = { deleted: null, - notARange: {} + notARange: {}, }; var store = new RelayRecordStore({records}); @@ -642,8 +642,8 @@ describe('RelayRecordStore', () => { var records = { 'client:1': { __range__: new GraphQLRange(), - __filterCalls__: calls - } + __filterCalls__: calls, + }, }; var store = new RelayRecordStore({records}); @@ -654,7 +654,7 @@ describe('RelayRecordStore', () => { describe('getConnectionIDsForRecord', () => { it('returns null for non-existent records', () => { var records = { - deleted: null + deleted: null, }; var store = new RelayRecordStore({records}); expect(store.getConnectionIDsForRecord('unfetched')).toBe(null); @@ -665,7 +665,7 @@ describe('RelayRecordStore', () => { var records = { '1': { __dataID__: '1' - } + }, }; var store = new RelayRecordStore({records}); expect(store.getConnectionIDsForRecord('1')).toBe(null); @@ -677,17 +677,17 @@ describe('RelayRecordStore', () => { __dataID__: '1' }, 'range:1': { - __dataID__: 'range:1' + __dataID__: 'range:1', }, 'range:2': { - __dataID__: 'range:2' - } + __dataID__: 'range:2', + }, }; var nodeRangeMap = { '1': { 'range:1': true, - 'range:2': true - } + 'range:2': true, + }, }; var store = new RelayRecordStore({records}, null, nodeRangeMap); expect(store.getConnectionIDsForRecord('1')).toEqual([ @@ -704,7 +704,7 @@ describe('RelayRecordStore', () => { describe('getConnectionIDsForField()', () => { it('returns null/undefined for non-existent records', () => { var records = { - 'deleted': null + 'deleted': null, }; var store = new RelayRecordStore({records}); expect(store.getConnectionIDsForField('unfetched', 'news_feed')).toBe( @@ -730,7 +730,7 @@ describe('RelayRecordStore', () => { 'photos.orderby(likes)': { __dataID__: '3' } - } + }, }; var store = new RelayRecordStore({records}); expect(store.getConnectionIDsForField('1', 'photos')).toEqual(['2', '3']); diff --git a/src/store/__tests__/RelayRecordStore_write-test.js b/src/store/__tests__/RelayRecordStore_write-test.js index e2a86c49d1eb2..553da00a6bb61 100644 --- a/src/store/__tests__/RelayRecordStore_write-test.js +++ b/src/store/__tests__/RelayRecordStore_write-test.js @@ -75,7 +75,7 @@ describe('RelayRecordStore', () => { var records = { '1': { __dataID__: '1' - } + }, }; var store = new RelayRecordStore({records}, null, null, cache); store.deleteRecord('1'); @@ -89,7 +89,7 @@ describe('RelayRecordStore', () => { it('writes to queued data if available, otherwise base data', () => { var cachedRecords = { a: {__dataID__: 'a'}, - b: {__dataID__: 'b'} + b: {__dataID__: 'b'}, }; var records = {}; var queuedRecords = {}; @@ -176,7 +176,7 @@ describe('RelayRecordStore', () => { var phone = { is_verified: true, phone_number: { - display_number: '1-800-555-1212' // directory assistance + display_number: '1-800-555-1212', // directory assistance } }; store.putField('1', 'all_phones', [phone]); @@ -187,7 +187,7 @@ describe('RelayRecordStore', () => { it('writes to queued data if available, otherwise base data', () => { var cachedRecords = { 'a': {__dataID__: 'a'}, - 'b': {__dataID__: 'b'} + 'b': {__dataID__: 'b'}, }; var records = {}; var queuedRecords = {}; @@ -247,12 +247,12 @@ describe('RelayRecordStore', () => { var cachedRecords = { 'a': { __dataID__: 'a', - name: 'A' + name: 'A', }, 'b': { __dataID__: 'b', - name: 'B' - } + name: 'B', + }, }; var records = {}; var queuedRecords = {}; @@ -301,7 +301,7 @@ describe('RelayRecordStore', () => { store.putLinkedRecordID('viewerID', 'actor', 'actorID'); expect(store.getLinkedRecordID('viewerID', 'actor')).toBe('actorID'); expect(cache.cacheField).toBeCalledWith('viewerID', 'actor', { - __dataID__: 'actorID' + __dataID__: 'actorID', }); }); @@ -362,7 +362,7 @@ describe('RelayRecordStore', () => { .toEqual(['actor1', 'actor2']); expect(cache.cacheField).toBeCalledWith('storyID', 'actors', [ {__dataID__: 'actor1'}, - {__dataID__: 'actor2'} + {__dataID__: 'actor2'}, ]); }); @@ -486,7 +486,7 @@ describe('RelayRecordStore', () => { { name: 'first', value: '10' - } + }, ]; store.putRecord('1'); store.putRange('1', calls); @@ -526,7 +526,7 @@ describe('RelayRecordStore', () => { store.putRange(connectionID, []); var pageInfo = { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }; var calls = [{name: 'first', value: 3}]; var edges = []; @@ -559,7 +559,7 @@ describe('RelayRecordStore', () => { expect(rangeInfo.requestedEdges).toEqual([ {edgeID: 'edge0', nodeID: 'node0'}, {edgeID: 'edge1', nodeID: 'node1'}, - {edgeID: 'edge2', nodeID: 'node2'} + {edgeID: 'edge2', nodeID: 'node2'}, ]); expect(cache.cacheField).toBeCalledWith( connectionID, @@ -579,6 +579,7 @@ describe('RelayRecordStore', () => { var queuedRecords; var queuedStore; var records; + var store; var _inc = 0; function addEdgeToStore(store) { @@ -622,7 +623,7 @@ describe('RelayRecordStore', () => { [{name: 'first', value: 1}], { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, }, [firstEdgeID] ); @@ -635,7 +636,7 @@ describe('RelayRecordStore', () => { [{name: 'last', value: 1}], { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: true + [HAS_PREV_PAGE]: true, }, [lastEdgeID] ); diff --git a/src/store/__tests__/RelayStoreData-test.js b/src/store/__tests__/RelayStoreData-test.js index 3b25249eeaa7f..d27ff21d0550e 100644 --- a/src/store/__tests__/RelayStoreData-test.js +++ b/src/store/__tests__/RelayStoreData-test.js @@ -58,8 +58,8 @@ describe('RelayStoreData', () => { id: '123', doesViewerLike: false, topLevelComments: { - count: 1 - } + count: 1, + }, } }; storeData.handleQueryPayload(query, response); @@ -103,13 +103,13 @@ describe('RelayStoreData', () => { id: '123', doesViewerLike: false, topLevelComments: { - count: 1 - } - } + count: 1, + }, + }, }; storeData.handleUpdatePayload(mutationQuery, payload, { configs: [], - isOptimisticUpdate: false + isOptimisticUpdate: false, }); // results are written to `records` @@ -149,14 +149,14 @@ describe('RelayStoreData', () => { id: '123', doesViewerLike: false, topLevelComments: { - count: 1 - } - } + count: 1, + }, + }, }; storeData.handleUpdatePayload(mutationQuery, payload, { configs: [], isOptimisticUpdate: true, - clientMutationID: 'mutationID' + clientMutationID: 'mutationID', }); // results are written to `queuedRecords` @@ -169,7 +169,7 @@ describe('RelayStoreData', () => { // `records` is unchanged expect(storeData.getNodeData()).toEqual({ - '123': {__dataID__: '123'} + '123': {__dataID__: '123'}, }); }); @@ -201,8 +201,8 @@ describe('RelayStoreData', () => { id: '123', doesViewerLike: false, topLevelComments: { - count: 1 - } + count: 1, + }, } }; storeData.handleQueryPayload(query, response); @@ -228,14 +228,14 @@ describe('RelayStoreData', () => { id: '123', doesViewerLike: false, topLevelComments: { - count: 1 - } - } + count: 1, + }, + }, }; storeData.handleUpdatePayload(mutationQuery, payload, { configs: [], isOptimisticUpdate: true, - clientMutationID: 'mutationID' + clientMutationID: 'mutationID', }); // simulate a server response with different data @@ -243,8 +243,8 @@ describe('RelayStoreData', () => { '123': { id: '123', doesViewerLike: true, // inverted - topLevelComments: null // delete - } + topLevelComments: null, // delete + }, }; storeData.handleQueryPayload(query, response); diff --git a/src/store/__tests__/RelayStoreData_cacheManager-test.js b/src/store/__tests__/RelayStoreData_cacheManager-test.js index 81396af76c535..9575259497689 100644 --- a/src/store/__tests__/RelayStoreData_cacheManager-test.js +++ b/src/store/__tests__/RelayStoreData_cacheManager-test.js @@ -108,7 +108,7 @@ describe('RelayStoreData', function() { } ) ); - } + }, }); }); @@ -120,12 +120,12 @@ describe('RelayStoreData', function() { expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: 2, - cacheRootCall: 0 + cacheRootCall: 0, }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ '123': { __dataID__: '123', - id: '123' + id: '123', } }); }); @@ -138,7 +138,7 @@ describe('RelayStoreData', function() { expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: 2, - cacheRootCall: 1 + cacheRootCall: 1, }); expect(cacheManager.cacheRootCall).toBeCalledWith( 'username', @@ -148,7 +148,7 @@ describe('RelayStoreData', function() { expect(cacheManager.cacheField).toBeCalledWithNodeFields({ '123': { __dataID__: '123', - id: '123' + id: '123', } }); }); @@ -161,13 +161,13 @@ describe('RelayStoreData', function() { expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: 3, - cacheRootCall: 1 + cacheRootCall: 1, }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ 'client:viewer': { __dataID__: 'client:viewer', __path__: getPathToRecord('client:viewer'), - isFbEmployee: true + isFbEmployee: true, } }); }); @@ -189,28 +189,28 @@ describe('RelayStoreData', function() { id: '123', hometown: { id: '456', - url: 'http://...' - } - } + url: 'http://...', + }, + }, }; storeData.handleQueryPayload(query, response); expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: 6, - cacheRootCall: 0 + cacheRootCall: 0, }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ '123': { __dataID__: '123', id: '123', - hometown: {__dataID__: '456'} + hometown: {__dataID__: '456'}, }, '456': { __dataID__: '456', id: '456', - url: 'http://...' - } + url: 'http://...', + }, }); }); @@ -230,8 +230,8 @@ describe('RelayStoreData', function() { id: '123', screennames: [ {service: 'GTALK'}, - {service: 'TWITTER'} - ] + {service: 'TWITTER'}, + ], } }; storeData.handleQueryPayload(query, response); @@ -240,7 +240,7 @@ describe('RelayStoreData', function() { expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: 9, - cacheRootCall: 0 + cacheRootCall: 0, }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ '123': { @@ -248,19 +248,19 @@ describe('RelayStoreData', function() { id: '123', screennames: [ {__dataID__: 'client:1'}, - {__dataID__: 'client:2'} - ] + {__dataID__: 'client:2'}, + ], }, 'client:1': { __dataID__: 'client:1', __path__: getPathToRecord('client:1'), - service: 'GTALK' + service: 'GTALK', }, 'client:2': { __dataID__: 'client:2', __path__: getPathToRecord('client:2'), - service: 'TWITTER' - } + service: 'TWITTER', + }, }); }); @@ -293,62 +293,62 @@ describe('RelayStoreData', function() { node: { id: '1' }, - cursor: '1' + cursor: '1', }, { node: { id: '2' }, - cursor: '2' - } + cursor: '2', + }, ], [PAGE_INFO]: { [HAS_PREV_PAGE]: false, - [HAS_NEXT_PAGE]: true - } - } - } + [HAS_NEXT_PAGE]: true, + }, + }, + }, }; storeData.handleQueryPayload(query, response); expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: 21, - cacheRootCall: 0 + cacheRootCall: 0, }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ '123': { __dataID__: '123', id: '123', - friends: {__dataID__: 'client:1'} + friends: {__dataID__: 'client:1'}, }, 'client:1': { __dataID__: 'client:1', __path__: getPathToRecord('client:1'), __filterCalls__: [], __forceIndex__: 0, - __range__: getRangeForRecord('client:1') + __range__: getRangeForRecord('client:1'), }, 'client:client:1:1': { __dataID__: 'client:client:1:1', __path__: getPathToRecord('client:client:1:1'), node: {__dataID__: '1'}, - cursor: '1' + cursor: '1', }, '1': { __dataID__: '1', - id: '1' + id: '1', }, 'client:client:1:2': { __dataID__: 'client:client:1:2', __path__: getPathToRecord('client:client:1:2'), node: {__dataID__: '2'}, - cursor: '2' + cursor: '2', }, '2': { __dataID__: '2', - id: '2' - } + id: '2', + }, }); }); @@ -379,31 +379,31 @@ describe('RelayStoreData', function() { edges: [], [PAGE_INFO]: { [HAS_PREV_PAGE]: false, - [HAS_NEXT_PAGE]: true - } - } - } + [HAS_NEXT_PAGE]: true, + }, + }, + }, }; storeData.handleQueryPayload(query, response); expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: 9, - cacheRootCall: 0 + cacheRootCall: 0, }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ '123': { __dataID__: '123', id: '123', - friends: {__dataID__: 'client:1'} + friends: {__dataID__: 'client:1'}, }, 'client:1': { __dataID__: 'client:1', __path__: getPathToRecord('client:1'), __filterCalls__: [], __forceIndex__: 0, - __range__: getRangeForRecord('client:1') - } + __range__: getRangeForRecord('client:1'), + }, }); }); @@ -428,8 +428,8 @@ describe('RelayStoreData', function() { [CLIENT_MUTATION_ID]: 'abc', feedback: { id: '123', - doesViewerLike: true - } + doesViewerLike: true, + }, }; storeData.handleUpdatePayload( mutationQuery, @@ -440,12 +440,12 @@ describe('RelayStoreData', function() { expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: prevCallCount + 2, // both scalar fields are updated - cacheRootCall: 0 + cacheRootCall: 0, }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ '123': { - doesViewerLike: true - } + doesViewerLike: true, + }, }); }); @@ -478,16 +478,16 @@ describe('RelayStoreData', function() { edges: [ { node: { - id: '1' + id: '1', }, - cursor: '1' - } + cursor: '1', + }, ], [PAGE_INFO]: { [HAS_PREV_PAGE]: false, - [HAS_NEXT_PAGE]: true - } - } + [HAS_NEXT_PAGE]: true, + }, + }, } }; storeData.handleQueryPayload(query, response); @@ -496,7 +496,7 @@ describe('RelayStoreData', function() { type: RelayMutationType.RANGE_ADD, connectionName: 'comments', edgeName: 'feedbackCommentEdge', - rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND} + rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND}, }]; var prevCallCount = cacheManager.cacheField.mock.calls.length; @@ -526,19 +526,19 @@ describe('RelayStoreData', function() { [CLIENT_MUTATION_ID]: 'abc', feedback: { comments: { - count: 3 + count: 3, }, - id: '123' + id: '123', }, feedbackCommentEdge: { node: { - id: '2' + id: '2', }, cursor: '2', source: { - id: '123' - } - } + id: '123', + }, + }, }; storeData.handleUpdatePayload( mutationQuery, @@ -549,24 +549,24 @@ describe('RelayStoreData', function() { expect(cacheManager).toContainCalledMethods({ cacheNode: 0, cacheField: prevCallCount + 12, - cacheRootCall: 0 + cacheRootCall: 0, }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ 'client:1': { __range__: getRangeForRecord('client:1'), - count: 3 + count: 3, }, 'client:client:1:2': { __dataID__: 'client:client:1:2', __path__: getPathToRecord('client:client:1:2'), node: {__dataID__: '2'}, cursor: '2', - source: {__dataID__: '123'} + source: {__dataID__: '123'}, }, '2': { __dataID__: '2', - id: '2' - } + id: '2', + }, }); }); @@ -599,16 +599,16 @@ describe('RelayStoreData', function() { edges: [ { node: { - id: '1' + id: '1', }, - cursor: '1' - } + cursor: '1', + }, ], [PAGE_INFO]: { [HAS_PREV_PAGE]: false, - [HAS_NEXT_PAGE]: true - } - } + [HAS_NEXT_PAGE]: true, + }, + }, } }; storeData.handleQueryPayload(query, response); @@ -616,7 +616,7 @@ describe('RelayStoreData', function() { var configs = [{ type: RelayMutationType.RANGE_DELETE, pathToConnection: ['feedback', 'comments'], - deletedIDFieldName: 'deletedCommentId' + deletedIDFieldName: 'deletedCommentId', }]; var prevCallCount = cacheManager.cacheField.mock.calls.length; @@ -640,9 +640,9 @@ describe('RelayStoreData', function() { feedback: { id: '123', comments: { - count: 1 - } - } + count: 1, + }, + }, }; storeData.handleUpdatePayload( mutationQuery, @@ -653,13 +653,13 @@ describe('RelayStoreData', function() { expect(cacheManager).toContainCalledMethods({ cacheNode: 1, cacheField: prevCallCount + 4, - cacheRootCall: 0 + cacheRootCall: 0, }); expect(cacheManager.cacheField).toBeCalledWithNodeFields({ 'client:1': { __range__: getRangeForRecord('client:1'), - count: 1 - } + count: 1, + }, }); }); }); diff --git a/src/store/__tests__/RelayStoreGarbageCollector-test.js b/src/store/__tests__/RelayStoreGarbageCollector-test.js index 4cfa9e6c6087a..940752f81b613 100644 --- a/src/store/__tests__/RelayStoreGarbageCollector-test.js +++ b/src/store/__tests__/RelayStoreGarbageCollector-test.js @@ -44,7 +44,7 @@ describe('RelayStoreGarbageCollector', () => { relayStoreData, stepLength ), - storeData: relayStoreData + storeData: relayStoreData, }; } @@ -246,8 +246,8 @@ describe('RelayStoreGarbageCollector', () => { 'client:1': {__dataID__: 'client:1'}, 'client:range': { __dataID__: 'client:range', - __range__: mockRange - } + __range__: mockRange, + }, }; var {garbageCollector, storeData} = createRelayStoreGarbageCollector(records); @@ -259,7 +259,7 @@ describe('RelayStoreGarbageCollector', () => { // Collectible on all registered DataIDs now set to true garbageCollector.scheduleCollection(); expect(storeData.getQueuedData()).toEqual({ - 'client:1': {__dataID__: 'client:1'} + 'client:1': {__dataID__: 'client:1'}, }); } ); @@ -277,7 +277,7 @@ describe('RelayStoreGarbageCollector', () => { var records = { a: {__dataID__: 'a'}, b: {__dataID__: 'b'}, - c: {__dataID__: 'c'} + c: {__dataID__: 'c'}, }; var {garbageCollector, storeData} = createRelayStoreGarbageCollector(records); @@ -306,13 +306,13 @@ describe('RelayStoreGarbageCollector', () => { jest.runAllTimers(); expect(storeData.getQueuedData()).toEqual({ b: {__dataID__: 'b'}, - c: {__dataID__: 'c'} + c: {__dataID__: 'c'}, }); // Second step of the second collect-cycle. `b` will be removed. (tasks[3])(); jest.runAllTimers(); expect(storeData.getQueuedData()).toEqual({ - c: {__dataID__: 'c'} + c: {__dataID__: 'c'}, }); // Executing the last step of the last collect-cycle, no more steps will // be queued after this step. @@ -346,17 +346,17 @@ describe('RelayStoreGarbageCollector', () => { var records = { a: { __dataID__: 'a', - field: {__dataID__: 'client:1'} + field: {__dataID__: 'client:1'}, }, b: {__dataID__: 'b'}, c: { __dataID__: 'c', - field: {__dataID__: 'client:2'} + field: {__dataID__: 'client:2'}, }, d: {__dataID__: 'd'}, e: {__dataID__: 'e'}, 'client:1': {__dataID__: 'client:1'}, - 'client:2': {__dataID__: 'client:2'} + 'client:2': {__dataID__: 'client:2'}, }; var {garbageCollector, storeData} = createRelayStoreGarbageCollector(records); @@ -376,7 +376,7 @@ describe('RelayStoreGarbageCollector', () => { // will be scheduled and run asynchronously. expect(storeData.getQueuedData()).toEqual({ d: {__dataID__: 'd'}, - e: {__dataID__: 'e'} + e: {__dataID__: 'e'}, }); jest.runAllTimers(); // Next collection step takes care of the remaining DataIDs `d` and `e`. @@ -399,14 +399,14 @@ describe('RelayStoreGarbageCollector', () => { a: { __dataID__: 'a', field1: {__dataID__: 'client:1'}, - field2: {__dataID__: 'client:2'} + field2: {__dataID__: 'client:2'}, }, 'client:1': {__dataID__: 'client:1'}, 'client:2': { __dataID__: 'client:2', - field3: {__dataID__: 'client:3' } + field3: {__dataID__: 'client:3' }, }, - 'client:3': {__dataID__: 'client:3'} + 'client:3': {__dataID__: 'client:3'}, }; var nodeData = storeData.getNodeData(); forEachObject(records, (data, dataID) => { @@ -416,10 +416,10 @@ describe('RelayStoreGarbageCollector', () => { var queuedRecords = { a: { __dataID__: 'a', - field2: {__dataID__: 'client:4'} + field2: {__dataID__: 'client:4'}, }, 'client:4': {__dataID__: 'client:4'}, - 'client:5': {__dataID__: 'client:5'} + 'client:5': {__dataID__: 'client:5'}, }; var queuedData = storeData.getQueuedData(); forEachObject(queuedRecords, (data, dataID) => { @@ -436,7 +436,7 @@ describe('RelayStoreGarbageCollector', () => { garbageCollector.scheduleCollection(); expect(storeData.getNodeData()).toEqual({}); expect(storeData.getQueuedData()).toEqual({ - 'client:5': {__dataID__: 'client:5'} + 'client:5': {__dataID__: 'client:5'}, }); }); @@ -448,14 +448,14 @@ describe('RelayStoreGarbageCollector', () => { a: { __dataID__: 'a', b: {__dataID__: 'b'}, - field1: {__dataID__: 'client:1'} + field1: {__dataID__: 'client:1'}, }, b: { __dataID__: 'b', - field2: {__dataID__: 'client:2'} + field2: {__dataID__: 'client:2'}, }, 'client:1': {__dataID__: 'client:1'}, - 'client:2': {__dataID__: 'client:2'} + 'client:2': {__dataID__: 'client:2'}, }; var {garbageCollector, storeData} = createRelayStoreGarbageCollector(records); @@ -469,7 +469,7 @@ describe('RelayStoreGarbageCollector', () => { expect(storeData.getQueuedData()).toEqual({ b: { __dataID__: 'b', - field2: {__dataID__: 'client:2'} + field2: {__dataID__: 'client:2'}, }, 'client:2': {__dataID__: 'client:2'} }); @@ -484,7 +484,7 @@ describe('RelayStoreGarbageCollector', () => { var records = { range: {__dataID__: 'range', __range__: mockRange}, 'client:1': {__dataID__: 'client:1'}, - 'client:2': {__dataID__: 'client:2'} + 'client:2': {__dataID__: 'client:2'}, }; var {garbageCollector, storeData} = createRelayStoreGarbageCollector(records); @@ -492,7 +492,7 @@ describe('RelayStoreGarbageCollector', () => { expect(storeData.getQueuedData()).toEqual({ range: {__dataID__: 'range', __range__: mockRange}, 'client:1': {__dataID__: 'client:1'}, - 'client:2': {__dataID__: 'client:2'} + 'client:2': {__dataID__: 'client:2'}, }); garbageCollector.register('range'); diff --git a/src/store/__tests__/filterExclusiveKeys-test.js b/src/store/__tests__/filterExclusiveKeys-test.js index 320f4d021ac4c..2b407f0509f7d 100644 --- a/src/store/__tests__/filterExclusiveKeys-test.js +++ b/src/store/__tests__/filterExclusiveKeys-test.js @@ -25,7 +25,7 @@ describe('filterExclusiveKeys', () => { var b = {x: true, y: true, z: true}; expect(filterExclusiveKeys(a, b)).toEqual([ ['v', 'w'], - ['y', 'z'] + ['y', 'z'], ]); }); @@ -34,7 +34,7 @@ describe('filterExclusiveKeys', () => { var b = {x: true, y: true, z: true}; expect(filterExclusiveKeys(a, b)).toEqual([ [], - ['x', 'y', 'z'] + ['x', 'y', 'z'], ]); }); @@ -43,7 +43,7 @@ describe('filterExclusiveKeys', () => { var b = {x: true, y: true, z: true}; expect(filterExclusiveKeys(a, b)).toEqual([ [], - ['x', 'y', 'z'] + ['x', 'y', 'z'], ]); }); @@ -52,7 +52,7 @@ describe('filterExclusiveKeys', () => { var b = null; expect(filterExclusiveKeys(a, b)).toEqual([ ['x', 'y', 'z'], - [] + [], ]); }); @@ -61,7 +61,7 @@ describe('filterExclusiveKeys', () => { var b = {}; expect(filterExclusiveKeys(a, b)).toEqual([ ['x', 'y', 'z'], - [] + [], ]); }); }); diff --git a/src/store/__tests__/observeAllRelayQueryData-test.js b/src/store/__tests__/observeAllRelayQueryData-test.js index 0c8c378e1d592..e8eeb9f90fd62 100644 --- a/src/store/__tests__/observeAllRelayQueryData-test.js +++ b/src/store/__tests__/observeAllRelayQueryData-test.js @@ -50,7 +50,7 @@ describe('observeRelayQueryData', () => { mockCallsbacks = { onCompleted: jest.genMockFunction(), onError: jest.genMockFunction(), - onNext: jest.genMockFunction() + onNext: jest.genMockFunction(), }; jest.addMatchers(RelayTestUtils.matchers); @@ -67,7 +67,7 @@ describe('observeRelayQueryData', () => { it('creates observers for the dataIDs when `subscribe` is called', () => { var query = getNode(Relay.QL`fragment on Node @relay(plural:true){id}`); var records = { - 1: {__dataID__: '1', id: 1} + 1: {__dataID__: '1', id: 1}, }; var observer = observeAllData(records, query, ['1']); @@ -80,7 +80,7 @@ describe('observeRelayQueryData', () => { var records = { 1: {__dataID__: '1', id: 1}, 2: {__dataID__: '2', id: 2}, - 3: {__dataID__: '3', id: 3} + 3: {__dataID__: '3', id: 3}, }; var observer = observeAllData(records, query, ['1', '2', '3']); @@ -97,7 +97,7 @@ describe('observeRelayQueryData', () => { var records = { 1: {__dataID__: '1', id: 1}, 2: {__dataID__: '2', id: 2}, - 3: {__dataID__: '3', id: 3} + 3: {__dataID__: '3', id: 3}, }; var observer = observeAllData(records, query, ['1', '2', '3']); @@ -112,7 +112,7 @@ describe('observeRelayQueryData', () => { var records = { 1: {__dataID__: '1', id: 1}, 2: {__dataID__: '2', id: 2}, - 3: {__dataID__: '3', id: 3} + 3: {__dataID__: '3', id: 3}, }; var observer = observeAllData(records, query, ['1', '2', '3']); @@ -132,7 +132,7 @@ describe('observeRelayQueryData', () => { var records = { 1: {__dataID__: '1', id: 1}, 2: {__dataID__: '2', id: 2}, - 3: {__dataID__: '3', id: 3} + 3: {__dataID__: '3', id: 3}, }; var observer = observeAllData(records, query, ['1', '2', '3']); @@ -147,7 +147,7 @@ describe('observeRelayQueryData', () => { var query = getNode(Relay.QL`fragment on Node @relay(plural:true){id}`); var records = { 1: {__dataID__: '1', id: 1}, - 2: {__dataID__: '2', id: 2} + 2: {__dataID__: '2', id: 2}, }; var observer = observeAllData(records, query, ['1']); @@ -163,14 +163,14 @@ describe('observeRelayQueryData', () => { var query = getNode(Relay.QL`fragment on Node @relay(plural:true){id}`); var records = { 1: {__dataID__: '1', id: 1}, - 2: {__dataID__: '2', id: 2} + 2: {__dataID__: '2', id: 2}, }; var observer = observeAllData(records, query, ['1', '2']); observer.subscribe(mockCallsbacks); expect(mockCallsbacks.onNext.mock.calls[0][0]).toEqual([ {__dataID__: '1', id: 1}, - {__dataID__: '2', id: 2} + {__dataID__: '2', id: 2}, ]); }); @@ -179,7 +179,7 @@ describe('observeRelayQueryData', () => { var records = { 1: {__dataID__: '1', id: 1}, 2: {__dataID__: '2', id: 2}, - 3: {__dataID__: '3', id: 3} + 3: {__dataID__: '3', id: 3}, }; var observer = observeAllData(records, query, ['1']); @@ -190,7 +190,7 @@ describe('observeRelayQueryData', () => { expect(mockCallsbacks.onNext.mock.calls[1][0]).toEqual([ {__dataID__: '1', id: 1}, {__dataID__: '2', id: 2}, - {__dataID__: '3', id: 3} + {__dataID__: '3', id: 3}, ]); }); @@ -199,7 +199,7 @@ describe('observeRelayQueryData', () => { var records = { a: {__dataID__: 'a', id: 1}, b: {__dataID__: 'b', id: 2}, - c: {__dataID__: 'c', id: 3} + c: {__dataID__: 'c', id: 3}, }; var observer = observeAllData(records, query, ['a', 'b', 'c']); @@ -207,14 +207,14 @@ describe('observeRelayQueryData', () => { expect(mockCallsbacks.onNext.mock.calls[0][0]).toEqual([ {__dataID__: 'a', id: 1}, {__dataID__: 'b', id: 2}, - {__dataID__: 'c', id: 3} + {__dataID__: 'c', id: 3}, ]); observer.setDataIDs(['c', 'a', 'b']); expect(mockCallsbacks.onNext.mock.calls[1][0]).toEqual([ {__dataID__: 'c', id: 3}, {__dataID__: 'a', id: 1}, - {__dataID__: 'b', id: 2} + {__dataID__: 'b', id: 2}, ]); }); @@ -222,7 +222,7 @@ describe('observeRelayQueryData', () => { var query = getNode(Relay.QL`fragment on Node @relay(plural:true){id}`); var records = { a: {__dataID__: 'a', id: 1}, - b: {__dataID__: 'b', id: 2} + b: {__dataID__: 'b', id: 2}, }; var observer = observeAllData(records, query, ['a', 'b']); @@ -230,7 +230,7 @@ describe('observeRelayQueryData', () => { observer.setDataIDs(['a']); expect(mockCallsbacks.onNext.mock.calls[1][0]).toEqual([ - {__dataID__: 'a', id: 1} + {__dataID__: 'a', id: 1}, ]); }); @@ -238,7 +238,7 @@ describe('observeRelayQueryData', () => { var query = getNode(Relay.QL`fragment on Node @relay(plural:true){id}`); var records = { a: {__dataID__: 'a', id: 1}, - b: {__dataID__: 'b', id: 2} + b: {__dataID__: 'b', id: 2}, }; var error = new Error('An error occured'); @@ -257,7 +257,7 @@ describe('observeRelayQueryData', () => { () => { var query = getNode(Relay.QL`fragment on Node @relay(plural:true){id}`); var records = { - a: {__dataID__: 'a', id: 1} + a: {__dataID__: 'a', id: 1}, }; var observer = observeAllData(records, query, ['a', 'b']); diff --git a/src/store/__tests__/observeRelayQueryData-test.js b/src/store/__tests__/observeRelayQueryData-test.js index ff8bd6c370b19..5bc1ba7fdfed8 100644 --- a/src/store/__tests__/observeRelayQueryData-test.js +++ b/src/store/__tests__/observeRelayQueryData-test.js @@ -59,7 +59,7 @@ describe('observeRelayQueryData', () => { var name = 'RelayObserverError'; var message = 'Record `node` has not been fetched.'; observeData({}, query, 'node').subscribe({ - onError: firstMockCallback + onError: firstMockCallback, }); expect(firstMockCallback).toBeCalled(); @@ -71,7 +71,7 @@ describe('observeRelayQueryData', () => { var query = getNode(Relay.QL`fragment on Node{id, name}`); var records = {node: null}; var subscription = observeData(records, query, 'node').subscribe({ - onNext: firstMockCallback + onNext: firstMockCallback, }); subscription.dispose(); @@ -107,11 +107,11 @@ describe('observeRelayQueryData', () => { it('no longer watches data when no subscribers are attached', () => { var recordsStore = new RelayRecordStore({records: { user: {id: 1, name: 'Chris', birthdate: {__dataID__: 'date'}}, - date: null + date: null, }}); var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); observeRelayQueryData(recordsStore, query, 'user').subscribe({ - onNext: firstMockCallback + onNext: firstMockCallback, }).dispose(); expect(addListenerForIDs.mock.calls.length).toBe(1); @@ -121,7 +121,7 @@ describe('observeRelayQueryData', () => { it('calls a subscriber when observed data changes', () => { var recordsStore = new RelayRecordStore({records: { user: {id: 1, name: 'Chris', birthdate: {__dataID__: 'date'}}, - date: null + date: null, }}); var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); var observable = observeRelayQueryData(recordsStore, query, 'user'); @@ -139,7 +139,7 @@ describe('observeRelayQueryData', () => { __dataID__: 'user', id: 1, name: 'Joe', - birthdate: null + birthdate: null, }); // Check that the change emitter still listens to the right id @@ -151,7 +151,7 @@ describe('observeRelayQueryData', () => { it('calls subscribers when data is added to an observed node', () => { var recordsStore = new RelayRecordStore({records: { user: {id: 1, name: 'Chris', birthdate: {__dataID__: 'date'}}, - date: null + date: null, }}); var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); var observable = observeRelayQueryData(recordsStore, query, 'user'); @@ -170,8 +170,8 @@ describe('observeRelayQueryData', () => { name: 'Chris', birthdate: { __dataID__: 'date', - day: 30 - } + day: 30, + }, }); expect(addListenerForIDs.mock.remove[0]).toBeCalled(); expect(addListenerForIDs.mock.calls[1][0]).toEqual([ @@ -182,7 +182,7 @@ describe('observeRelayQueryData', () => { it('calls a subscriber when data disappears from a node', () => { var recordsStore = new RelayRecordStore({records: { user: {id: 1, name: 'Jon', birthdate: {__dataID__: 'date'}}, - date: {day: 15 } + date: {day: 15 }, }}); var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); var observable = observeRelayQueryData(recordsStore, query, 'user'); @@ -198,7 +198,7 @@ describe('observeRelayQueryData', () => { __dataID__: 'user', id: 1, name: 'Jon', - birthdate: null + birthdate: null, }); expect(addListenerForIDs.mock.calls[0][0]).toEqual([ 'user', 'date' @@ -212,7 +212,7 @@ describe('observeRelayQueryData', () => { it('no longer calls disposed-of subscribers when data changes', () => { var recordsStore = new RelayRecordStore({records: { user: {id: 1, name: 'Jon', birthdate: {__dataID__: 'date'}}, - date: {day: 15 } + date: {day: 15 }, }}); var query = getNode(Relay.QL`fragment on User{id, name, birthdate {day}}`); var observable = observeRelayQueryData(recordsStore, query, 'user'); @@ -286,7 +286,7 @@ describe('observeRelayQueryData', () => { recordsStore = new RelayRecordStore({records: { chris: {__dataID__: 'chris', address: {__dataID__: 'address'}}, date: {__dataID__: 'date', day: 15}, - address: {__dataID__: 'address', city: 'Menlo Park'} + address: {__dataID__: 'address', city: 'Menlo Park'}, }}); observable = observeRelayQueryData(recordsStore, query, 'chris'); }); diff --git a/src/store/__tests__/readRelayQueryData-test.js b/src/store/__tests__/readRelayQueryData-test.js index 11cf091a97274..6fa5338d4db0f 100644 --- a/src/store/__tests__/readRelayQueryData-test.js +++ b/src/store/__tests__/readRelayQueryData-test.js @@ -81,13 +81,13 @@ describe('readRelayQueryData', () => { 'client:viewer': { __dataID__: 'client:viewer', actor: { - __dataID__: '660361306' - } + __dataID__: '660361306', + }, }, 660361306: { __dataID__: '660361306', - firstName: 'Greg' - } + firstName: 'Greg', + }, }; var query = getNode(Relay.QL`query{viewer{actor{firstName}}}`); var data = getData({records}, query, 'client:viewer'); @@ -95,8 +95,8 @@ describe('readRelayQueryData', () => { __dataID__: 'client:viewer', actor: { __dataID__: '660361306', - firstName: 'Greg' - } + firstName: 'Greg', + }, }); }); @@ -105,10 +105,10 @@ describe('readRelayQueryData', () => { node: { name: 'Chris', birthdate: {__dataID__: 'date'}, - address: {__dataID__: 'address'} + address: {__dataID__: 'address'}, }, date: {day: 21}, - address: null + address: null, }; var query = getNode(Relay.QL`fragment on User{birthdate {day}, address {city}}`); expect( @@ -116,7 +116,7 @@ describe('readRelayQueryData', () => { ).toEqual({ node: true, date: true, - address: true + address: true, }); }); @@ -124,9 +124,9 @@ describe('readRelayQueryData', () => { var records = { 1055790163: { address: {__dataID__: 'client:1'}, - firstName: 'Yuzhi' + firstName: 'Yuzhi', }, - 'client:1': null + 'client:1': null, }; var query = getNode(Relay.QL` fragment on Actor { @@ -140,7 +140,7 @@ describe('readRelayQueryData', () => { expect(data).toEqual({ __dataID__: '1055790163', address: null, - firstName: 'Yuzhi' + firstName: 'Yuzhi', }); }); @@ -149,8 +149,8 @@ describe('readRelayQueryData', () => { feedbackID: { __dataID__: 'feedbackID', doesViewerLike: null, - id: 'feedbackID' - } + id: 'feedbackID', + }, }; var query = getNode(Relay.QL` fragment on Feedback { @@ -165,8 +165,8 @@ describe('readRelayQueryData', () => { records = { feedbackID: { __dataID__: 'feedbackID', - id: 'feedbackID' - } + id: 'feedbackID', + }, }; data = getData({records}, query, 'feedbackID'); expect(data.id).toBe('feedbackID'); @@ -178,7 +178,7 @@ describe('readRelayQueryData', () => { var records = { user_id: { id: 'user_id', - websites: [] + websites: [], } }; var query = getNode(Relay.QL`fragment on User{id,websites}`); @@ -208,22 +208,22 @@ describe('readRelayQueryData', () => { var records = { 660361306: { __dataID__: '660361306', - firstName: 'Greg' - } + firstName: 'Greg', + }, }; var queuedRecords = { 660361306: { __dataID__: '660361306', __status__: ERROR, - firstName: 'Snoop Lion' - } + firstName: 'Snoop Lion', + }, }; var query = getNode(Relay.QL`fragment on User{firstName}`); var data = getData({records, queuedRecords}, query, '660361306'); expect(data).toEqual({ __dataID__: '660361306', __status__: ERROR, - firstName: 'Snoop Lion' + firstName: 'Snoop Lion', }); }); @@ -232,13 +232,13 @@ describe('readRelayQueryData', () => { 'client:viewer': { __dataID__: 'client:viewer', actor: { - __dataID__: '660361306' - } + __dataID__: '660361306', + }, }, 660361306: { __dataID__: '660361306', - firstName: 'Greg' - } + firstName: 'Greg', + }, }; var fragmentReference = new RelayFragmentReference( () => Relay.QL`fragment on Viewer{actor{firstName}}`, @@ -256,12 +256,12 @@ describe('readRelayQueryData', () => { 1055790163: { __dataID__: '1055790163', address: {__dataID__: 'client:1'}, - last_name: 'Zheng' + last_name: 'Zheng', }, 'client:1': { __dataID__: 'client:1', city: 'San Francisco', - country: 'US' + country: 'US', } }; @@ -277,7 +277,7 @@ describe('readRelayQueryData', () => { address: { __dataID__: 'client:1', city: 'San Francisco', - country: 'US' + country: 'US', } }); }); @@ -288,8 +288,8 @@ describe('readRelayQueryData', () => { id: 'client:123', count: 42, __dataID__: 'client:123', - __range__: new GraphQLRange() - } + __range__: new GraphQLRange(), + }, }; var query = getNode(Relay.QL` fragment on FriendsConnection { @@ -299,7 +299,7 @@ describe('readRelayQueryData', () => { var rangeID = GraphQLStoreRangeUtils.getClientIDForRangeWithID( callsToGraphQL([ {name: 'is_viewer_friend', value: null}, - {name: 'first', value: 10} + {name: 'first', value: 10}, ]), {}, 'client:123' @@ -313,13 +313,13 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, } }); var data = getData({records}, query, rangeID); expect(data).toEqual({ __dataID__: rangeID, - count: 42 + count: 42, }); }); @@ -328,13 +328,13 @@ describe('readRelayQueryData', () => { feedback_id: { __dataID__: 'feedback_id', likers: { - __dataID__: 'likers_id' - } + __dataID__: 'likers_id', + }, }, likers_id: { __dataID__: 'likers_id', - count: 31337 - } + count: 31337, + }, }; var query = getNode(Relay.QL`fragment on Feedback{likers{count}}`); var data = getData({records}, query, 'feedback_id'); @@ -342,8 +342,8 @@ describe('readRelayQueryData', () => { __dataID__: 'feedback_id', likers: { __dataID__: 'likers_id', - count: 31337 - } + count: 31337, + }, }); }); @@ -362,14 +362,14 @@ describe('readRelayQueryData', () => { feedbackID: { __dataID__: 'feedbackID', topLevelComments: { - __dataID__: 'commentsID' - } + __dataID__: 'commentsID', + }, }, commentsID: { __dataID__: 'commentsID', __range__: new GraphQLRange(), - count: 57 - } + count: 57, + }, }; GraphQLRange.prototype.retrieveRangeInfoForQuery.mockReturnValue({ @@ -379,7 +379,7 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, } }); @@ -388,8 +388,8 @@ describe('readRelayQueryData', () => { __dataID__: 'feedbackID', topLevelComments: { __dataID__: 'commentsID_first(1)', - count: 57 - } + count: 57, + }, }); }); @@ -409,14 +409,14 @@ describe('readRelayQueryData', () => { feedbackID: { __dataID__: 'feedbackID', topLevelComments: { - __dataID__: 'commentsID' - } + __dataID__: 'commentsID', + }, }, commentsID: { __dataID__: 'commentsID', __range__: new GraphQLRange(), - count: 57 - } + count: 57, + }, }; GraphQLRange.prototype.retrieveRangeInfoForQuery.mockReturnValue({ @@ -426,7 +426,7 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, } }); @@ -437,9 +437,9 @@ describe('readRelayQueryData', () => { __dataID__: 'commentsID_first(1)', count: 57, [PAGE_INFO]: { - [HAS_NEXT_PAGE]: true + [HAS_NEXT_PAGE]: true, } - } + }, }); }); @@ -448,20 +448,20 @@ describe('readRelayQueryData', () => { story_id: { __dataID__: 'story_id', feedback: { - __dataID__: 'feedback_id' - } + __dataID__: 'feedback_id', + }, }, feedback_id: { __dataID__: 'feedback_id', likers: { - __dataID__: 'likers_id' - } + __dataID__: 'likers_id', + }, }, likers_id: { __dataID__: 'likers_id', __range__: new GraphQLRange(), - count: 31337 - } + count: 31337, + }, }; var error = 'Invariant Violation: ' + @@ -486,20 +486,20 @@ describe('readRelayQueryData', () => { story_id: { __dataID__: 'story_id', feedback: { - __dataID__: 'feedback_id' - } + __dataID__: 'feedback_id', + }, }, feedback_id: { __dataID__: 'feedback_id', likers: { - __dataID__: 'likers_id' - } + __dataID__: 'likers_id', + }, }, likers_id: { __dataID__: 'likers_id', __range__: new GraphQLRange(), - count: 31337 - } + count: 31337, + }, }; var error = 'Invariant Violation: ' + @@ -533,24 +533,24 @@ describe('readRelayQueryData', () => { feedback_id: { __dataID__: 'feedback_id', likers: { - __dataID__: 'likers_id' + __dataID__: 'likers_id', } }, likers_id: { __dataID__: 'likers_id', edges: [ { - __dataID__: 'likers_edge_id' - } + __dataID__: 'likers_edge_id', + }, ], [PAGE_INFO]: { - __dataID__: 'likers_page_info_id' - } + __dataID__: 'likers_page_info_id', + }, }, likers_edge_id: { __dataID__: 'likers_edge_id', node: { - __dataID__: 'liker_id' + __dataID__: 'liker_id', } }, likers_page_info_id: { @@ -574,11 +574,11 @@ describe('readRelayQueryData', () => { __dataID__: 'likers_edge_id', node: { __dataID__: 'liker_id', - name: 'Tim' - } - } - ] - } + name: 'Tim', + }, + }, + ], + }, }); query = getNode(Relay.QL` @@ -591,9 +591,9 @@ describe('readRelayQueryData', () => { __dataID__: 'likers_id_first(1)', [PAGE_INFO]: { __dataID__: 'likers_page_info_id', - [HAS_NEXT_PAGE]: true - } - } + [HAS_NEXT_PAGE]: true, + }, + }, }); }); @@ -602,13 +602,13 @@ describe('readRelayQueryData', () => { feedback_id: { __dataID__: 'feedback_id', comments: { - __dataID__: 'comments_id' + __dataID__: 'comments_id', } }, comments_id: { __dataID__: 'comments_id', - __range__: new GraphQLRange() - } + __range__: new GraphQLRange(), + }, }; var fragmentReference = new RelayFragmentReference( () => Relay.QL`fragment on PageInfo{hasNextPage}`, @@ -630,7 +630,7 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, } }); @@ -645,7 +645,7 @@ describe('readRelayQueryData', () => { __dataID__: 'comments_id_first(1)', [PAGE_INFO]: { [START_CURSOR]: 'cursor', - [HAS_NEXT_PAGE]: true + [HAS_NEXT_PAGE]: true, } }); @@ -665,21 +665,21 @@ describe('readRelayQueryData', () => { feedback_id: { __dataID__: 'feedback_id', comments: { - __dataID__: 'comments_id' + __dataID__: 'comments_id', } }, comments_id: { __dataID__: 'comments_id', - __range__: new GraphQLRange() + __range__: new GraphQLRange(), }, comment_node_id: { __dataID__: 'comment_node_id', - id: 'comment_node_id' + id: 'comment_node_id', }, comment_edge_id: { __dataID__: 'comment_edge_id', node: {__dataID__: 'comment_node_id'}, - cursor: 'cursor' + cursor: 'cursor', } }; var fragmentReference = new RelayFragmentReference( @@ -707,7 +707,7 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, } }); @@ -728,7 +728,7 @@ describe('readRelayQueryData', () => { } }], [PAGE_INFO]: { - [START_CURSOR]: 'cursor' + [START_CURSOR]: 'cursor', } }); @@ -750,7 +750,7 @@ describe('readRelayQueryData', () => { id: 'user_id', screennames: [ {__dataID__: 'client1'}, - {__dataID__: 'client2'} + {__dataID__: 'client2'}, ], hometown: {__dataID__: 'hometown_id'} }, @@ -820,16 +820,16 @@ describe('readRelayQueryData', () => { var records = { 'client:viewer': { __dataID__: 'client:viewer', - actor: null - } + actor: null, + }, }; var data = getData({records}, query, 'client:viewer'); expect(data.actor).toBeNull(); records = { 'client:viewer': { - __dataID__: 'client:viewer' - } + __dataID__: 'client:viewer', + }, }; data = getData({records}, query, 'client:viewer'); expect(data.actor).toBeUndefined(); @@ -849,8 +849,8 @@ describe('readRelayQueryData', () => { user_id: { __dataID__: 'user_id', id: 'user_id', - address: null - } + address: null, + }, }; var data = getData({records}, query, 'user_id'); expect(data.address).toBeNull(); @@ -859,8 +859,8 @@ describe('readRelayQueryData', () => { records = { user_id: { __dataID__: 'user_id', - id: 'user_id' - } + id: 'user_id', + }, }; data = getData({records}, query, 'user_id'); expect(data.address).toBeUndefined(); @@ -881,8 +881,8 @@ describe('readRelayQueryData', () => { var records = { 'client:viewer': { - __dataID__: 'client:viewer' - } + __dataID__: 'client:viewer', + }, }; var data = getData({records}, query, 'client:viewer'); @@ -907,13 +907,13 @@ describe('readRelayQueryData', () => { '123': { __dataID__: '123', birthdate: { - __dataID__: 'client:1' - } + __dataID__: 'client:1', + }, }, 'client:1': { __dataID__: 'client:1', - year: null - } + year: null, + }, }; var data = getData({records}, query, '123'); @@ -933,13 +933,13 @@ describe('readRelayQueryData', () => { 'user_id': { __dataID__: 'user_id', friends: { - __dataID__: 'client:friends' - } + __dataID__: 'client:friends', + }, }, 'client:friends': { __dataID__: 'client:friends', - count: 42 - } + count: 42, + }, }; var data = getData({records}, query, 'user_id'); expect(data.friends.count).toBe(42); @@ -950,14 +950,14 @@ describe('readRelayQueryData', () => { 'user_id': { __dataID__: 'user_id', friends: { - __dataID__: 'client:friends' - } + __dataID__: 'client:friends', + }, }, 'client:friends': { __dataID__: 'client:friends', __range__: new GraphQLRange(), - count: 42 - } + count: 42, + }, }; GraphQLRange.prototype.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['edgeID'], @@ -966,7 +966,7 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, } }); data = getData({records}, query, 'user_id'); @@ -1009,21 +1009,21 @@ describe('readRelayQueryData', () => { __dataID__: 'storyID', id: 'storyID', feedback: { - __dataID__: 'feedbackID' - } + __dataID__: 'feedbackID', + }, }, feedbackID: { __dataID__: 'feedbackID', - id: 'feedbackID' - } + id: 'feedbackID', + }, }; var data = getData({records}, query, 'storyID'); expect(data).toEqual({ __dataID__: 'storyID', id: 'storyID', feedback: { - __dataID__: 'feedbackID' - } + __dataID__: 'feedbackID', + }, }); }); @@ -1055,31 +1055,31 @@ describe('readRelayQueryData', () => { userID: { __dataID__: 'userID', friends: { - __dataID__: 'friendsID' - } + __dataID__: 'friendsID', + }, }, friendsID: { __dataID__: 'friendsID', - __range__: new GraphQLRange() + __range__: new GraphQLRange(), }, edgeID: { __dataID__: 'edgeID', node: { - __dataID__: 'friendID' + __dataID__: 'friendID', }, - cursor: 'cursor' + cursor: 'cursor', }, friendID: { __dataID__: 'friendID', address: { - __dataID__: 'addressID' - } + __dataID__: 'addressID', + }, }, addressID: { __dataID__: 'addressID', city: 'Menlo Park', - country: 'USA' - } + country: 'USA', + }, }; GraphQLRange.prototype.retrieveRangeInfoForQuery.mockReturnValue({ @@ -1089,7 +1089,7 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, } }); @@ -1105,8 +1105,8 @@ describe('readRelayQueryData', () => { __dataID__: 'userID', friends: { __dataID__: 'friendsID_first(25)', - [getNode(fragmentReference).getConcreteFragmentID()]: pointer - } + [getNode(fragmentReference).getConcreteFragmentID()]: pointer, + }, }); // Now we read the inner (non-local) fragment, using the range client ID. @@ -1125,11 +1125,11 @@ describe('readRelayQueryData', () => { address: { __dataID__: 'addressID', city: 'Menlo Park', - country: 'USA' - } - } - } - ] + country: 'USA', + }, + }, + }, + ], }); }); @@ -1138,14 +1138,14 @@ describe('readRelayQueryData', () => { 'client:viewer': { __dataID__: 'client:viewer', actor: { - __dataID__: '660361306' - } + __dataID__: '660361306', + }, }, 660361306: { __dataID__: '660361306', firstName: 'Greg', - id: '660361306' - } + id: '660361306', + }, }; var query = getNode(Relay.QL`query{viewer{actor{firstName}}}`); var data = getData( @@ -1159,8 +1159,8 @@ describe('readRelayQueryData', () => { actor: { __dataID__: '660361306', firstName: 'Greg', - id: '660361306' - } + id: '660361306', + }, }); }); @@ -1179,14 +1179,14 @@ describe('readRelayQueryData', () => { feedbackID: { __dataID__: 'feedbackID', topLevelComments: { - __dataID__: 'commentsID' - } + __dataID__: 'commentsID', + }, }, commentsID: { __dataID__: 'commentsID', __range__: new GraphQLRange(), - count: 57 - } + count: 57, + }, }; GraphQLRange.prototype.retrieveRangeInfoForQuery.mockReturnValue({ @@ -1196,7 +1196,7 @@ describe('readRelayQueryData', () => { [START_CURSOR]: 'cursor', [END_CURSOR]: 'cursor', [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false + [HAS_PREV_PAGE]: false, } }); @@ -1212,9 +1212,9 @@ describe('readRelayQueryData', () => { __dataID__: 'commentsID_first(1)', [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } - } + [HAS_PREV_PAGE]: false, + }, + }, }); }); diff --git a/src/store/filterExclusiveKeys.js b/src/store/filterExclusiveKeys.js index 2b5260d06f383..eaf3122a29eeb 100644 --- a/src/store/filterExclusiveKeys.js +++ b/src/store/filterExclusiveKeys.js @@ -31,7 +31,7 @@ function filterExclusiveKeys( } return [ keysA.filter(key => !hasOwnProperty.call(b, key)), - keysB.filter(key => !hasOwnProperty.call(a, key)) + keysB.filter(key => !hasOwnProperty.call(a, key)), ]; } diff --git a/src/store/observeAllRelayQueryData.js b/src/store/observeAllRelayQueryData.js index 077b5b3f63817..dc1f0581e7872 100644 --- a/src/store/observeAllRelayQueryData.js +++ b/src/store/observeAllRelayQueryData.js @@ -11,8 +11,6 @@ * @flow */ - /* eslint no-unused-expressions: 1 */ - 'use strict'; import type {DataID} from 'RelayInternalTypes'; @@ -93,7 +91,7 @@ class RelayQueryMultipleDataObservable { if (this._lastError) { callbacks.onError(this._lastError); return { - dispose: emptyFunction + dispose: emptyFunction, }; } @@ -112,7 +110,7 @@ class RelayQueryMultipleDataObservable { callbacks.onError(this._lastError); this._disposeSubscriptions(dataIDToSubscriptionIndex); return { - dispose: emptyFunction + dispose: emptyFunction, }; } this._subscribeCalls.push({callbacks, dataIDToSubscriptionIndex}); @@ -140,7 +138,7 @@ class RelayQueryMultipleDataObservable { this._subscriptions = {}; this._wrappedData = {}; } - } + }, }; } @@ -211,7 +209,7 @@ class RelayQueryMultipleDataObservable { subscriptions.push(observer.subscribe({ onCompleted: () => this._handleCompleted(dataID), onError: error => this._handleError(dataID, error), - onNext: data => this._handleNext(dataID, data) + onNext: data => this._handleNext(dataID, data), })); } } diff --git a/src/store/observeRelayQueryData.js b/src/store/observeRelayQueryData.js index 3ef2fa2bd689d..55400d5c2e2fa 100644 --- a/src/store/observeRelayQueryData.js +++ b/src/store/observeRelayQueryData.js @@ -11,9 +11,8 @@ * @flow */ - /* eslint no-unused-expressions: 1 */ - 'use strict'; + var GraphQLStoreChangeEmitter = require('GraphQLStoreChangeEmitter'); var RelayError = require('RelayError'); import type {DataID} from 'RelayInternalTypes'; @@ -103,7 +102,7 @@ class RelayQueryDataObservable { if (this._lastError) { callbacks.onError(this._lastError); return { - dispose: emptyFunction + dispose: emptyFunction, }; } @@ -134,7 +133,7 @@ class RelayQueryDataObservable { // No longer observing any dataIDs this._observedDataIDs = {}; } - } + }, }; } diff --git a/src/store/readRelayQueryData.js b/src/store/readRelayQueryData.js index 64d590c4512f8..4af90235d274d 100644 --- a/src/store/readRelayQueryData.js +++ b/src/store/readRelayQueryData.js @@ -98,7 +98,7 @@ class RelayStoreReader extends RelayQueryVisitor { ): StoreReaderResult { var result = { data: (undefined: $FlowIssue), - dataIDs: ({}: $FlowIssue) + dataIDs: ({}: $FlowIssue), }; var rangeData = GraphQLStoreRangeUtils.parseRangeClientID(dataID); var status = this._recordStore.getRecordStatus( @@ -111,7 +111,7 @@ class RelayStoreReader extends RelayQueryVisitor { parent: null, rangeInfo: null, seenDataIDs: result.dataIDs, - storeDataID: dataID + storeDataID: dataID, }; this.visit(queryNode, state); result.data = state.data; @@ -208,7 +208,7 @@ class RelayStoreReader extends RelayQueryVisitor { parent: node, rangeInfo: null, seenDataIDs: state.seenDataIDs, - storeDataID: dataID + storeDataID: dataID, }; node.getChildren().forEach(child => this.visit(child, nextState)); return nextState.data; @@ -236,7 +236,7 @@ class RelayStoreReader extends RelayQueryVisitor { parent: node, rangeInfo: metadata && calls.length ? metadata : null, seenDataIDs: state.seenDataIDs, - storeDataID: dataID + storeDataID: dataID, }; this.traverse(node, nextState); this._setDataValue(state, applicationName, nextState.data); @@ -255,7 +255,7 @@ class RelayStoreReader extends RelayQueryVisitor { parent: node, rangeInfo: null, seenDataIDs: state.seenDataIDs, - storeDataID: edgeData.edgeID + storeDataID: edgeData.edgeID, }; this.traverse(node, nextState); return nextState.data; @@ -327,7 +327,7 @@ class RelayStoreReader extends RelayQueryVisitor { parent: node, rangeInfo: null, seenDataIDs: state.seenDataIDs, - storeDataID: dataID + storeDataID: dataID, }; var status = this._recordStore.getRecordStatus(dataID); if (status === RelayRecordStatus.EXISTENT) { diff --git a/src/tools/RelayDeprecated.js b/src/tools/RelayDeprecated.js index 05538ff240434..dac63c5827046 100644 --- a/src/tools/RelayDeprecated.js +++ b/src/tools/RelayDeprecated.js @@ -59,13 +59,13 @@ var RelayDeprecated = { var deprecatedProperties = [ 'queries', 'queryParams', - 'processQueryParams' + 'processQueryParams', ].filter(property => maybeSpec.hasOwnProperty(property)); var modernProperties = [ 'fragments', 'initialVariables', - 'prepareVariables' + 'prepareVariables', ].filter(property => maybeSpec.hasOwnProperty(property)); if (modernProperties.length) { @@ -103,7 +103,7 @@ var RelayDeprecated = { if (queryParams && !Mutation.initialVariables) { RelayDeprecated.warn({ was: Mutation.name + '.queryParams', - now: Mutation.name + '.initialVariables' + now: Mutation.name + '.initialVariables', }); Mutation.initialVariables = queryParams; } @@ -115,12 +115,12 @@ var RelayDeprecated = { if (queries && !Mutation.fragments) { RelayDeprecated.warn({ was: Mutation.name + '.queries', - now: Mutation.name + '.fragments' + now: Mutation.name + '.fragments', }); Mutation.fragments = queries; } return Mutation.fragments; - } + }, }; diff --git a/src/tools/RelayError.js b/src/tools/RelayError.js index 9eb28094d9660..f4a5539875aed 100644 --- a/src/tools/RelayError.js +++ b/src/tools/RelayError.js @@ -44,7 +44,7 @@ var RelayError = { ); (error: any).source = errorData; return error; - } + }, }; /** diff --git a/src/tools/RelayProfiler.js b/src/tools/RelayProfiler.js index 7515ffd7fd12c..2f413811f85ef 100644 --- a/src/tools/RelayProfiler.js +++ b/src/tools/RelayProfiler.js @@ -238,7 +238,7 @@ var RelayProfiler = { removeFromArray(profileHandlersByName[name], handler); } } - } + }, }; diff --git a/src/tools/__mocks__/RelayProfiler.js b/src/tools/__mocks__/RelayProfiler.js index 6e5b00fe9ffff..cec1e372b3f70 100644 --- a/src/tools/__mocks__/RelayProfiler.js +++ b/src/tools/__mocks__/RelayProfiler.js @@ -36,7 +36,7 @@ var RelayProfiler = { }; }), attachProfileHandler: jest.genMockFunction(), - detachProfileHandler: jest.genMockFunction() + detachProfileHandler: jest.genMockFunction(), }; module.exports = RelayProfiler; diff --git a/src/tools/__mocks__/RelayTestUtils.js b/src/tools/__mocks__/RelayTestUtils.js index de20009dc5451..220f5ad240183 100644 --- a/src/tools/__mocks__/RelayTestUtils.js +++ b/src/tools/__mocks__/RelayTestUtils.js @@ -43,7 +43,7 @@ var RelayTestUtils = { } } ContextSetter.childContextTypes = { - route: RelayPropTypes.QueryConfig.isRequired + route: RelayPropTypes.QueryConfig.isRequired, }; class MockPointer { @@ -367,7 +367,7 @@ var RelayTestUtils = { 'Expected:', ' ' + printRelayQuery(actualQuery), '\ntoMatchPath:', - ' ' + printRelayQuery(expectedQuery) + ' ' + printRelayQuery(expectedQuery), ].filter(token => token).join('\n'); return false; @@ -474,7 +474,7 @@ var RelayTestUtils = { payload, ); return changeTracker.getChangeSet(); - } + }, }; /** @@ -538,7 +538,7 @@ function printQueryComparison(actual, expected, message) { formatRefParam(actual), message + ':', ' ' + printRelayQuery(expected), - formatRefParam(expected) + formatRefParam(expected), ].filter(line => !!line).join('\n'); } diff --git a/src/tools/__tests__/RelayProfiler-test.js b/src/tools/__tests__/RelayProfiler-test.js index 82f1d4be69dff..bea72a993b8fe 100644 --- a/src/tools/__tests__/RelayProfiler-test.js +++ b/src/tools/__tests__/RelayProfiler-test.js @@ -229,7 +229,7 @@ describe('RelayProfiler', function() { onStop(name) { expect(name).toBe('mockBehavior'); actualOrdering.push('1: afterEnd'); - } + }, }); RelayProfiler.attachProfileHandler('mockBehavior', { @@ -240,14 +240,14 @@ describe('RelayProfiler', function() { onStop(name) { expect(name).toBe('mockBehavior'); actualOrdering.push('2: afterEnd'); - } + }, }); var profiler = RelayProfiler.profile('mockBehavior'); expect(actualOrdering).toEqual([ '2: beforeEnd', - '1: beforeEnd' + '1: beforeEnd', ]); profiler.stop(); @@ -263,7 +263,7 @@ describe('RelayProfiler', function() { it('does not invoke detached profile handlers', () => { var mockHandlers = { onStart: jest.genMockFunction(), - onStop: jest.genMockFunction() + onStop: jest.genMockFunction(), }; RelayProfiler.attachProfileHandler('mockBehavior', mockHandlers); @@ -277,7 +277,7 @@ describe('RelayProfiler', function() { it('passes state to each profile handler', () => { var mockHandlers = { onStart: jest.genMockFunction(), - onStop: jest.genMockFunction() + onStop: jest.genMockFunction(), }; var state = {}; diff --git a/src/traversal/__tests__/checkRelayQueryData-test.js b/src/traversal/__tests__/checkRelayQueryData-test.js index 7dac0c1d5ac80..85c03b8aa1eb8 100644 --- a/src/traversal/__tests__/checkRelayQueryData-test.js +++ b/src/traversal/__tests__/checkRelayQueryData-test.js @@ -89,7 +89,7 @@ describe('checkRelayQueryData', () => { var records = { 1055790163: { id: '1055790163', - __dataID__: '1055790163' + __dataID__: '1055790163', } }; @@ -109,7 +109,7 @@ describe('checkRelayQueryData', () => { var records = { 1055790163: { id: '1055790163', - __dataID__: '1055790163' + __dataID__: '1055790163', } }; @@ -129,7 +129,7 @@ describe('checkRelayQueryData', () => { var records = { 1055790163: { id: '1055790163', - __dataID__: '1055790163' + __dataID__: '1055790163', } }; @@ -151,7 +151,7 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', firstName: 'Yuzhi', - __dataID__: '1055790163' + __dataID__: '1055790163', } }; @@ -174,7 +174,7 @@ describe('checkRelayQueryData', () => { var records = { 1055790163: { id: '1055790163', - __dataID__: '1055790163' + __dataID__: '1055790163', } }; @@ -198,12 +198,12 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - friends: { __dataID__: 'friends_id'} + friends: { __dataID__: 'friends_id'}, }, friends_id: { __dataID__:'friends_id', - count: 500 - } + count: 500, + }, }; var result = hasData(getNode( @@ -226,7 +226,7 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - friends: { __dataID__: 'friends_id'} + friends: { __dataID__: 'friends_id'}, } }; @@ -250,10 +250,10 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - friends: { __dataID__: 'friends_id'} + friends: { __dataID__: 'friends_id'}, }, friends_id: { - __dataID__: 'friends_id' + __dataID__: 'friends_id', } }; @@ -277,7 +277,7 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - screennames: [{__dataID__: 'client:screenname1'}] + screennames: [{__dataID__: 'client:screenname1'}], }, 'client:screenname1': { __dataID__: 'client:screenname1', @@ -305,7 +305,7 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - screennames: [{__dataID__: 'client:screenname1'}] + screennames: [{__dataID__: 'client:screenname1'}], } }; @@ -329,10 +329,10 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - screennames: [{__dataID__: 'client:screenname1'}] + screennames: [{__dataID__: 'client:screenname1'}], }, 'client:screenname1': { - __dataID__: 'client:screenname1' + __dataID__: 'client:screenname1', } }; @@ -356,7 +356,7 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - friends: { __dataID__: 'friends_id'} + friends: { __dataID__: 'friends_id'}, }, friends_id: { __dataID__:'friends_id', @@ -366,7 +366,7 @@ describe('checkRelayQueryData', () => { records.friends_id.__range__.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: [], diffCalls: [], - pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false } + pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false }, }); var result = hasData(getNode( @@ -390,7 +390,7 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - friends: { __dataID__: 'friends_id'} + friends: { __dataID__: 'friends_id'}, }, friends_id: { __dataID__:'friends_id', @@ -400,7 +400,7 @@ describe('checkRelayQueryData', () => { records.friends_id.__range__.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: [], diffCalls: [new GraphQL.Callv('first', 10)], - pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false } + pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false }, }); var result = hasData(getNode( @@ -423,7 +423,7 @@ describe('checkRelayQueryData', () => { var records = { viewer_id: { '__configs__.named(some_gk)': {__dataID__:'configs_id'}, - __dataID__: 'viewer_id' + __dataID__: 'viewer_id', }, configs_id: { __dataID__: 'configs_id', @@ -431,12 +431,12 @@ describe('checkRelayQueryData', () => { }, edge_id: { __dataID__: 'edge_id', - node: {__dataID__:'node_id'} + node: {__dataID__:'node_id'}, }, node_id: { __dataID__: 'node_id', - name: 'some_gk' - } + name: 'some_gk', + }, }; var result = hasData(getNode( @@ -465,7 +465,7 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - friends: { __dataID__: 'friends_id'} + friends: { __dataID__: 'friends_id'}, }, friends_id: { __dataID__:'friends_id', @@ -473,17 +473,17 @@ describe('checkRelayQueryData', () => { }, edge_id: { __dataID__: 'edge_id', - node: {__dataID__:'node_id'} + node: {__dataID__:'node_id'}, }, node_id: { __dataID__: 'node_id', - id: 'node_id' + id: 'node_id', } }; records.friends_id.__range__.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['edge_id'], diffCalls: [], - pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false } + pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false }, }); var result = hasData(getNode( @@ -507,7 +507,7 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - friends: { __dataID__: 'friends_id'} + friends: { __dataID__: 'friends_id'}, }, friends_id: { __dataID__:'friends_id', @@ -519,13 +519,13 @@ describe('checkRelayQueryData', () => { cursor: 'cursor' }, node_id: { - __dataID__: 'node_id' + __dataID__: 'node_id', } }; records.friends_id.__range__.retrieveRangeInfoForQuery.mockReturnValue({ requestedEdgeIDs: ['edge_id'], diffCalls: [], - pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false } + pageInfo: {[HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false }, }); var result = hasData(getNode( @@ -549,7 +549,7 @@ describe('checkRelayQueryData', () => { 1055790163: { id: '1055790163', __dataID__: '1055790163', - username: 'yuzhi' + username: 'yuzhi', } }; diff --git a/src/traversal/__tests__/diffRelayQuery-test.js b/src/traversal/__tests__/diffRelayQuery-test.js index f0f8c3a64d1d2..14a078653e618 100644 --- a/src/traversal/__tests__/diffRelayQuery-test.js +++ b/src/traversal/__tests__/diffRelayQuery-test.js @@ -46,7 +46,7 @@ describe('diffRelayQuery', () => { printRelayQuery = require('printRelayQuery'); rootCallMap = { - viewer: {'': 'client:viewer'} + viewer: {'': 'client:viewer'}, }; jest.addMatchers(RelayTestUtils.matchers); @@ -80,8 +80,8 @@ describe('diffRelayQuery', () => { var records = { '4': { __dataID__: '4', - id: '4' - } + id: '4', + }, }; var store = new RelayRecordStore({records}); var tracker = new RelayQueryTracker(); @@ -103,7 +103,7 @@ describe('diffRelayQuery', () => { __dataID__: '4', id: '4', name: 'Mark' - } + }, }; var store = new RelayRecordStore({records}); var tracker = new RelayQueryTracker(); @@ -124,7 +124,7 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - 'profilePicture.size(32)': 'https://facebook.com' + 'profilePicture.size(32)': 'https://facebook.com', } }; var store = new RelayRecordStore({records}); @@ -146,7 +146,7 @@ describe('diffRelayQuery', () => { '4': { __dataID__: '4', id: '4', - 'profilePicture.size(32)': 'https://facebook.com' + 'profilePicture.size(32)': 'https://facebook.com', } }; var store = new RelayRecordStore({records}); @@ -181,7 +181,7 @@ describe('diffRelayQuery', () => { __dataID__: '4808495', id: '4808495', name: 'Joe' - } + }, }; var store = new RelayRecordStore({records}, {rootCallMap}); var tracker = new RelayQueryTracker(); @@ -216,19 +216,19 @@ describe('diffRelayQuery', () => { __dataID__: 'story', id: 'story', feedback: { - __dataID__: 'story:feedback' - } + __dataID__: 'story:feedback', + }, }, 'story:feedback': { __dataID__: 'story:feedback', topLevelComments: { - __dataID__: 'story:feedback:comments' - } + __dataID__: 'story:feedback:comments', + }, }, 'story:feedback:comments': { __dataID__: 'story:feedback:comments', - count: 5 - } + count: 5, + }, }; var store = new RelayRecordStore({records}); var tracker = new RelayQueryTracker(); @@ -327,19 +327,19 @@ describe('diffRelayQuery', () => { __dataID__: 'story', id: 'story', feedback: { - __dataID__: 'story:feedback' - } + __dataID__: 'story:feedback', + }, }, 'story:feedback': { __dataID__: 'story:feedback', topLevelComments: { - __dataID__: 'story:feedback:comments' - } + __dataID__: 'story:feedback:comments', + }, }, 'story:feedback:comments': { __dataID__: 'story:feedback:comments', - count: 5 - } + count: 5, + }, }; var store = new RelayRecordStore({records}); @@ -380,19 +380,19 @@ describe('diffRelayQuery', () => { __dataID__: 'story', id: 'story', feedback: { - __dataID__: 'story:feedback' - } + __dataID__: 'story:feedback', + }, }, 'story:feedback': { __dataID__: 'story:feedback', topLevelComments: { - __dataID__: 'story:feedback:comments' - } + __dataID__: 'story:feedback:comments', + }, }, 'story:feedback:comments': { __dataID__: 'story:feedback:comments', - count: 5 - } + count: 5, + }, }; var store = new RelayRecordStore({records}); @@ -423,26 +423,26 @@ describe('diffRelayQuery', () => { var mockRange = new GraphQLRange(); mockRange.retrieveRangeInfoForQuery.mockReturnValue({ diffCalls: [], - requestedEdges: [] + requestedEdges: [], }); var records = { story: { __dataID__: 'story', id: 'story', feedback: { - __dataID__: 'story:feedback' - } + __dataID__: 'story:feedback', + }, }, 'story:feedback': { __dataID__: 'story:feedback', topLevelComments: { - __dataID__: 'story:feedback:comments' - } + __dataID__: 'story:feedback:comments', + }, }, 'story:feedback:comments': { __dataID__: 'story:feedback:comments', - __range__: mockRange - } + __range__: mockRange, + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -557,7 +557,7 @@ describe('diffRelayQuery', () => { } }, 'actor': { - __dataID__: 'actor' + __dataID__: 'actor', // `id` should always be fetched, but should work correctly regardless } }; @@ -580,8 +580,8 @@ describe('diffRelayQuery', () => { var records = { '4': { __dataID__: '4', - id: '4' - } + id: '4', + }, }; var store = new RelayRecordStore({records}); var tracker = new RelayQueryTracker(); @@ -658,7 +658,7 @@ describe('diffRelayQuery', () => { var records = { '4': { __dataID__: '4', - friends: null + friends: null, } }; var store = new RelayRecordStore({records}); @@ -1445,7 +1445,7 @@ describe('diffRelayQuery', () => { __dataID__: 'client:4:660361306', node: {__dataID__: '660361306'}, cursor: 'cursor1' - } + }, ]; var records = { '4': { @@ -1566,7 +1566,7 @@ describe('diffRelayQuery', () => { var records = { 'client:viewer': { __dataID__: 'client:viewer', - actor: {__dataID__: '4'} + actor: {__dataID__: '4'}, }, '4': { __dataID__: '4', diff --git a/src/traversal/__tests__/diffRelayQuery_connection-test.js b/src/traversal/__tests__/diffRelayQuery_connection-test.js index d90fc27292fe7..4092e4a4f1c3b 100644 --- a/src/traversal/__tests__/diffRelayQuery_connection-test.js +++ b/src/traversal/__tests__/diffRelayQuery_connection-test.js @@ -48,7 +48,7 @@ describe('diffRelayQuery', () => { ({HAS_NEXT_PAGE, HAS_PREV_PAGE, PAGE_INFO} = RelayConnectionInterface); rootCallMap = { - 'viewer': {'': 'client:viewer'} + 'viewer': {'': 'client:viewer'}, }; jest.addMatchers(RelayTestUtils.matchers); @@ -89,14 +89,14 @@ describe('diffRelayQuery', () => { edges: [ {cursor: 'c1', node: {id: 's1'}}, {cursor: 'c2', node: {id: 's2'}}, - {cursor: 'c3', node: {id: 's3'}} + {cursor: 'c3', node: {id: 's3'}}, ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } - } - } + [HAS_PREV_PAGE]: false, + }, + }, + }, }; var query = getNode(Relay.QL` query { @@ -132,14 +132,14 @@ describe('diffRelayQuery', () => { edges: [ {cursor: 'c1', node: {id: 's1'}}, {cursor: 'c2', node: {id: 's2'}}, - {cursor: 'c3', node: {id: 's3'}} + {cursor: 'c3', node: {id: 's3'}}, ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } - } - } + [HAS_PREV_PAGE]: false, + }, + }, + }, }; var query = getNode(Relay.QL` query { @@ -189,14 +189,14 @@ describe('diffRelayQuery', () => { edges: [ {cursor: 'c1', node: {id:'', message:{text:'s1'}}}, {cursor: 'c2', node: {id:'', message:{text:'s1'}}}, - {cursor: 'c3', node: {id:'', message:{text:'s1'}}} + {cursor: 'c3', node: {id:'', message:{text:'s1'}}}, ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } - } - } + [HAS_PREV_PAGE]: false, + }, + }, + }, }; var writeQuery = getNode(Relay.QL` query { @@ -238,7 +238,7 @@ describe('diffRelayQuery', () => { 'RelayDiffQueryBuilder: connection `node{*}` can only be refetched ' + 'if the node is refetchable by `id`. Cannot refetch data for field ' + '`%s`.', - 'newsFeed' + 'newsFeed', ]).toBeWarnedNTimes(3); }); @@ -254,14 +254,14 @@ describe('diffRelayQuery', () => { edges: [ {cursor: 'c1', node: {id:'s1', message:{text:'s1'}}}, {cursor: 'c2', node: {id:'s2', message:{text:'s1'}}}, - {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}} + {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}}, ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } - } - } + [HAS_PREV_PAGE]: false, + }, + }, + }, }; var writeQuery = getNode(Relay.QL` query { @@ -340,14 +340,14 @@ describe('diffRelayQuery', () => { edges: [ {cursor: 'c1', node: {id:'s1', message:{text:'s1'}}}, {cursor: 'c2', node: {id:'s2', message:{text:'s1'}}}, - {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}} + {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}}, ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } - } - } + [HAS_PREV_PAGE]: false, + }, + }, + }, }; var writeQuery = getNode(Relay.QL` query { @@ -474,14 +474,14 @@ describe('diffRelayQuery', () => { edges: [ {cursor: 'c1', node: {id:'s1', message:{text:'s1'}}}, {cursor: 'c2', node: {id:'s2', message:{text:'s1'}}}, - {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}} + {cursor: 'c3', node: {id:'s3', message:{text:'s1'}}}, ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } - } - } + [HAS_PREV_PAGE]: false, + }, + }, + }, }; var writeQuery = getNode(Relay.QL` query { @@ -552,7 +552,7 @@ describe('diffRelayQuery', () => { 'RelayDiffQueryBuilder: connection `edges{*}` fields can only be ' + 'refetched if the connection supports the `find` call. Cannot ' + 'refetch data for field `%s`.', - 'notificationStories' + 'notificationStories', ]).toBeWarnedNTimes(3); } ); @@ -567,14 +567,14 @@ describe('diffRelayQuery', () => { viewer: { [alias]: { edges: [ - {cursor: 'c1', node: {id:'s1', message:{text:'s1'}}} + {cursor: 'c1', node: {id:'s1', message:{text:'s1'}}}, ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } - } - } + [HAS_PREV_PAGE]: false, + }, + }, + }, }; var writeQuery = getNode(Relay.QL` query { diff --git a/src/traversal/__tests__/flattenSplitRelayQueries-test.js b/src/traversal/__tests__/flattenSplitRelayQueries-test.js index f671c868f50ab..b9f91158e5c1d 100644 --- a/src/traversal/__tests__/flattenSplitRelayQueries-test.js +++ b/src/traversal/__tests__/flattenSplitRelayQueries-test.js @@ -26,7 +26,7 @@ describe('flattenSplitRelayQueries', () => { it('returns an empty array when there are no queries', () => { var split = { required: null, - deferred: [] + deferred: [], }; expect(flattenSplitRelayQueries(split)).toEqual([]); }); @@ -34,7 +34,7 @@ describe('flattenSplitRelayQueries', () => { it('returns a single required query', () => { var split = { required: getQuery(), - deferred: [] + deferred: [], }; expect(flattenSplitRelayQueries(split)).toEqual([split.required]); }); @@ -44,8 +44,8 @@ describe('flattenSplitRelayQueries', () => { required: null, deferred: [{ required: getQuery(), - deferred: [] - }] + deferred: [], + }], }; expect(flattenSplitRelayQueries(split)) .toEqual([split.deferred[0].required]); @@ -57,19 +57,19 @@ describe('flattenSplitRelayQueries', () => { deferred: [ { required: getQuery(), - deferred: [] + deferred: [], }, { required: getQuery(), - deferred: [] - } - ] + deferred: [], + }, + ], }; expect(flattenSplitRelayQueries(split)) .toEqual([ split.required, split.deferred[0].required, - split.deferred[1].required + split.deferred[1].required, ]); }); @@ -81,16 +81,16 @@ describe('flattenSplitRelayQueries', () => { required: getQuery(), deferred: [{ required: getQuery(), - deferred: [] - }] - } - ] + deferred: [], + }], + }, + ], }; expect(flattenSplitRelayQueries(split)) .toEqual([ split.required, split.deferred[0].required, - split.deferred[0].deferred[0].required + split.deferred[0].deferred[0].required, ]); }); }); diff --git a/src/traversal/__tests__/inferRelayFieldsFromData-test.js b/src/traversal/__tests__/inferRelayFieldsFromData-test.js index f94ec3cdb582e..56ad6b6803411 100644 --- a/src/traversal/__tests__/inferRelayFieldsFromData-test.js +++ b/src/traversal/__tests__/inferRelayFieldsFromData-test.js @@ -34,11 +34,9 @@ describe('inferRelayFieldsFromData', function() { inferRelayFieldsFromData = require('inferRelayFieldsFromData'); ({ - END_CURSOR, HAS_NEXT_PAGE, HAS_PREV_PAGE, - PAGE_INFO, - START_CURSOR + PAGE_INFO } = RelayConnectionInterface); jest.addMatchers({ @@ -55,7 +53,7 @@ describe('inferRelayFieldsFromData', function() { it('infers scalar fields from scalars', () => { expect(inferRelayFieldsFromData({ id: '123', - name: 'Alice' + name: 'Alice', })).toEqualFields(Relay.QL` fragment on Actor { id, name, @@ -66,8 +64,8 @@ describe('inferRelayFieldsFromData', function() { expect(inferRelayFieldsFromData({ id: '123', address: { - city: 'Menlo Park' - } + city: 'Menlo Park', + }, })).toEqualFields(Relay.QL` fragment on Actor { id, address { @@ -79,7 +77,7 @@ describe('inferRelayFieldsFromData', function() { it('infers unterminated fields from null', () => { expect(inferRelayFieldsFromData({ id: '123', - address: null + address: null, })).toEqualFields(Relay.QL` fragment on Actor { id, address, @@ -91,8 +89,8 @@ describe('inferRelayFieldsFromData', function() { id: '123', websites: [ 'facebook.com', - 'google.com' - ] + 'google.com', + ], }); expect(fields).toEqualFields(Relay.QL` fragment on Actor { id, @@ -106,8 +104,8 @@ describe('inferRelayFieldsFromData', function() { id: '123', screennames: [ {service: 'GTALK'}, - {service: 'TWITTER'} - ] + {service: 'TWITTER'}, + ], })).toEqualFields(Relay.QL` fragment on Actor { id, screennames { @@ -119,7 +117,7 @@ describe('inferRelayFieldsFromData', function() { it('infers unterminated fields from empty arrays', () => { expect(inferRelayFieldsFromData({ id: '123', - websites: [] + websites: [], })).toEqualFields(Relay.QL` fragment on Actor { id, websites, @@ -129,7 +127,7 @@ describe('inferRelayFieldsFromData', function() { it('infers unterminated fields from null elements in arrays', () => { expect(inferRelayFieldsFromData({ id: '123', - websites: [null] + websites: [null], })).toEqualFields(Relay.QL` fragment on Actor { id, websites, @@ -139,7 +137,7 @@ describe('inferRelayFieldsFromData', function() { it('infers field arguments from keys', () => { expect(inferRelayFieldsFromData({ id: '123', - 'url.site(www)': 'https://...' + 'url.site(www)': 'https://...', })).toEqualFields(Relay.QL` fragment on Actor { id, url(site:"www"), @@ -149,7 +147,7 @@ describe('inferRelayFieldsFromData', function() { it('throws for keys with invalid call encodings', () => { expect(() => { inferRelayFieldsFromData({ - 'url.site': 'https://...' + 'url.site': 'https://...', }); }).toFailInvariant( 'inferRelayFieldsFromData(): Malformed data key, `url.site`.' @@ -162,13 +160,13 @@ describe('inferRelayFieldsFromData', function() { 'friends.first(2)': { edges: [ {node: {name: 'Alice'}}, - {node: {name: 'Bob'}} + {node: {name: 'Bob'}}, ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } - } + [HAS_PREV_PAGE]: false, + }, + }, })).toEqualFields(Relay.QL` fragment on Actor { id, friends(first:"2") { @@ -187,7 +185,7 @@ describe('inferRelayFieldsFromData', function() { expect(inferRelayFieldsFromData({ node: { id: '123', - name: 'name' + name: 'name', } })).toEqualFields(Relay.QL` fragment on NodeSavedStateResponsePayload { node { @@ -203,7 +201,7 @@ describe('inferRelayFieldsFromData', function() { __range__: null, __status__: null, id: '123', - name: 'Alice' + name: 'Alice', })).toEqualFields(Relay.QL` fragment on Node { id, name, diff --git a/src/traversal/__tests__/printRelayQueryCall-test.js b/src/traversal/__tests__/printRelayQueryCall-test.js index a5dce780c2d55..f6ad1ce661be6 100644 --- a/src/traversal/__tests__/printRelayQueryCall-test.js +++ b/src/traversal/__tests__/printRelayQueryCall-test.js @@ -17,7 +17,7 @@ describe('printRelayQueryCall', () => { it('prints a call with a null argument', () => { var call = { name: 'me', - value: null + value: null, }; expect(printRelayQueryCall(call)).toEqual('.me()'); }); @@ -25,7 +25,7 @@ describe('printRelayQueryCall', () => { it('prints a call with an undefined argument', () => { var call = { name: 'me', - value: undefined + value: undefined, }; expect(printRelayQueryCall(call)).toEqual('.me()'); }); @@ -33,7 +33,7 @@ describe('printRelayQueryCall', () => { it('prints a call with a string argument', () => { var call = { name: 'first', - value: '5' + value: '5', }; expect(printRelayQueryCall(call)).toEqual('.first(5)'); }); @@ -41,7 +41,7 @@ describe('printRelayQueryCall', () => { it('prints a call with a numeric argument', () => { var call = { name: 'first', - value: 5 + value: 5, }; expect(printRelayQueryCall(call)).toEqual('.first(5)'); }); @@ -49,7 +49,7 @@ describe('printRelayQueryCall', () => { it('prints a call with `true` argument', () => { var call = { name: 'if', - value: true + value: true, }; expect(printRelayQueryCall(call)).toEqual('.if(true)'); }); @@ -57,7 +57,7 @@ describe('printRelayQueryCall', () => { it('prints a call with `false` argument', () => { var call = { name: 'unless', - value: false + value: false, }; expect(printRelayQueryCall(call)).toEqual('.unless(false)'); }); @@ -65,7 +65,7 @@ describe('printRelayQueryCall', () => { it('prints a call with many arguments', () => { var call = { name: 'usernames', - value: ['glh', 'joesavona'] + value: ['glh', 'joesavona'], }; expect(printRelayQueryCall(call)).toEqual('.usernames(glh,joesavona)'); }); @@ -73,7 +73,7 @@ describe('printRelayQueryCall', () => { it('sanitizes argument values', () => { var call = { name: 'checkin_search_query', - value: JSON.stringify({query: 'Menlo Park'}) + value: JSON.stringify({query: 'Menlo Park'}), }; expect(printRelayQueryCall(call)).toEqual( '.checkin_search_query(\\{"query":"Menlo Park"\\})' @@ -88,12 +88,12 @@ describe('printRelayQueryCall', () => { ' x': '\\ x', 'x ': 'x\\ \\ ', ' x ': '\\ x\\ \\ ', - 'x y': 'x y' + 'x y': 'x y', }; Object.keys(values).forEach(value => { var call = { name: 'node', - value + value, }; var expected = values[value]; expect(printRelayQueryCall(call)).toEqual('.node(' + expected + ')'); diff --git a/src/traversal/__tests__/refragmentRelayQuery-test.js b/src/traversal/__tests__/refragmentRelayQuery-test.js index f86c7f5f4b643..7cf26ce3fb618 100644 --- a/src/traversal/__tests__/refragmentRelayQuery-test.js +++ b/src/traversal/__tests__/refragmentRelayQuery-test.js @@ -33,7 +33,7 @@ describe('refragmentRelayQuery', () => { /* jslint validthis:true */ this.actual = refragmentRelayQuery(flattenRelayQuery(this.actual)); return matchers.toEqualQueryNode.call(this, expected); - } + }, }); }); diff --git a/src/traversal/__tests__/splitDeferredRelayQueries-test.js b/src/traversal/__tests__/splitDeferredRelayQueries-test.js index bea53a0b01cf6..c9a55e4bcadfe 100644 --- a/src/traversal/__tests__/splitDeferredRelayQueries-test.js +++ b/src/traversal/__tests__/splitDeferredRelayQueries-test.js @@ -969,9 +969,9 @@ describe('splitDeferredRelayQueries()', () => { { generated: true, pk: 'id', - rootCall: 'node' + rootCall: 'node', } - ) + ), ] ); queryNode = queryNode.clone( diff --git a/src/traversal/__tests__/writeRelayQueryPayload_connectionField-test.js b/src/traversal/__tests__/writeRelayQueryPayload_connectionField-test.js index b7c0ceb09bcbc..b60b5a49957eb 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_connectionField-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_connectionField-test.js @@ -42,7 +42,7 @@ describe('writeRelayQueryPayload()', () => { HAS_NEXT_PAGE, HAS_PREV_PAGE, PAGE_INFO, - START_CURSOR + START_CURSOR, } = RelayConnectionInterface); jest.addMatchers(RelayTestUtils.matchers); @@ -81,8 +81,8 @@ describe('writeRelayQueryPayload()', () => { edges: [], [PAGE_INFO]: { [HAS_NEXT_PAGE]: false, - [HAS_PREV_PAGE]: false - } + [HAS_PREV_PAGE]: false, + }, } } }; @@ -91,7 +91,7 @@ describe('writeRelayQueryPayload()', () => { expect(results).toEqual({ created: { '123': true, - 'client:1': true // `friends` connection + 'client:1': true, // `friends` connection }, updated: {} }); @@ -104,7 +104,7 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: undefined, [HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false, - [START_CURSOR]: undefined + [START_CURSOR]: undefined, }, requestedEdges: [] }); @@ -172,8 +172,8 @@ describe('writeRelayQueryPayload()', () => { ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } + [HAS_PREV_PAGE]: false, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ @@ -185,7 +185,7 @@ describe('writeRelayQueryPayload()', () => { 'client:client:1:friend3ID': true, 'friend1ID': true, // nodes 'friend2ID': true, - 'friend3ID': true + 'friend3ID': true, }, updated: {} }); @@ -201,12 +201,12 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'friend3', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'friend1' + [START_CURSOR]: 'friend1', }, requestedEdges: [ {edgeID: 'client:client:1:friend1ID', nodeID: 'friend1ID'}, {edgeID: 'client:client:1:friend2ID', nodeID: 'friend2ID'}, - {edgeID: 'client:client:1:friend3ID', nodeID: 'friend3ID'} + {edgeID: 'client:client:1:friend3ID', nodeID: 'friend3ID'}, ] }); }); @@ -243,19 +243,19 @@ describe('writeRelayQueryPayload()', () => { null, { cursor: 'friend2', - node: null + node: null, }, { cursor: 'friend3', node: { id: 'friend3ID' - } + }, } ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } + [HAS_PREV_PAGE]: false, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ @@ -263,7 +263,7 @@ describe('writeRelayQueryPayload()', () => { '123': true, 'client:1': true, // `friends` connection 'client:client:1:friend3ID': true, // edges - 'friend3ID': true + 'friend3ID': true, }, updated: {} }); @@ -277,10 +277,10 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'friend3', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'friend3' + [START_CURSOR]: 'friend3', }, requestedEdges: [ - {edgeID: 'client:client:1:friend3ID', nodeID: 'friend3ID'} + {edgeID: 'client:client:1:friend3ID', nodeID: 'friend3ID'}, ] }); }); @@ -340,21 +340,21 @@ describe('writeRelayQueryPayload()', () => { source: { id: '123' } - } + }, ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } + [HAS_PREV_PAGE]: false, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { 'client:client:1:friend1ID': true, // edges - 'friend1ID': true // nodes + 'friend1ID': true, // nodes }, updated: { - 'client:1': true + 'client:1': true, } }); expect(store.getField('friend1ID', 'id')).toBe('friend1ID'); @@ -367,10 +367,10 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'friend1', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'friend1' + [START_CURSOR]: 'friend1', }, requestedEdges: [ - {edgeID: 'client:client:1:friend1ID', nodeID: 'friend1ID'} + {edgeID: 'client:client:1:friend1ID', nodeID: 'friend1ID'}, ] }); }); @@ -417,10 +417,10 @@ describe('writeRelayQueryPayload()', () => { ], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } - } - } + [HAS_PREV_PAGE]: false, + }, + }, + }, }; expect(() => writePayload(store, query, payload)).toFailInvariant( 'RelayQueryWriter: Cannot write edges for connection ' + @@ -461,8 +461,8 @@ describe('writeRelayQueryPayload()', () => { }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } + [HAS_PREV_PAGE]: false, + }, }; var records = {}; store = new RelayRecordStore({records}); @@ -498,17 +498,17 @@ describe('writeRelayQueryPayload()', () => { }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: true - } + [HAS_PREV_PAGE]: true, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { 'node2': true, - 'client:client:1:node2': true // 2nd edge + 'client:client:1:node2': true, // 2nd edge }, updated: { - 'client:1': true // range updated + 'client:1': true, // range updated } }); expect(store.getRangeMetadata('client:1', [ @@ -520,12 +520,12 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'cursor2', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'cursor1' + [START_CURSOR]: 'cursor1', }, requestedEdges: [ {edgeID: 'client:client:1:node1', nodeID: 'node1'}, - {edgeID: 'client:client:1:node2', nodeID: 'node2'} - ] + {edgeID: 'client:client:1:node2', nodeID: 'node2'}, + ], }); }); @@ -560,16 +560,16 @@ describe('writeRelayQueryPayload()', () => { }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: true - } + [HAS_PREV_PAGE]: true, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - 'node1': true // `name` added + 'node1': true, // `name` added // range not updated, only the node changed - } + }, }); expect(store.getField('node1', 'name')).toBe('Tim'); expect(store.getRangeMetadata('client:1', [ @@ -581,11 +581,11 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'cursor1', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'cursor1' + [START_CURSOR]: 'cursor1', }, requestedEdges: [ - {edgeID: 'client:client:1:node1', nodeID: 'node1'} - ] + {edgeID: 'client:client:1:node1', nodeID: 'node1'}, + ], }); }); @@ -618,7 +618,7 @@ describe('writeRelayQueryPayload()', () => { payload['123'][alias] = { edges: [{ node: { - id: 'node1' + id: 'node1', }, source: { // new edge field id: '456' @@ -627,18 +627,18 @@ describe('writeRelayQueryPayload()', () => { }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: true - } + [HAS_PREV_PAGE]: true, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - '456': true // `source` added + '456': true, // `source` added }, updated: { 'client:1': true, // range updated because an edge had a change - 'client:client:1:node1': true // `source` added to edge - } + 'client:client:1:node1': true, // `source` added to edge + }, }); expect(store.getRangeMetadata('client:1', [ {name: 'first', value: 1} @@ -649,11 +649,11 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'cursor1', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'cursor1' + [START_CURSOR]: 'cursor1', }, requestedEdges: [ - {edgeID: 'client:client:1:node1', nodeID: 'node1'} - ] + {edgeID: 'client:client:1:node1', nodeID: 'node1'}, + ], }); var sourceID = store.getLinkedRecordID('client:client:1:node1', 'source'); expect(sourceID).toBe('456'); @@ -689,17 +689,17 @@ describe('writeRelayQueryPayload()', () => { }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } + [HAS_PREV_PAGE]: false, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { 'node1b': true, - 'client:client:1:node1b': true // edge added but never referenced + 'client:client:1:node1b': true, // edge added but never referenced }, updated: { - 'client:1': true // range updated + 'client:1': true, // range updated } }); expect(store.getField('node1b', 'id')).toBe('node1b'); @@ -712,11 +712,11 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'cursor1', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'cursor1' + [START_CURSOR]: 'cursor1', }, requestedEdges: [ - {edgeID: 'client:client:1:node1', nodeID: 'node1'} - ] + {edgeID: 'client:client:1:node1', nodeID: 'node1'}, + ], }); }); @@ -749,17 +749,17 @@ describe('writeRelayQueryPayload()', () => { }], [PAGE_INFO]: { [HAS_NEXT_PAGE]: true, - [HAS_PREV_PAGE]: false - } + [HAS_PREV_PAGE]: false, + }, }; var results = writePayload(store, query, payload, null, {forceIndex: 1}); expect(results).toEqual({ created: { 'node1b': true, - 'client:client:1:node1b': true + 'client:client:1:node1b': true, }, updated: { - 'client:1': true // range updated + 'client:1': true, // range updated } }); expect(store.getField('node1b', 'id')).toBe('node1b'); @@ -772,11 +772,11 @@ describe('writeRelayQueryPayload()', () => { [END_CURSOR]: 'cursor1b', [HAS_NEXT_PAGE]: true, [HAS_PREV_PAGE]: false, - [START_CURSOR]: 'cursor1b' + [START_CURSOR]: 'cursor1b', }, requestedEdges: [ - {edgeID: 'client:client:1:node1b', nodeID: 'node1b'} - ] + {edgeID: 'client:client:1:node1b', nodeID: 'node1b'}, + ], }); }); }); diff --git a/src/traversal/__tests__/writeRelayQueryPayload_linkedField-test.js b/src/traversal/__tests__/writeRelayQueryPayload_linkedField-test.js index 08123f8cbe8da..1949d71048158 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_linkedField-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_linkedField-test.js @@ -50,15 +50,15 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { viewer: { - actor: null - } + actor: null, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - 'client:viewer': true + 'client:viewer': true, }, - updated: {} + updated: {}, }); expect(store.getRecordStatus(VIEWER_ID)).toBe('EXISTENT'); expect(store.getLinkedRecordID(VIEWER_ID, 'actor')).toBe(null); @@ -69,12 +69,12 @@ describe('writeRelayQueryPayload()', () => { 'client:viewer': { __dataID__: VIEWER_ID, actor: { - __dataID__: 'client:1' - } + __dataID__: 'client:1', + }, }, 'client:1': { - __dataID__: 'client:1' - } + __dataID__: 'client:1', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -88,16 +88,16 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { viewer: { - actor: null - } + actor: null, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { }, updated: { - 'client:viewer': true - } + 'client:viewer': true, + }, }); expect(store.getRecordStatus(VIEWER_ID)).toBe('EXISTENT'); expect(store.getLinkedRecordID(VIEWER_ID, 'actor')).toBe(null); @@ -117,8 +117,8 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { viewer: { - actor: undefined - } + actor: undefined, + }, }; writePayload(store, query, payload); expect(store.getRecordStatus(VIEWER_ID)).toBe('EXISTENT'); @@ -130,13 +130,13 @@ describe('writeRelayQueryPayload()', () => { 'client:viewer': { __dataID__: VIEWER_ID, actor: { - __dataID__: '123' - } + __dataID__: '123', + }, }, '123': { __dataID__: '123', - id: '123' - } + id: '123', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -150,8 +150,8 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { viewer: { - actor: undefined - } + actor: undefined, + }, }; writePayload(store, query, payload); expect(store.getRecordStatus(VIEWER_ID)).toBe('EXISTENT'); @@ -177,16 +177,16 @@ describe('writeRelayQueryPayload()', () => { viewer: { actor: { id: actorID - } - } + }, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { 'client:viewer': true, - '123': true + '123': true, }, - updated: {} + updated: {}, }); expect(store.getLinkedRecordID(VIEWER_ID, 'actor')).toBe(actorID); expect(store.getRecordStatus(actorID)).toBe('EXISTENT'); @@ -220,17 +220,17 @@ describe('writeRelayQueryPayload()', () => { viewer: { actor: { id: nextActorID - } - } + }, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - '456': true + '456': true, }, updated: { - 'client:viewer': true - } + 'client:viewer': true, + }, }); expect(store.getLinkedRecordID(VIEWER_ID, 'actor')).toBe(nextActorID); expect(store.getRecordStatus(nextActorID)).toBe('EXISTENT'); @@ -263,9 +263,9 @@ describe('writeRelayQueryPayload()', () => { expect(results).toEqual({ created: { '123': true, - 'client:1': true + 'client:1': true, }, - updated: {} + updated: {}, }); expect(store.getLinkedRecordID('123', 'address')).toBe(addressID); expect(store.getRecordStatus(addressID)).toBe('EXISTENT'); @@ -304,13 +304,13 @@ describe('writeRelayQueryPayload()', () => { // generated client id address: { city: 'San Francisco' - } - } + }, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, - updated: {} + updated: {}, }); expect(store.getLinkedRecordID('123', 'address')).toBe(addressID); expect(store.getField(addressID, 'city')).toBe('San Francisco'); @@ -323,9 +323,9 @@ describe('writeRelayQueryPayload()', () => { 'hometown': { __dataID__: 'hometown:1' }, - id: 'user:1' + id: 'user:1', }, - 'hometown:1': null + 'hometown:1': null, }; var store = new RelayRecordStore({records}); store.removeRecord('hometown:1'); @@ -343,18 +343,18 @@ describe('writeRelayQueryPayload()', () => { id: 'user:1', 'hometown': { id: 'hometown:1', - name: 'World' + name: 'World', } - } + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - 'hometown:1': true + 'hometown:1': true, }, updated: { - 'user:1': true - } + 'user:1': true, + }, }); }); }); diff --git a/src/traversal/__tests__/writeRelayQueryPayload_paths-test.js b/src/traversal/__tests__/writeRelayQueryPayload_paths-test.js index ad7d6faa849e6..1aebac694cb60 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_paths-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_paths-test.js @@ -72,15 +72,15 @@ describe('writePayload()', () => { var payload = { 'viewer': { actor: { - id: '123' - } - } + id: '123', + }, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { 'client:viewer': true, - '123': true + '123': true, }, updated: {} }); @@ -106,13 +106,13 @@ describe('writePayload()', () => { `); var payload = { '123': { - id: '123' - } + id: '123', + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - '123': true + '123': true, }, updated: {} }); @@ -140,10 +140,10 @@ describe('writePayload()', () => { 'actor': { id: '123', address: { - city: 'San Francisco' - } - } - } + city: 'San Francisco', + }, + }, + }, }; writePayload(store, query, payload); @@ -170,8 +170,8 @@ describe('writePayload()', () => { isVerified: true, phoneNumber: { displayNumber: '1-800-555-1212', // directory assistance - countryCode: '1' - } + countryCode: '1', + }, }; var query = getNode(Relay.QL` query { @@ -189,8 +189,8 @@ describe('writePayload()', () => { var payload = { '123': { id: '123', - allPhones: [phone] - } + allPhones: [phone], + }, }; writePayload(store, query, payload); @@ -241,13 +241,13 @@ describe('writePayload()', () => { node: { id: 'node1', address: { - city: 'San Francisco' - } - } - } - ] - } - } + city: 'San Francisco', + }, + }, + }, + ], + }, + }, }; writePayload(store, query, payload); @@ -288,8 +288,8 @@ describe('writePayload()', () => { var payload = { '123': { id: '123', - name: 'Joe' - } + name: 'Joe', + }, }; writePayload(store, query, payload, tracker); var trackedQueries = tracker.trackNodeForID.mock.calls; @@ -317,9 +317,9 @@ describe('writePayload()', () => { '123': { id: '123', address: { - city: 'San Francisco' - } - } + city: 'San Francisco', + }, + }, }; var addressID = 'client:1'; var addressFragment = getNode(fragment).getChildren()[0]; @@ -335,8 +335,8 @@ describe('writePayload()', () => { it('tracks new linked records', () => { var records = { 'client:viewer': { - __dataID__: 'client:viewer' - } + __dataID__: 'client:viewer', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -352,9 +352,9 @@ describe('writePayload()', () => { viewer: { actor: { id: '123', - name: 'Joe' - } - } + name: 'Joe', + }, + }, }; var tracker = new RelayQueryTracker(); writePayload(store, query, payload, tracker); @@ -368,8 +368,8 @@ describe('writePayload()', () => { var records = { '123': { __dataID__: '123', - id: '123' - } + id: '123', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -389,14 +389,14 @@ describe('writePayload()', () => { isVerified: true, phoneNumber: { displayNumber: '1-800-555-1212', // directory assistance - countryCode: '1' - } + countryCode: '1', + }, }; var payload = { '123': { id: '123', - allPhones: [phone] - } + allPhones: [phone], + }, }; var tracker = new RelayQueryTracker(); writePayload(store, query, payload, tracker); @@ -417,8 +417,8 @@ describe('writePayload()', () => { var records = { '123': { __dataID__: '123', - id: '123' - } + id: '123', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -444,12 +444,12 @@ describe('writePayload()', () => { cursor: 'c1', node: { id: '456', - name: 'Greg' - } - } - ] - } - } + name: 'Greg', + }, + }, + ], + }, + }, }; var tracker = new RelayQueryTracker(); writePayload(store, query, payload, tracker); @@ -477,8 +477,8 @@ describe('writePayload()', () => { var records = { '123': { __dataID__: '123', - id: '123' - } + id: '123', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -504,12 +504,12 @@ describe('writePayload()', () => { cursor: 'c1', node: { id: '456', - name: 'Greg' - } - } - ] - } - } + name: 'Greg', + }, + }, + ], + }, + }, }; var tracker = new RelayQueryTracker(); writePayload(store, query, payload, tracker); @@ -540,12 +540,12 @@ describe('writePayload()', () => { cursor: 'c2', node: { id: '789', - name: 'Jing' - } - } - ] - } - } + name: 'Jing', + }, + }, + ], + }, + }, }; tracker = new RelayQueryTracker(); tracker.trackNodeForID.mockClear(); @@ -594,9 +594,9 @@ describe('writePayload()', () => { allPhones: [ { phoneNumber: { - displayNumber: '1-800-555-1212' // directory assistance - } - } + displayNumber: '1-800-555-1212', // directory assistance + }, + }, ], [alias]: { edges: [ @@ -604,12 +604,12 @@ describe('writePayload()', () => { cursor: 'c1', node: { id: '456', - name: 'Tim' - } - } - ] - } - } + name: 'Tim', + }, + }, + ], + }, + }, }; // populate the store and record the original tracked queries var tracker = new RelayQueryTracker(); @@ -627,7 +627,7 @@ describe('writePayload()', () => { tracker = new RelayQueryTracker(); tracker.trackNodeForID.mockClear(); writePayload(store, query, payload, tracker, { - updateTrackedQueries: true + updateTrackedQueries: true, }); var nextTracked = tracker.trackNodeForID.mock.calls; expect(nextTracked.length).toBe(prevTracked.length); diff --git a/src/traversal/__tests__/writeRelayQueryPayload_pluralLinkedField-test.js b/src/traversal/__tests__/writeRelayQueryPayload_pluralLinkedField-test.js index 1b97007699726..d8e7e75dafa1c 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_pluralLinkedField-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_pluralLinkedField-test.js @@ -37,7 +37,7 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123' + id: '123', } }; var store = new RelayRecordStore({records}); @@ -56,14 +56,14 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - allPhones: [] + allPhones: [], } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true + '123': true, } }); var phoneIDs = store.getLinkedRecordIDs('123', 'allPhones'); @@ -74,7 +74,7 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123' + id: '123', } }; var store = new RelayRecordStore({records}); @@ -108,10 +108,10 @@ describe('writeRelayQueryPayload()', () => { expect(results).toEqual({ created: { 'client:1': true, - 'client:2': true + 'client:2': true, }, updated: { - '123': true + '123': true, } }); var phoneIDs = store.getLinkedRecordIDs('123', 'allPhones'); @@ -153,7 +153,7 @@ describe('writeRelayQueryPayload()', () => { 'client:2': { __dataID__: 'client:2', displayNumber: phone.phoneNumber.displayNumber, - countryCode: phone.phoneNumber.countryCode + countryCode: phone.phoneNumber.countryCode, } }; var store = new RelayRecordStore({records}); @@ -188,7 +188,7 @@ describe('writeRelayQueryPayload()', () => { created: {}, updated: { // intermediate phone object has no changes - 'client:2': true + 'client:2': true, } }); var phoneIDs = store.getLinkedRecordIDs('123', 'allPhones'); @@ -230,7 +230,7 @@ describe('writeRelayQueryPayload()', () => { 'client:2': { __dataID__: 'client:2', displayNumber: phone.phoneNumber.displayNumber, - countryCode: phone.phoneNumber.countryCode + countryCode: phone.phoneNumber.countryCode, } }; var store = new RelayRecordStore({records}); @@ -277,7 +277,7 @@ describe('writeRelayQueryPayload()', () => { '123': { __dataID__: '123', id: '123', - allPhones: [] + allPhones: [], } }; var store = new RelayRecordStore({records}); @@ -296,13 +296,13 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123', - allPhones: [] + allPhones: [], } }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, - updated: {} + updated: {}, }); var phoneIDs = store.getLinkedRecordIDs('123', 'allPhones'); expect(phoneIDs).toEqual([]); diff --git a/src/traversal/__tests__/writeRelayQueryPayload_rootRecord-test.js b/src/traversal/__tests__/writeRelayQueryPayload_rootRecord-test.js index c16b54edd51a8..b67a47c833137 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_rootRecord-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_rootRecord-test.js @@ -47,15 +47,15 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { me: { - id: '123' - } + id: '123', + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - 123: true + 123: true, }, - updated: {} + updated: {}, }); expect(store.getRecordStatus('123')).toBe('EXISTENT'); expect(store.getField('123', 'id')).toBe('123'); @@ -77,17 +77,17 @@ describe('writeRelayQueryPayload()', () => { var payload = { viewer: { actor: { - id: '123' - } - } + id: '123', + }, + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { 'client:viewer': true, - '123': true + '123': true, }, - updated: {} + updated: {}, }); expect(store.getRecordStatus('client:viewer')).toBe('EXISTENT'); expect(store.getLinkedRecordID('client:viewer', 'actor')).toBe('123'); @@ -106,15 +106,15 @@ describe('writeRelayQueryPayload()', () => { `); var payload = { yuzhi: { - id: '1055790163' - } + id: '1055790163', + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - '1055790163': true + '1055790163': true, }, - updated: {} + updated: {}, }); expect(store.getRecordStatus('1055790163')).toBe('EXISTENT'); expect(store.getField('1055790163', 'id')).toBe('1055790163'); @@ -137,15 +137,15 @@ describe('writeRelayQueryPayload()', () => { // no `id` value is present, so the root ID is autogenerated var payload = { 'yuzhi': { - name: 'Yuzhi Zheng' - } + name: 'Yuzhi Zheng', + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - 'client:1': true + 'client:1': true, }, - updated: {} + updated: {}, }); expect(store.getRecordStatus('client:1')).toBe('EXISTENT'); expect(store.getField('client:1', 'name')).toBe('Yuzhi Zheng'); @@ -164,15 +164,15 @@ describe('writeRelayQueryPayload()', () => { `, {path: '$.*.id'}); // This path is bogus. var payload = { '123': { - id: '123' - } + id: '123', + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - '123': true + '123': true, }, - updated: {} + updated: {}, }); expect(store.getRecordStatus('123')).toBe('EXISTENT'); expect(store.getField('123', 'id')).toBe('123'); @@ -189,7 +189,7 @@ describe('writeRelayQueryPayload()', () => { } `); var payload = { - '123': null + '123': null, }; expect(() => { writePayload(store, query, payload); @@ -210,12 +210,12 @@ describe('writeRelayQueryPayload()', () => { } `); var payload = { - '123': null + '123': null, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, - updated: {} + updated: {}, }); expect(store.getRecordStatus('123')).toBe('NONEXISTENT'); }); @@ -236,14 +236,14 @@ describe('writeRelayQueryPayload()', () => { } `); var payload = { - '123': null + '123': null, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true - } + '123': true, + }, }); expect(store.getRecordStatus('123')).toBe('NONEXISTENT'); }); @@ -261,12 +261,12 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { __dataID__: '123', - id: '123' + id: '123', }, '456': { __dataID__: '456', - id: '456' - } + id: '456', + }, }; expect(() => { writePayload(store, query, payload); @@ -297,7 +297,7 @@ describe('writeRelayQueryPayload()', () => { __dataID__: '456', id: '456', name: 'Jing', - } + }, }; writePayload(store, query, payload); expect(store.getRecordStatus('123')).toBe('EXISTENT'); @@ -317,7 +317,7 @@ describe('writeRelayQueryPayload()', () => { } `); var payload = { - '123': undefined + '123': undefined, }; expect(() => { writePayload(store, query, payload); @@ -346,7 +346,7 @@ describe('writeRelayQueryPayload()', () => { } `); var payload = { - '123': undefined + '123': undefined, }; expect(() => { writePayload(store, query, payload); @@ -370,14 +370,14 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123' - } + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: { '123': true }, - updated: {} + updated: {}, }); expect(store.getRecordStatus('123')).toBe('EXISTENT'); }); @@ -386,8 +386,8 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123' - } + id: '123', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -400,12 +400,12 @@ describe('writeRelayQueryPayload()', () => { var payload = { '123': { id: '123' - } + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, - updated: {} + updated: {}, }); expect(store.getRecordStatus('123')).toBe('EXISTENT'); }); @@ -416,7 +416,7 @@ describe('writeRelayQueryPayload()', () => { __dataID__: '123', id: '123', name: 'Joe' - } + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -431,14 +431,14 @@ describe('writeRelayQueryPayload()', () => { '123': { id: '123', name: 'Joseph' - } + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, updated: { - '123': true - } + '123': true, + }, }); expect(store.getRecordStatus('123')).toBe('EXISTENT'); expect(store.getField('123', 'name')).toBe('Joseph'); @@ -448,8 +448,8 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123' - } + id: '123', + }, }; var store = new RelayRecordStore({records}); var query = getNode(Relay.QL` @@ -463,12 +463,12 @@ describe('writeRelayQueryPayload()', () => { '123': { id: '123', name: 'Joseph' - } + }, }; var results = writePayload(store, query, payload); expect(results).toEqual({ created: {}, - updated: {} + updated: {}, }); expect(store.getRecordStatus('123')).toBe('EXISTENT'); expect(store.getField('123', 'name')).toBe(undefined); diff --git a/src/traversal/__tests__/writeRelayQueryPayload_scalarField-test.js b/src/traversal/__tests__/writeRelayQueryPayload_scalarField-test.js index 49ac356ec8c42..48c2345d2d7c8 100644 --- a/src/traversal/__tests__/writeRelayQueryPayload_scalarField-test.js +++ b/src/traversal/__tests__/writeRelayQueryPayload_scalarField-test.js @@ -53,7 +53,7 @@ describe('writeRelayQueryPayload()', () => { var results = writePayload(store, query, payload); expect(results).toEqual({ created: { - '123': true + '123': true, }, updated: {} }); @@ -64,7 +64,7 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123' + id: '123', } }; var store = new RelayRecordStore({records}); @@ -85,7 +85,7 @@ describe('writeRelayQueryPayload()', () => { expect(results).toEqual({ created: {}, updated: { - '123': true + '123': true, } }); expect(store.getField('123', 'name')).toBe(null); @@ -117,7 +117,7 @@ describe('writeRelayQueryPayload()', () => { expect(results).toEqual({ created: {}, updated: { - '123': true + '123': true, } }); expect(store.getField('123', 'name')).toBe(null); @@ -148,7 +148,7 @@ describe('writeRelayQueryPayload()', () => { var records = { '123': { __dataID__: '123', - id: '123' + id: '123', } }; var store = new RelayRecordStore({records}); diff --git a/src/traversal/__tests__/writeRelayUpdatePayload-test.js b/src/traversal/__tests__/writeRelayUpdatePayload-test.js index 1cdd7f57506cd..4a375c437737e 100644 --- a/src/traversal/__tests__/writeRelayUpdatePayload-test.js +++ b/src/traversal/__tests__/writeRelayUpdatePayload-test.js @@ -103,12 +103,12 @@ describe('writePayload()', () => { { cursor: commentID + ':cursor', node: { - id: commentID - } - } - ] - } - } + id: commentID, + }, + }, + ], + }, + }, }; writePayload(store, query, payload); connectionID = store.getLinkedRecordID( @@ -122,7 +122,7 @@ describe('writePayload()', () => { // create the mutation and payload var input = { [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', - deletedCommentId: commentID + deletedCommentId: commentID, }; var mutation = getNode(Relay.QL` mutation { @@ -136,12 +136,12 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input) + input: JSON.stringify(input), }); var configs = [{ type: RelayMutationType.RANGE_DELETE, deletedIDFieldName: 'deletedCommentId', - pathToConnection: ['feedback', 'topLevelComments'] + pathToConnection: ['feedback', 'topLevelComments'], }]; var payload = { @@ -151,9 +151,9 @@ describe('writePayload()', () => { feedback: { id: 'feedback_id', topLevelComments: { - count: 0 - } - } + count: 0, + }, + }, }; // write to the queued store @@ -176,9 +176,9 @@ describe('writePayload()', () => { created: {}, updated: { [connectionID]: true, // range edge deleted & count changed - [edgeID]: true // edge deleted + [edgeID]: true, // edge deleted // `commentID` is not modified - } + }, }); expect(queueStore.getField(connectionID, 'count')).toBe(0); @@ -197,7 +197,7 @@ describe('writePayload()', () => { connectionID, [{name: 'first', value: '1'}] ).requestedEdges.map(edge => edge.edgeID)).toEqual([ - edgeID + edgeID, ]); }); @@ -205,7 +205,7 @@ describe('writePayload()', () => { // create the mutation and payload var input = { [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', - deletedCommentId: commentID + deletedCommentId: commentID, }; var mutation = getNode(Relay.QL` mutation { @@ -219,12 +219,12 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input) + input: JSON.stringify(input), }); var configs = [{ type: RelayMutationType.RANGE_DELETE, deletedIDFieldName: 'deletedCommentId', - pathToConnection: ['feedback', 'topLevelComments'] + pathToConnection: ['feedback', 'topLevelComments'], }]; var payload = { @@ -234,9 +234,9 @@ describe('writePayload()', () => { feedback: { id: 'feedback_id', topLevelComments: { - count: 0 - } - } + count: 0, + }, + }, }; // write to the queued store @@ -259,9 +259,9 @@ describe('writePayload()', () => { created: {}, updated: { [connectionID]: true, // range edge deleted & count changed - [edgeID]: true // edge deleted + [edgeID]: true, // edge deleted // `commentID` is not modified - } + }, }); expect(store.getField(connectionID, 'count')).toBe(0); @@ -325,18 +325,18 @@ describe('writePayload()', () => { { cursor: firstCommentID + ':cursor', node: { - id: firstCommentID - } + id: firstCommentID, + }, }, { cursor: secondCommentID + ':cursor', node: { - id: secondCommentID - } - } - ] - } - } + id: secondCommentID, + }, + }, + ], + }, + }, }; writePayload(store, query, payload); @@ -350,7 +350,7 @@ describe('writePayload()', () => { var input = { actor_id: 'actor:123', [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', - deletedCommentId: firstCommentID + deletedCommentId: firstCommentID, }; var mutation = getNode(Relay.QL` mutation { @@ -365,11 +365,11 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input) + input: JSON.stringify(input), }); var configs = [{ type: RelayMutationType.NODE_DELETE, - deletedIDFieldName: 'deletedCommentId' + deletedIDFieldName: 'deletedCommentId', }]; var payload = { @@ -379,9 +379,9 @@ describe('writePayload()', () => { feedback: { id: feedbackID, topLevelComments: { - count: 0 - } - } + count: 0, + }, + }, }; // write to the queued store @@ -405,8 +405,8 @@ describe('writePayload()', () => { updated: { [connectionID]: true, // range item deleted & count changed [firstEdgeID]: true, // edge deleted - [firstCommentID]: true // node deleted - } + [firstCommentID]: true, // node deleted + }, }); // node is deleted @@ -420,7 +420,7 @@ describe('writePayload()', () => { connectionID, [{name: 'first', value: '2'}] ).requestedEdges.map(edge => edge.edgeID)).toEqual([ - secondEdgeID + secondEdgeID, ]); // connection metadata is merged into the queued store expect(queueStore.getField(connectionID, 'count')).toBe(0); @@ -437,7 +437,7 @@ describe('writePayload()', () => { [{name: 'first', value: '2'}] ).requestedEdges.map(edge => edge.edgeID)).toEqual([ firstEdgeID, - secondEdgeID + secondEdgeID, ]); }); @@ -446,7 +446,7 @@ describe('writePayload()', () => { var input = { actor_id: 'actor:123', [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', - deletedCommentId: firstCommentID + deletedCommentId: firstCommentID, }; var mutation = getNode(Relay.QL` mutation { @@ -461,11 +461,11 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input) + input: JSON.stringify(input), }); var configs = [{ type: RelayMutationType.NODE_DELETE, - deletedIDFieldName: 'deletedCommentId' + deletedIDFieldName: 'deletedCommentId', }]; var payload = { @@ -475,9 +475,9 @@ describe('writePayload()', () => { feedback: { id: feedbackID, topLevelComments: { - count: 0 - } - } + count: 0, + }, + }, }; // write to the base store @@ -501,8 +501,8 @@ describe('writePayload()', () => { updated: { [connectionID]: true, // range item deleted & count changed [firstEdgeID]: true, // edge deleted - [firstCommentID]: true // node deleted - } + [firstCommentID]: true, // node deleted + }, }); // node is deleted @@ -516,7 +516,7 @@ describe('writePayload()', () => { connectionID, [{name: 'first', value: '1'}] ).requestedEdges.map(edge => edge.edgeID)).toEqual([ - secondEdgeID + secondEdgeID, ]); // connection metadata is merged into the queued store expect(store.getField(connectionID, 'count')).toBe(0); @@ -556,14 +556,14 @@ describe('writePayload()', () => { `); var payload = { request1: { - id: firstRequestID + id: firstRequestID, }, request2: { - id: secondRequestID + id: secondRequestID, }, request3: { - id: secondRequestID - } + id: secondRequestID, + }, }; writePayload(store, query, payload); @@ -574,7 +574,7 @@ describe('writePayload()', () => { var input = { actor_id: 'actor:123', [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', - deletedRequestIds: [firstRequestID, secondRequestID] + deletedRequestIds: [firstRequestID, secondRequestID], }; var mutation = getNode(Relay.QL` mutation { @@ -583,17 +583,17 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input) + input: JSON.stringify(input), }); var configs = [{ type: RelayMutationType.NODE_DELETE, - deletedIDFieldName: 'deletedRequestIds' + deletedIDFieldName: 'deletedRequestIds', }]; var payload = { [RelayConnectionInterface.CLIENT_MUTATION_ID]: input[RelayConnectionInterface.CLIENT_MUTATION_ID], - deletedRequestIds: [firstRequestID, secondRequestID] + deletedRequestIds: [firstRequestID, secondRequestID], }; // write to the queued store @@ -616,8 +616,8 @@ describe('writePayload()', () => { created: {}, updated: { [firstRequestID]: true, // node deleted - [secondRequestID]: true // node deleted - } + [secondRequestID]: true, // node deleted + }, }); // node is deleted @@ -638,7 +638,7 @@ describe('writePayload()', () => { var input = { actor_id: 'actor:123', [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', - deletedRequestIds: [firstRequestID, secondRequestID] + deletedRequestIds: [firstRequestID, secondRequestID], }; var mutation = getNode(Relay.QL` mutation { @@ -647,11 +647,11 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input) + input: JSON.stringify(input), }); var configs = [{ type: RelayMutationType.NODE_DELETE, - deletedIDFieldName: 'deletedRequestIds' + deletedIDFieldName: 'deletedRequestIds', }]; var payload = { @@ -680,8 +680,8 @@ describe('writePayload()', () => { created: {}, updated: { [firstRequestID]: true, // node deleted - [secondRequestID]: true - } + [secondRequestID]: true, + }, }); // node is deleted @@ -740,12 +740,12 @@ describe('writePayload()', () => { { cursor: commentID + ':cursor', node: { - id: commentID - } - } - ] - } - } + id: commentID, + }, + }, + ], + }, + }, }; writePayload(store, query, payload); @@ -757,7 +757,7 @@ describe('writePayload()', () => { var input = { actor_id: 'actor:123', [RelayConnectionInterface.CLIENT_MUTATION_ID]: '0', - feedback_id: feedbackID + feedback_id: feedbackID, }; var mutation = getNode(Relay.QL` mutation { @@ -776,7 +776,7 @@ describe('writePayload()', () => { type: RelayMutationType.RANGE_ADD, connectionName: 'topLevelComments', edgeName: 'feedbackCommentEdge', - rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND} + rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND}, }]; var payload = { [RelayConnectionInterface.CLIENT_MUTATION_ID]: @@ -784,9 +784,9 @@ describe('writePayload()', () => { feedback: { id: feedbackID, topLevelComments: { - count: 2 - } - } + count: 2, + }, + }, }; // write to queued store @@ -809,7 +809,7 @@ describe('writePayload()', () => { 'writeRelayUpdatePayload(): Expected response payload to include the ' + 'newly created edge `%s` and its `node` field. Did you forget to ' + 'update the `RANGE_ADD` mutation config?', - 'feedbackCommentEdge' + 'feedbackCommentEdge', ]).toBeWarnedNTimes(1); // feedback is updated, but the edge is not added @@ -828,7 +828,7 @@ describe('writePayload()', () => { feedback_id: feedbackID, message: { text: 'Hello!', - ranges: [] + ranges: [], } }; @@ -856,13 +856,13 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input) + input: JSON.stringify(input), }); var configs = [{ type: RelayMutationType.RANGE_ADD, connectionName: 'topLevelComments', edgeName: 'feedbackCommentEdge', - rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND} + rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND}, }]; var nextCursor = 'comment789:cursor'; @@ -875,21 +875,21 @@ describe('writePayload()', () => { feedback: { id: feedbackID, topLevelComments: { - count: 2 - } + count: 2, + }, }, feedbackCommentEdge: { cursor: nextCursor, node: { id: nextNodeID, body: { - text: input.message.text - } + text: input.message.text, + }, }, source: { - id: feedbackID - } - } + id: feedbackID, + }, + }, }; // write to queued store @@ -912,11 +912,11 @@ describe('writePayload()', () => { created: { [nextNodeID]: true, // node added [nextEdgeID]: true, // edge added - [bodyID]: true // `body` subfield + [bodyID]: true, // `body` subfield }, updated: { - [connectionID]: true // range item added & count changed - } + [connectionID]: true, // range item added & count changed + }, }); // queued records are updated: edge/node added @@ -958,7 +958,7 @@ describe('writePayload()', () => { feedback_id: feedbackID, message: { text: 'Hello!', - ranges: [] + ranges: [], } }; @@ -986,13 +986,13 @@ describe('writePayload()', () => { } } `, { - input: JSON.stringify(input) + input: JSON.stringify(input), }); var configs = [{ type: RelayMutationType.RANGE_ADD, connectionName: 'topLevelComments', edgeName: 'feedbackCommentEdge', - rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND} + rangeBehaviors: {'': GraphQLMutatorConstants.PREPEND}, }]; var nextCursor = 'comment789:cursor'; @@ -1005,21 +1005,21 @@ describe('writePayload()', () => { feedback: { id: feedbackID, topLevelComments: { - count: 2 - } + count: 2, + }, }, feedbackCommentEdge: { cursor: nextCursor, node: { id: nextNodeID, body: { - text: input.message.text - } + text: input.message.text, + }, }, source: { - id: feedbackID - } - } + id: feedbackID, + }, + }, }; // write to base store @@ -1042,11 +1042,11 @@ describe('writePayload()', () => { created: { [nextNodeID]: true, // node added [nextEdgeID]: true, // edge added - [bodyID]: true // `body` subfield + [bodyID]: true, // `body` subfield }, updated: { - [connectionID]: true // range item added & count changed - } + [connectionID]: true, // range item added & count changed + }, }); // base records are updated: edge/node added diff --git a/src/traversal/checkRelayQueryData.js b/src/traversal/checkRelayQueryData.js index 615240a812170..c7e51509fdb88 100644 --- a/src/traversal/checkRelayQueryData.js +++ b/src/traversal/checkRelayQueryData.js @@ -48,7 +48,7 @@ function checkRelayQueryData( var state = { dataID: undefined, rangeInfo: undefined, - result: true + result: true, }; checker.visit(query, state); @@ -93,7 +93,7 @@ class RelayQueryChecker extends RelayQueryVisitor { nextState = { dataID, rangeInfo: undefined, - result: true + result: true, }; this.traverse(root, nextState); state.result = state.result && nextState.result; @@ -152,7 +152,7 @@ class RelayQueryChecker extends RelayQueryVisitor { var nextState = { dataID: dataIDs[ii], rangeInfo: undefined, - result: true + result: true, }; this.traverse(field, nextState); state.result = nextState.result; @@ -171,7 +171,7 @@ class RelayQueryChecker extends RelayQueryVisitor { var nextState = { dataID, rangeInfo: null, // Flow rejects `undefined` here - result: true + result: true, }; var metadata = this._store.getRangeMetadata(dataID, calls); if (metadata) { @@ -199,7 +199,7 @@ class RelayQueryChecker extends RelayQueryVisitor { var nextState = { dataID: edges[ii].edgeID, rangeInfo: undefined, - result: true + result: true, }; this.traverse(field, nextState); state.result = nextState.result; @@ -225,7 +225,7 @@ class RelayQueryChecker extends RelayQueryVisitor { var nextState = { dataID, rangeInfo: undefined, - result: true + result: true, }; this.traverse(field, nextState); state.result = state.result && nextState.result; diff --git a/src/traversal/diffRelayQuery.js b/src/traversal/diffRelayQuery.js index 1d56b25bd6eda..c663307f95e7c 100644 --- a/src/traversal/diffRelayQuery.js +++ b/src/traversal/diffRelayQuery.js @@ -224,7 +224,7 @@ class RelayDiffQueryBuilder { } else if (node.isGenerated()) { return { diffNode: node, - trackedNode: null + trackedNode: null, }; } else if (node.isConnection()) { return this.diffConnection(node, path, dataID); @@ -300,7 +300,7 @@ class RelayDiffQueryBuilder { return { diffNode, - trackedNode + trackedNode, }; } @@ -314,7 +314,7 @@ class RelayDiffQueryBuilder { if (this._store.getField(dataID, field.getStorageKey()) === undefined) { return { diffNode: field, - trackedNode: null + trackedNode: null, }; } return null; @@ -334,7 +334,7 @@ class RelayDiffQueryBuilder { if (nextDataID === undefined) { return { diffNode: field, - trackedNode: null + trackedNode: null, }; } if (nextDataID === null) { @@ -363,7 +363,7 @@ class RelayDiffQueryBuilder { // not fetched return { diffNode: field, - trackedNode: null + trackedNode: null, }; } else if (linkedIDs === null || linkedIDs.length === 0) { // empty array means nothing to fetch @@ -401,7 +401,7 @@ class RelayDiffQueryBuilder { if (hasSplitQueries) { return { diffNode: null, - trackedNode: field + trackedNode: field, }; } } else { @@ -440,7 +440,7 @@ class RelayDiffQueryBuilder { if (connectionID === undefined) { return { diffNode: field, - trackedNode: null + trackedNode: null, }; } // Skip if the connection is deleted. @@ -468,7 +468,7 @@ class RelayDiffQueryBuilder { connectionField: field, dataID: connectionID, edgeID: edge.edgeID, - rangeInfo + rangeInfo, }; var diffOutput = this.traverse( field, @@ -488,7 +488,7 @@ class RelayDiffQueryBuilder { connectionField: field, dataID: connectionID, edgeID: null, - rangeInfo + rangeInfo, }; // diff non-`edges` fields such as `count` var diffOutput = this.traverse( @@ -547,7 +547,7 @@ class RelayDiffQueryBuilder { '`%s`.', connectionField.getStorageKey() ); - return {}; + return; } var hasSplitQueries = false; @@ -613,7 +613,7 @@ class RelayDiffQueryBuilder { // be tracked. return { diffNode: null, - trackedNode: hasSplitQueries ? edgeField : trackedNode + trackedNode: hasSplitQueries ? edgeField : trackedNode, }; } } @@ -626,7 +626,7 @@ function makeScope(dataID: DataID): DiffScope { connectionField: null, dataID, edgeID: null, - rangeInfo: null + rangeInfo: null, }; } @@ -718,7 +718,7 @@ function splitNodeAndEdgesFields( } return { edges: hasEdgeChild ? edgeOrFragment.clone(edgeChildren) : null, - node: hasNodeChild ? edgeOrFragment.clone(nodeChildren) : null + node: hasNodeChild ? edgeOrFragment.clone(nodeChildren) : null, }; } diff --git a/src/traversal/inferRelayFieldsFromData.js b/src/traversal/inferRelayFieldsFromData.js index 12df81614972b..77a35d4054e22 100644 --- a/src/traversal/inferRelayFieldsFromData.js +++ b/src/traversal/inferRelayFieldsFromData.js @@ -86,7 +86,7 @@ function buildField( var value = captures[2].split(','); return { name: captures[1], - value: value.length === 1 ? value[0] : value + value: value.length === 1 ? value[0] : value, }; }); } diff --git a/src/traversal/splitDeferredRelayQueries.js b/src/traversal/splitDeferredRelayQueries.js index 6ff45991178d9..b8b86b79a1069 100644 --- a/src/traversal/splitDeferredRelayQueries.js +++ b/src/traversal/splitDeferredRelayQueries.js @@ -43,7 +43,7 @@ function splitDeferredRelayQueries(node: RelayQuery.Root): SplitQueries { __path__: [], __refQuery__: null, deferred: [], - required: null + required: null, }; splitter.visit(node, splitQueries); @@ -223,7 +223,7 @@ function createRefQuery( [node], { isDeferred: true, - rootArg: RelayNodeInterface.ID + rootArg: RelayNodeInterface.ID, }, context.getName() ); @@ -284,7 +284,7 @@ class GraphQLSplitDeferredQueries extends RelayQueryTransform { __path__: path, __refQuery__: null, deferred: [], - required: null + required: null, }; var result = this.traverse(node, deferred); if (result) { diff --git a/src/traversal/subtractRelayQuery.js b/src/traversal/subtractRelayQuery.js index 3b2f4dd247d75..78ff24c8c6c1d 100644 --- a/src/traversal/subtractRelayQuery.js +++ b/src/traversal/subtractRelayQuery.js @@ -40,7 +40,7 @@ function subtractRelayQuery( var visitor = new RelayQuerySubtractor(); var state = { isEmpty: true, - subtrahend + subtrahend, }; var diff = visitor.visit(minuend, state); if (!state.isEmpty) { @@ -124,7 +124,7 @@ class RelayQuerySubtractor extends RelayQueryTransform { for (var ii = 0; ii < subtrahendRanges.length; ii++) { fieldState = { isEmpty: true, - subtrahend: subtrahendRanges[ii] + subtrahend: subtrahendRanges[ii], }; diff = this._subtractChildren(diff, fieldState); state.isEmpty = fieldState.isEmpty; @@ -151,7 +151,7 @@ class RelayQuerySubtractor extends RelayQueryTransform { var fieldState = { isEmpty: true, - subtrahend: subField + subtrahend: subField, }; var diff = this._subtractChildren(node, fieldState); state.isEmpty = fieldState.isEmpty; diff --git a/src/traversal/writeRelayUpdatePayload.js b/src/traversal/writeRelayUpdatePayload.js index f2c91d5ed4c39..2a3a7412fc202 100644 --- a/src/traversal/writeRelayUpdatePayload.js +++ b/src/traversal/writeRelayUpdatePayload.js @@ -54,7 +54,7 @@ var ID = 'id'; var IGNORED_KEYS = { error: true, /* $FlowIssue #7728187 - Computed Property */ - [CLIENT_MUTATION_ID]: true + [CLIENT_MUTATION_ID]: true, }; var STUB_CURSOR_ID = 'client:cursor'; From b38d1ebb54c092b9ccd7d118b08fc8c1e73650d4 Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Sun, 16 Aug 2015 19:49:07 +0100 Subject: [PATCH 10/14] add previously removed commas --- src/container/RelayContainer.js | 2 +- src/legacy/store/__mocks__/GraphQLQueryRunner.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/container/RelayContainer.js b/src/container/RelayContainer.js index da2ef142b3165..bafeef274f722 100644 --- a/src/container/RelayContainer.js +++ b/src/container/RelayContainer.js @@ -965,7 +965,7 @@ function create( ContainerConstructor.getQueryNames = RelayDeprecated.createWarning({ was: componentName + '.getQueryNames', now: componentName + '.getFragmentNames', - adapter: ContainerConstructor.getFragmentNames + adapter: ContainerConstructor.getFragmentNames, }); /** diff --git a/src/legacy/store/__mocks__/GraphQLQueryRunner.js b/src/legacy/store/__mocks__/GraphQLQueryRunner.js index e770a240e6dee..37618f744fbde 100644 --- a/src/legacy/store/__mocks__/GraphQLQueryRunner.js +++ b/src/legacy/store/__mocks__/GraphQLQueryRunner.js @@ -45,7 +45,7 @@ function genMockRequest(args) { }, fail(error) { args[1]({aborted: false, done: false, error, ready, stale: false}); - } + }, }; } From b481201278e76948b30aecc70e3ed5bc8afd93b9 Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Sun, 16 Aug 2015 22:32:38 +0100 Subject: [PATCH 11/14] fix failing tests --- src/container/__tests__/RelayContainer-test.js | 4 ---- src/container/__tests__/RelayRootContainer-test.js | 1 - .../store/__tests__/GraphQLDeferredQueryTracker-test.js | 1 - src/legacy/store/__tests__/GraphQLRange-test.js | 1 - src/mutation/__tests__/RelayMutation-test.js | 1 - src/query/__tests__/RelayFragmentReference-test.js | 3 --- src/query/__tests__/RelayQueryPath-test.js | 1 - src/query/__tests__/RelayQueryTransform-test.js | 3 --- src/query/__tests__/RelayQueryVisitor-test.js | 3 --- src/query/__tests__/toGraphQL-test.js | 1 - src/store/__tests__/RelayPendingQueryTracker-test.js | 4 ---- src/store/__tests__/RelayRecordStore_write-test.js | 1 - src/store/__tests__/observeRelayQueryData-test.js | 2 -- src/store/__tests__/readRelayQueryData-test.js | 1 - src/traversal/__tests__/checkRelayQueryData-test.js | 3 --- src/traversal/__tests__/diffRelayQuery-test.js | 3 --- src/traversal/__tests__/diffRelayQuery_connection-test.js | 1 - src/traversal/__tests__/splitDeferredRelayQueries-test.js | 3 --- 18 files changed, 37 deletions(-) diff --git a/src/container/__tests__/RelayContainer-test.js b/src/container/__tests__/RelayContainer-test.js index f80064042e667..e6933c7b0b0ff 100644 --- a/src/container/__tests__/RelayContainer-test.js +++ b/src/container/__tests__/RelayContainer-test.js @@ -49,12 +49,9 @@ describe('RelayContainer', function() { React = require('React'); ReactTestUtils = require('ReactTestUtils'); Relay = require('Relay'); - RelayMetaRoute = require('RelayMetaRoute'); RelayQuery = require('RelayQuery'); RelayRoute = require('RelayRoute'); - toGraphQL = require('toGraphQL'); - var render = jest.genMockFunction().mockImplementation(function() { // Make it easier to expect prop values. render.mock.calls[render.mock.calls.length - 1].props = this.props; @@ -204,7 +201,6 @@ describe('RelayContainer', function() { ` } }); - sideshowFragment = new GraphQL.QueryFragment('Test', 'Viewer'); feedFragment = new GraphQL.QueryFragment('Test', 'Viewer', [ new GraphQL.Field('newsFeed'), diff --git a/src/container/__tests__/RelayRootContainer-test.js b/src/container/__tests__/RelayRootContainer-test.js index 340275a8e09c9..6bfed2154721d 100644 --- a/src/container/__tests__/RelayRootContainer-test.js +++ b/src/container/__tests__/RelayRootContainer-test.js @@ -43,7 +43,6 @@ describe('RelayRootContainer', function() { RelayRootContainer = require('RelayRootContainer'); RelayRoute = require('RelayRoute'); RelayStore = require('RelayStore'); - RelayTypes = require('RelayTypes'); ReactComponent = React.createClass({render: () =>
}); RelayContainer = Relay.createContainer(ReactComponent, { diff --git a/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js b/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js index 212e3d5ab05b4..0489fa445bb91 100644 --- a/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js +++ b/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js @@ -40,7 +40,6 @@ describe('GraphQLDeferredQueryTracker', () => { RelayStoreData = require('RelayStoreData'); flattenSplitRelayQueries = require('flattenSplitRelayQueries'); - getWeakIdForObject = require('getWeakIdForObject'); splitDeferredRelayQueries = require('splitDeferredRelayQueries'); recordStore = RelayStoreData.getDefaultInstance().getRecordStore(); diff --git a/src/legacy/store/__tests__/GraphQLRange-test.js b/src/legacy/store/__tests__/GraphQLRange-test.js index 5a3413fb453a7..13d9f3384cae2 100644 --- a/src/legacy/store/__tests__/GraphQLRange-test.js +++ b/src/legacy/store/__tests__/GraphQLRange-test.js @@ -86,7 +86,6 @@ describe('GraphQLRange', () => { origConsoleWarn = console.warn; GraphQLRange = require('GraphQLRange'); - GraphQL = require('GraphQL'); GraphQLStoreDataHandler = require('GraphQLStoreDataHandler'); RelayConnectionInterface = require('RelayConnectionInterface'); diff --git a/src/mutation/__tests__/RelayMutation-test.js b/src/mutation/__tests__/RelayMutation-test.js index 25633f71a30da..eb1607f8bcbab 100644 --- a/src/mutation/__tests__/RelayMutation-test.js +++ b/src/mutation/__tests__/RelayMutation-test.js @@ -33,7 +33,6 @@ describe('RelayMutation', function() { jest.resetModuleRegistry(); Relay = require('Relay'); - RelayQuery = require('RelayQuery'); buildRQL = require('buildRQL'); fromGraphQL = require('fromGraphQL'); diff --git a/src/query/__tests__/RelayFragmentReference-test.js b/src/query/__tests__/RelayFragmentReference-test.js index 985d8cf5daa88..38967acf65dd2 100644 --- a/src/query/__tests__/RelayFragmentReference-test.js +++ b/src/query/__tests__/RelayFragmentReference-test.js @@ -27,9 +27,6 @@ describe('RelayFragmentReference', () => { Relay = require('Relay'); RelayFragmentReference = require('RelayFragmentReference'); RelayMetaRoute = require('RelayMetaRoute'); - RelayQuery = require('RelayQuery'); - - generateRQLFieldAlias = require('generateRQLFieldAlias'); route = new RelayMetaRoute(''); }); diff --git a/src/query/__tests__/RelayQueryPath-test.js b/src/query/__tests__/RelayQueryPath-test.js index 946ed34699b00..e87d54a1a147b 100644 --- a/src/query/__tests__/RelayQueryPath-test.js +++ b/src/query/__tests__/RelayQueryPath-test.js @@ -36,7 +36,6 @@ describe('RelayQueryPath', () => { jest.resetModuleRegistry(); Relay = require('Relay'); - RelayQuery = require('RelayQuery'); RelayQueryPath = require('RelayQueryPath'); fromJSON = RelayQueryPath.fromJSON; diff --git a/src/query/__tests__/RelayQueryTransform-test.js b/src/query/__tests__/RelayQueryTransform-test.js index 25eeabbc25bd0..06a71caad7ff1 100644 --- a/src/query/__tests__/RelayQueryTransform-test.js +++ b/src/query/__tests__/RelayQueryTransform-test.js @@ -23,13 +23,10 @@ describe('RelayQueryTransform', () => { var query; beforeEach(() => { - GraphQL = require('GraphQL'); Relay = require('Relay'); RelayQuery = require('RelayQuery'); RelayQueryTransform = require('RelayQueryTransform'); - generateRQLFieldAlias = require('generateRQLFieldAlias'); - var variables = { first: 10, after: 'offset', diff --git a/src/query/__tests__/RelayQueryVisitor-test.js b/src/query/__tests__/RelayQueryVisitor-test.js index 4d320483315e6..1e198d196b000 100644 --- a/src/query/__tests__/RelayQueryVisitor-test.js +++ b/src/query/__tests__/RelayQueryVisitor-test.js @@ -23,13 +23,10 @@ describe('RelayQueryVisitor', () => { var query; beforeEach(() => { - GraphQL = require('GraphQL'); Relay = require('Relay'); RelayQuery = require('RelayQuery'); RelayQueryVisitor = require('RelayQueryVisitor'); - generateRQLFieldAlias = require('generateRQLFieldAlias'); - var variables = { first: 10, after: 'offset', diff --git a/src/query/__tests__/toGraphQL-test.js b/src/query/__tests__/toGraphQL-test.js index 63426e719fb0e..cb25133a0ec2a 100644 --- a/src/query/__tests__/toGraphQL-test.js +++ b/src/query/__tests__/toGraphQL-test.js @@ -26,7 +26,6 @@ describe('toGraphQL', function() { beforeEach(function() { jest.resetModuleRegistry(); - GraphQL = require('GraphQL'); Relay = require('Relay'); fromGraphQL = require('fromGraphQL'); diff --git a/src/store/__tests__/RelayPendingQueryTracker-test.js b/src/store/__tests__/RelayPendingQueryTracker-test.js index 549b9a10b5ef2..0ef28efa8e028 100644 --- a/src/store/__tests__/RelayPendingQueryTracker-test.js +++ b/src/store/__tests__/RelayPendingQueryTracker-test.js @@ -33,16 +33,12 @@ describe('RelayPendingQueryTracker', () => { jest.resetModuleRegistry(); DliteFetchModeConstants = require('DliteFetchModeConstants'); - GraphQL = require('GraphQL'); - Promise = require('Promise'); Relay = require('Relay'); RelayPendingQueryTracker = require('RelayPendingQueryTracker'); - RelayQuery = require('RelayQuery'); RelayStoreData = require('RelayStoreData'); fetchRelayQuery = require('fetchRelayQuery'); subtractRelayQuery = require('subtractRelayQuery'); - toGraphQL = require('toGraphQL'); writeRelayQueryPayload = require('writeRelayQueryPayload'); subtractRelayQuery.mockImplementation(query => query); diff --git a/src/store/__tests__/RelayRecordStore_write-test.js b/src/store/__tests__/RelayRecordStore_write-test.js index 553da00a6bb61..806607c3a0755 100644 --- a/src/store/__tests__/RelayRecordStore_write-test.js +++ b/src/store/__tests__/RelayRecordStore_write-test.js @@ -25,7 +25,6 @@ describe('RelayRecordStore', () => { beforeEach(() => { jest.resetModuleRegistry(); - GraphQL = require('GraphQL'); GraphQLRange = require('GraphQLRange'); RelayConnectionInterface = require('RelayConnectionInterface'); RelayMockCacheManager = require('RelayMockCacheManager'); diff --git a/src/store/__tests__/observeRelayQueryData-test.js b/src/store/__tests__/observeRelayQueryData-test.js index 5bc1ba7fdfed8..206b9f60743ac 100644 --- a/src/store/__tests__/observeRelayQueryData-test.js +++ b/src/store/__tests__/observeRelayQueryData-test.js @@ -41,12 +41,10 @@ describe('observeRelayQueryData', () => { GraphQLStoreChangeEmitter = require('GraphQLStoreChangeEmitter'); Relay = require('Relay'); - RelayQuery = require('RelayQuery'); RelayRecordStore = require('RelayRecordStore'); addListenerForIDs = GraphQLStoreChangeEmitter.addListenerForIDs; observeRelayQueryData = require('observeRelayQueryData'); - readRelayQueryData = require('readRelayQueryData'); firstMockCallback = jest.genMockFunction(); secondMockCallback = jest.genMockFunction(); diff --git a/src/store/__tests__/readRelayQueryData-test.js b/src/store/__tests__/readRelayQueryData-test.js index 6fa5338d4db0f..00497cb1bf06d 100644 --- a/src/store/__tests__/readRelayQueryData-test.js +++ b/src/store/__tests__/readRelayQueryData-test.js @@ -46,7 +46,6 @@ describe('readRelayQueryData', () => { Relay = require('Relay'); RelayConnectionInterface = require('RelayConnectionInterface'); RelayFragmentReference = require('RelayFragmentReference'); - RelayQuery = require('RelayQuery'); RelayRecordStore = require('RelayRecordStore'); callsToGraphQL = require('callsToGraphQL'); readRelayQueryData = require('readRelayQueryData'); diff --git a/src/traversal/__tests__/checkRelayQueryData-test.js b/src/traversal/__tests__/checkRelayQueryData-test.js index 85c03b8aa1eb8..92a1fd833ef5c 100644 --- a/src/traversal/__tests__/checkRelayQueryData-test.js +++ b/src/traversal/__tests__/checkRelayQueryData-test.js @@ -44,14 +44,11 @@ describe('checkRelayQueryData', () => { GraphQL = require('GraphQL'); GraphQLRange = require('GraphQLRange'); - GraphQLStoreRangeUtils = require('GraphQLStoreRangeUtils'); Relay = require('Relay'); RelayConnectionInterface = require('RelayConnectionInterface'); - RelayQuery = require('RelayQuery'); RelayRecordStore = require('RelayRecordStore'); checkRelayQueryData = require('checkRelayQueryData'); - emptyFunction = require('emptyFunction'); ({HAS_NEXT_PAGE, HAS_PREV_PAGE} = RelayConnectionInterface); }); diff --git a/src/traversal/__tests__/diffRelayQuery-test.js b/src/traversal/__tests__/diffRelayQuery-test.js index 14a078653e618..369adf64dbd3f 100644 --- a/src/traversal/__tests__/diffRelayQuery-test.js +++ b/src/traversal/__tests__/diffRelayQuery-test.js @@ -32,18 +32,15 @@ describe('diffRelayQuery', () => { beforeEach(() => { jest.resetModuleRegistry(); - GraphQL = require('GraphQL'); GraphQLRange = require('GraphQLRange'); Relay = require('Relay'); RelayConnectionInterface = require('RelayConnectionInterface'); RelayQuery = require('RelayQuery'); - RelayQueryPath = require('RelayQueryPath'); RelayQueryTracker = require('RelayQueryTracker'); RelayRecordStore = require('RelayRecordStore'); diffRelayQuery = require('diffRelayQuery'); filterRelayQuery = require('filterRelayQuery'); - printRelayQuery = require('printRelayQuery'); rootCallMap = { viewer: {'': 'client:viewer'}, diff --git a/src/traversal/__tests__/diffRelayQuery_connection-test.js b/src/traversal/__tests__/diffRelayQuery_connection-test.js index 4092e4a4f1c3b..e63b4f41941b7 100644 --- a/src/traversal/__tests__/diffRelayQuery_connection-test.js +++ b/src/traversal/__tests__/diffRelayQuery_connection-test.js @@ -38,7 +38,6 @@ describe('diffRelayQuery', () => { Relay = require('Relay'); RelayConnectionInterface = require('RelayConnectionInterface'); - RelayQuery = require('RelayQuery'); RelayQueryTracker = require('RelayQueryTracker'); RelayRecordStore = require('RelayRecordStore'); diff --git a/src/traversal/__tests__/splitDeferredRelayQueries-test.js b/src/traversal/__tests__/splitDeferredRelayQueries-test.js index c9a55e4bcadfe..5d8b6ef183e43 100644 --- a/src/traversal/__tests__/splitDeferredRelayQueries-test.js +++ b/src/traversal/__tests__/splitDeferredRelayQueries-test.js @@ -39,14 +39,11 @@ describe('splitDeferredRelayQueries()', () => { // Reset query numbers back to q0. jest.resetModuleRegistry(); - GraphQL = require('GraphQL'); Relay = require('Relay'); RelayQuery = require('RelayQuery'); - RelayQueryTransform = require('RelayQueryTransform'); RelayTestUtils = require('RelayTestUtils'); flattenRelayQuery = require('flattenRelayQuery'); generateRQLFieldAlias = require('generateRQLFieldAlias'); - printRelayQuery = require('printRelayQuery'); splitDeferredRelayQueries = require('splitDeferredRelayQueries'); jest.addMatchers(RelayTestUtils.matchers); From e40a9506c4c32796c54c17a1f9d64464c5db272e Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Thu, 20 Aug 2015 14:19:31 +0100 Subject: [PATCH 12/14] remove forgotten tags from confilct merge --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index 7644d31915d8c..c9f39dddef532 100644 --- a/package.json +++ b/package.json @@ -43,12 +43,9 @@ "babel-relay-plugin": "^0.1.2", "del": "^1.2.0", "envify": "^3.4.0", -<<<<<<< HEAD "eslint": "^1.1.0", "eslint-plugin-react": "^3.2.3", -======= "flow-bin": "0.14.0", ->>>>>>> master "graphql": "^0.2.6", "gulp": "^3.9.0", "gulp-babel": "^5.1.0", From eb8974b364b5d1d213800d5fb49503f42eeee0ef Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Thu, 20 Aug 2015 14:42:34 +0100 Subject: [PATCH 13/14] fix failing tests --- src/query/RelayQueryTransform.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/query/RelayQueryTransform.js b/src/query/RelayQueryTransform.js index 3b097fedb5810..020924c71e2d8 100644 --- a/src/query/RelayQueryTransform.js +++ b/src/query/RelayQueryTransform.js @@ -13,6 +13,8 @@ 'use strict'; +import type RelayQuery from 'RelayQuery'; // eslint-disable-line + var RelayQueryVisitor = require('RelayQueryVisitor'); /** From f59650a0b35d4566c1105acda2a48163a147b009 Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Tue, 25 Aug 2015 00:17:56 +0100 Subject: [PATCH 14/14] remove all changes made to src/ --- .eslintrc | 2 -- src/__forks__/interface/RelayConnectionInterface.js | 2 +- src/__forks__/traversal/printRelayQuery.js | 1 + src/container/__tests__/RelayContainer-test.js | 8 ++++++++ src/container/__tests__/RelayRootContainer-test.js | 2 ++ src/legacy/store/GraphQLStoreQueryResolver.js | 1 + .../store/__tests__/GraphQLDeferredQueryTracker-test.js | 2 ++ src/legacy/store/__tests__/GraphQLRange-test.js | 2 ++ src/mutation/RelayMutation.js | 1 + src/mutation/__tests__/RelayMutation-test.js | 2 ++ src/query/RelayQuerySerializer.js | 8 ++++++++ src/query/RelayQueryTransform.js | 2 +- src/query/__tests__/RelayFragmentReference-test.js | 6 ++++++ src/query/__tests__/RelayQueryPath-test.js | 2 ++ src/query/__tests__/RelayQueryTransform-test.js | 6 ++++++ src/query/__tests__/RelayQueryVisitor-test.js | 6 ++++++ src/query/__tests__/toGraphQL-test.js | 2 ++ src/store/__tests__/RelayPendingQueryTracker-test.js | 8 ++++++++ src/store/__tests__/RelayRecordStore_write-test.js | 2 ++ src/store/__tests__/observeRelayQueryData-test.js | 4 ++++ src/store/__tests__/readRelayQueryData-test.js | 2 ++ src/tools/RelayTypes.js | 2 +- src/traversal/__tests__/checkRelayQueryData-test.js | 6 ++++++ src/traversal/__tests__/diffRelayQuery-test.js | 6 ++++++ src/traversal/__tests__/diffRelayQuery_connection-test.js | 2 ++ src/traversal/__tests__/inferRelayFieldsFromData-test.js | 6 ++++-- src/traversal/__tests__/splitDeferredRelayQueries-test.js | 6 ++++++ 27 files changed, 92 insertions(+), 7 deletions(-) diff --git a/.eslintrc b/.eslintrc index 07278ef7fb9cc..207a858b6b1c3 100644 --- a/.eslintrc +++ b/.eslintrc @@ -32,10 +32,8 @@ rules: strict: [2, global] # Make this a warning for now. We do this in a few places so we might need to # disable - eol-last: 2 dot-notation: 2 dot-location: [2, property] - no-unused-vars: [2, args: none] quotes: [2, single, avoid-escape] no-multi-spaces: 2 diff --git a/src/__forks__/interface/RelayConnectionInterface.js b/src/__forks__/interface/RelayConnectionInterface.js index 835871afd0586..6af932564931d 100644 --- a/src/__forks__/interface/RelayConnectionInterface.js +++ b/src/__forks__/interface/RelayConnectionInterface.js @@ -80,4 +80,4 @@ var RelayConnectionInterface = { }, }; -module.exports = RelayConnectionInterface; +module.exports = RelayConnectionInterface; \ No newline at end of file diff --git a/src/__forks__/traversal/printRelayQuery.js b/src/__forks__/traversal/printRelayQuery.js index 9da6093bf00b3..05048fb33c725 100644 --- a/src/__forks__/traversal/printRelayQuery.js +++ b/src/__forks__/traversal/printRelayQuery.js @@ -13,6 +13,7 @@ 'use strict'; +import type {Call} from 'RelayInternalTypes'; var RelayProfiler = require('RelayProfiler'); var RelayQuery = require('RelayQuery'); diff --git a/src/container/__tests__/RelayContainer-test.js b/src/container/__tests__/RelayContainer-test.js index b6733ad53c39d..46ed7f73490a3 100644 --- a/src/container/__tests__/RelayContainer-test.js +++ b/src/container/__tests__/RelayContainer-test.js @@ -25,9 +25,12 @@ describe('RelayContainer', function() { var React; var ReactTestUtils; var Relay; + var RelayMetaRoute; var RelayQuery; var RelayRoute; + var toGraphQL; + var MockContainer; var MockComponent; var RelayTestRenderer; @@ -49,9 +52,12 @@ describe('RelayContainer', function() { React = require('React'); ReactTestUtils = require('ReactTestUtils'); Relay = require('Relay'); + RelayMetaRoute = require('RelayMetaRoute'); RelayQuery = require('RelayQuery'); RelayRoute = require('RelayRoute'); + toGraphQL = require('toGraphQL'); + var render = jest.genMockFunction().mockImplementation(function() { // Make it easier to expect prop values. render.mock.calls[render.mock.calls.length - 1].props = this.props; @@ -207,6 +213,7 @@ describe('RelayContainer', function() { }); describe('conditional fragments', () => { + var sideshowFragment; var MockFeed; var feedFragment; @@ -220,6 +227,7 @@ describe('RelayContainer', function() { ` } }); + sideshowFragment = new GraphQL.QueryFragment('Test', 'Viewer'); feedFragment = new GraphQL.QueryFragment('Test', 'Viewer', [ new GraphQL.Field('newsFeed'), diff --git a/src/container/__tests__/RelayRootContainer-test.js b/src/container/__tests__/RelayRootContainer-test.js index 6bfed2154721d..16dccbdb6b9ca 100644 --- a/src/container/__tests__/RelayRootContainer-test.js +++ b/src/container/__tests__/RelayRootContainer-test.js @@ -24,6 +24,7 @@ describe('RelayRootContainer', function() { var RelayRootContainer; var RelayRoute; var RelayStore; + var RelayTypes; var ReactComponent; var RelayContainer; @@ -43,6 +44,7 @@ describe('RelayRootContainer', function() { RelayRootContainer = require('RelayRootContainer'); RelayRoute = require('RelayRoute'); RelayStore = require('RelayStore'); + RelayTypes = require('RelayTypes'); ReactComponent = React.createClass({render: () =>
}); RelayContainer = Relay.createContainer(ReactComponent, { diff --git a/src/legacy/store/GraphQLStoreQueryResolver.js b/src/legacy/store/GraphQLStoreQueryResolver.js index b45e7a9d28343..11f5f986108b5 100644 --- a/src/legacy/store/GraphQLStoreQueryResolver.js +++ b/src/legacy/store/GraphQLStoreQueryResolver.js @@ -24,6 +24,7 @@ import type RelayQuery from 'RelayQuery'; var RelayStoreData = require('RelayStoreData'); import type {StoreReaderData} from 'RelayTypes'; +var invariant = require('invariant'); var filterExclusiveKeys = require('filterExclusiveKeys'); var readRelayQueryData = require('readRelayQueryData'); var recycleNodesInto = require('recycleNodesInto'); diff --git a/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js b/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js index 0489fa445bb91..44046fcd61f03 100644 --- a/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js +++ b/src/legacy/store/__tests__/GraphQLDeferredQueryTracker-test.js @@ -22,6 +22,7 @@ describe('GraphQLDeferredQueryTracker', () => { var RelayStoreData; var flattenSplitRelayQueries; + var getWeakIdForObject; var splitDeferredRelayQueries; var {defer, getNode} = RelayTestUtils; @@ -40,6 +41,7 @@ describe('GraphQLDeferredQueryTracker', () => { RelayStoreData = require('RelayStoreData'); flattenSplitRelayQueries = require('flattenSplitRelayQueries'); + getWeakIdForObject = require('getWeakIdForObject'); splitDeferredRelayQueries = require('splitDeferredRelayQueries'); recordStore = RelayStoreData.getDefaultInstance().getRecordStore(); diff --git a/src/legacy/store/__tests__/GraphQLRange-test.js b/src/legacy/store/__tests__/GraphQLRange-test.js index 13d9f3384cae2..336e194ef634a 100644 --- a/src/legacy/store/__tests__/GraphQLRange-test.js +++ b/src/legacy/store/__tests__/GraphQLRange-test.js @@ -72,6 +72,7 @@ var last5Edges = [edge96, edge97, edge98, edge99, edge100]; describe('GraphQLRange', () => { var GraphQLRange; var GraphQLStoreDataHandler; + var GraphQL; var RelayConnectionInterface; var origConsoleError; @@ -86,6 +87,7 @@ describe('GraphQLRange', () => { origConsoleWarn = console.warn; GraphQLRange = require('GraphQLRange'); + GraphQL = require('GraphQL'); GraphQLStoreDataHandler = require('GraphQLStoreDataHandler'); RelayConnectionInterface = require('RelayConnectionInterface'); diff --git a/src/mutation/RelayMutation.js b/src/mutation/RelayMutation.js index 294f68c5081cf..6cbe3221d53f5 100644 --- a/src/mutation/RelayMutation.js +++ b/src/mutation/RelayMutation.js @@ -14,6 +14,7 @@ 'use strict'; import type GraphQL from 'GraphQL'; +import type GraphQLFragmentPointer from 'GraphQLFragmentPointer'; var RelayDeprecated = require('RelayDeprecated'); var RelayFragmentReference = require('RelayFragmentReference'); import type RelayMetaRoute from 'RelayMetaRoute'; diff --git a/src/mutation/__tests__/RelayMutation-test.js b/src/mutation/__tests__/RelayMutation-test.js index eb1607f8bcbab..409df1bfc5a24 100644 --- a/src/mutation/__tests__/RelayMutation-test.js +++ b/src/mutation/__tests__/RelayMutation-test.js @@ -21,6 +21,7 @@ jest describe('RelayMutation', function() { var MockMutation; var Relay; + var RelayQuery; var buildRQL; var fromGraphQL; @@ -33,6 +34,7 @@ describe('RelayMutation', function() { jest.resetModuleRegistry(); Relay = require('Relay'); + RelayQuery = require('RelayQuery'); buildRQL = require('buildRQL'); fromGraphQL = require('fromGraphQL'); diff --git a/src/query/RelayQuerySerializer.js b/src/query/RelayQuerySerializer.js index f428352603c37..58fcdd550f960 100644 --- a/src/query/RelayQuerySerializer.js +++ b/src/query/RelayQuerySerializer.js @@ -27,6 +27,14 @@ type Field = { metadata: {[key: string]: mixed} }; +type Query = { + kind: 'Query'; + name: string; + calls: Array; + children: Array; + metadata: {[key: string]: mixed} +}; + type FragmentDefinition = { kind: 'FragmentDefinition'; name: string; diff --git a/src/query/RelayQueryTransform.js b/src/query/RelayQueryTransform.js index 020924c71e2d8..7858f64a27574 100644 --- a/src/query/RelayQueryTransform.js +++ b/src/query/RelayQueryTransform.js @@ -13,7 +13,7 @@ 'use strict'; -import type RelayQuery from 'RelayQuery'; // eslint-disable-line +import type RelayQuery from 'RelayQuery'; var RelayQueryVisitor = require('RelayQueryVisitor'); diff --git a/src/query/__tests__/RelayFragmentReference-test.js b/src/query/__tests__/RelayFragmentReference-test.js index 38967acf65dd2..7891aa57bb777 100644 --- a/src/query/__tests__/RelayFragmentReference-test.js +++ b/src/query/__tests__/RelayFragmentReference-test.js @@ -19,6 +19,9 @@ describe('RelayFragmentReference', () => { var Relay; var RelayFragmentReference; var RelayMetaRoute; + var RelayQuery; + + var generateRQLFieldAlias; var route; @@ -27,6 +30,9 @@ describe('RelayFragmentReference', () => { Relay = require('Relay'); RelayFragmentReference = require('RelayFragmentReference'); RelayMetaRoute = require('RelayMetaRoute'); + RelayQuery = require('RelayQuery'); + + generateRQLFieldAlias = require('generateRQLFieldAlias'); route = new RelayMetaRoute(''); }); diff --git a/src/query/__tests__/RelayQueryPath-test.js b/src/query/__tests__/RelayQueryPath-test.js index e87d54a1a147b..62ee3237d1310 100644 --- a/src/query/__tests__/RelayQueryPath-test.js +++ b/src/query/__tests__/RelayQueryPath-test.js @@ -16,6 +16,7 @@ RelayTestUtils.unmockRelay(); describe('RelayQueryPath', () => { var Relay; + var RelayQuery; var RelayQueryPath; var fromJSON; @@ -36,6 +37,7 @@ describe('RelayQueryPath', () => { jest.resetModuleRegistry(); Relay = require('Relay'); + RelayQuery = require('RelayQuery'); RelayQueryPath = require('RelayQueryPath'); fromJSON = RelayQueryPath.fromJSON; diff --git a/src/query/__tests__/RelayQueryTransform-test.js b/src/query/__tests__/RelayQueryTransform-test.js index 06a71caad7ff1..dfa4b68f82e25 100644 --- a/src/query/__tests__/RelayQueryTransform-test.js +++ b/src/query/__tests__/RelayQueryTransform-test.js @@ -15,18 +15,24 @@ var RelayTestUtils = require('RelayTestUtils'); RelayTestUtils.unmockRelay(); describe('RelayQueryTransform', () => { + var GraphQL; var Relay; var RelayQuery; var RelayQueryTransform; + var generateRQLFieldAlias; + var {getNode} = RelayTestUtils; var query; beforeEach(() => { + GraphQL = require('GraphQL'); Relay = require('Relay'); RelayQuery = require('RelayQuery'); RelayQueryTransform = require('RelayQueryTransform'); + generateRQLFieldAlias = require('generateRQLFieldAlias'); + var variables = { first: 10, after: 'offset', diff --git a/src/query/__tests__/RelayQueryVisitor-test.js b/src/query/__tests__/RelayQueryVisitor-test.js index 1e198d196b000..af95a324cdb0e 100644 --- a/src/query/__tests__/RelayQueryVisitor-test.js +++ b/src/query/__tests__/RelayQueryVisitor-test.js @@ -15,18 +15,24 @@ var RelayTestUtils = require('RelayTestUtils'); RelayTestUtils.unmockRelay(); describe('RelayQueryVisitor', () => { + var GraphQL; var Relay; var RelayQuery; var RelayQueryVisitor; + var generateRQLFieldAlias; + var {getNode} = RelayTestUtils; var query; beforeEach(() => { + GraphQL = require('GraphQL'); Relay = require('Relay'); RelayQuery = require('RelayQuery'); RelayQueryVisitor = require('RelayQueryVisitor'); + generateRQLFieldAlias = require('generateRQLFieldAlias'); + var variables = { first: 10, after: 'offset', diff --git a/src/query/__tests__/toGraphQL-test.js b/src/query/__tests__/toGraphQL-test.js index cb25133a0ec2a..9cc23016fd219 100644 --- a/src/query/__tests__/toGraphQL-test.js +++ b/src/query/__tests__/toGraphQL-test.js @@ -15,6 +15,7 @@ var RelayTestUtils = require('RelayTestUtils'); RelayTestUtils.unmockRelay(); describe('toGraphQL', function() { + var GraphQL; var Relay; var fromGraphQL; @@ -26,6 +27,7 @@ describe('toGraphQL', function() { beforeEach(function() { jest.resetModuleRegistry(); + GraphQL = require('GraphQL'); Relay = require('Relay'); fromGraphQL = require('fromGraphQL'); diff --git a/src/store/__tests__/RelayPendingQueryTracker-test.js b/src/store/__tests__/RelayPendingQueryTracker-test.js index 0ef28efa8e028..60da1c73cf27f 100644 --- a/src/store/__tests__/RelayPendingQueryTracker-test.js +++ b/src/store/__tests__/RelayPendingQueryTracker-test.js @@ -18,13 +18,17 @@ jest.dontMock('RelayPendingQueryTracker'); describe('RelayPendingQueryTracker', () => { var DliteFetchModeConstants; + var GraphQL; + var Promise; var Relay; var RelayPendingQueryTracker; + var RelayQuery; var RelayStoreData; var addPending; var fetchRelayQuery; var subtractRelayQuery; + var toGraphQL; var writeRelayQueryPayload; var {getNode} = RelayTestUtils; @@ -33,12 +37,16 @@ describe('RelayPendingQueryTracker', () => { jest.resetModuleRegistry(); DliteFetchModeConstants = require('DliteFetchModeConstants'); + GraphQL = require('GraphQL'); + Promise = require('Promise'); Relay = require('Relay'); RelayPendingQueryTracker = require('RelayPendingQueryTracker'); + RelayQuery = require('RelayQuery'); RelayStoreData = require('RelayStoreData'); fetchRelayQuery = require('fetchRelayQuery'); subtractRelayQuery = require('subtractRelayQuery'); + toGraphQL = require('toGraphQL'); writeRelayQueryPayload = require('writeRelayQueryPayload'); subtractRelayQuery.mockImplementation(query => query); diff --git a/src/store/__tests__/RelayRecordStore_write-test.js b/src/store/__tests__/RelayRecordStore_write-test.js index 806607c3a0755..6e3348e12f7b5 100644 --- a/src/store/__tests__/RelayRecordStore_write-test.js +++ b/src/store/__tests__/RelayRecordStore_write-test.js @@ -14,6 +14,7 @@ jest.autoMockOff(); describe('RelayRecordStore', () => { + var GraphQL; var GraphQLRange; var RelayConnectionInterface; var RelayMockCacheManager; @@ -25,6 +26,7 @@ describe('RelayRecordStore', () => { beforeEach(() => { jest.resetModuleRegistry(); + GraphQL = require('GraphQL'); GraphQLRange = require('GraphQLRange'); RelayConnectionInterface = require('RelayConnectionInterface'); RelayMockCacheManager = require('RelayMockCacheManager'); diff --git a/src/store/__tests__/observeRelayQueryData-test.js b/src/store/__tests__/observeRelayQueryData-test.js index 206b9f60743ac..3da9a21dafd17 100644 --- a/src/store/__tests__/observeRelayQueryData-test.js +++ b/src/store/__tests__/observeRelayQueryData-test.js @@ -17,10 +17,12 @@ RelayTestUtils.unmockRelay(); describe('observeRelayQueryData', () => { var GraphQLStoreChangeEmitter; var Relay; + var RelayQuery; var RelayRecordStore; var addListenerForIDs; var observeRelayQueryData; + var readRelayQueryData; var firstMockCallback; var secondMockCallback; @@ -41,10 +43,12 @@ describe('observeRelayQueryData', () => { GraphQLStoreChangeEmitter = require('GraphQLStoreChangeEmitter'); Relay = require('Relay'); + RelayQuery = require('RelayQuery'); RelayRecordStore = require('RelayRecordStore'); addListenerForIDs = GraphQLStoreChangeEmitter.addListenerForIDs; observeRelayQueryData = require('observeRelayQueryData'); + readRelayQueryData = require('readRelayQueryData'); firstMockCallback = jest.genMockFunction(); secondMockCallback = jest.genMockFunction(); diff --git a/src/store/__tests__/readRelayQueryData-test.js b/src/store/__tests__/readRelayQueryData-test.js index 00497cb1bf06d..1659f001461f7 100644 --- a/src/store/__tests__/readRelayQueryData-test.js +++ b/src/store/__tests__/readRelayQueryData-test.js @@ -21,6 +21,7 @@ describe('readRelayQueryData', () => { var Relay; var RelayConnectionInterface; var RelayFragmentReference; + var RelayQuery; var RelayRecordStore; var callsToGraphQL; var readRelayQueryData; @@ -46,6 +47,7 @@ describe('readRelayQueryData', () => { Relay = require('Relay'); RelayConnectionInterface = require('RelayConnectionInterface'); RelayFragmentReference = require('RelayFragmentReference'); + RelayQuery = require('RelayQuery'); RelayRecordStore = require('RelayRecordStore'); callsToGraphQL = require('callsToGraphQL'); readRelayQueryData = require('readRelayQueryData'); diff --git a/src/tools/RelayTypes.js b/src/tools/RelayTypes.js index a09ba496e05ec..072a4bfd7c04b 100644 --- a/src/tools/RelayTypes.js +++ b/src/tools/RelayTypes.js @@ -17,7 +17,7 @@ * Types that Relay framework users may find useful. */ import type URI from 'URI'; -import type {DataID} from 'RelayInternalTypes'; +import type {DataID, ClientMutationID} from 'RelayInternalTypes'; import type RelayMutationTransaction from 'RelayMutationTransaction'; // Routes and variables diff --git a/src/traversal/__tests__/checkRelayQueryData-test.js b/src/traversal/__tests__/checkRelayQueryData-test.js index 92a1fd833ef5c..5ee844ae9bf78 100644 --- a/src/traversal/__tests__/checkRelayQueryData-test.js +++ b/src/traversal/__tests__/checkRelayQueryData-test.js @@ -17,11 +17,14 @@ RelayTestUtils.unmockRelay(); describe('checkRelayQueryData', () => { var GraphQL; var GraphQLRange; + var GraphQLStoreRangeUtils; var Relay; var RelayConnectionInterface; + var RelayQuery; var RelayRecordStore; var checkRelayQueryData; + var emptyFunction; var {getNode} = RelayTestUtils; var HAS_NEXT_PAGE, HAS_PREV_PAGE; @@ -44,11 +47,14 @@ describe('checkRelayQueryData', () => { GraphQL = require('GraphQL'); GraphQLRange = require('GraphQLRange'); + GraphQLStoreRangeUtils = require('GraphQLStoreRangeUtils'); Relay = require('Relay'); RelayConnectionInterface = require('RelayConnectionInterface'); + RelayQuery = require('RelayQuery'); RelayRecordStore = require('RelayRecordStore'); checkRelayQueryData = require('checkRelayQueryData'); + emptyFunction = require('emptyFunction'); ({HAS_NEXT_PAGE, HAS_PREV_PAGE} = RelayConnectionInterface); }); diff --git a/src/traversal/__tests__/diffRelayQuery-test.js b/src/traversal/__tests__/diffRelayQuery-test.js index 369adf64dbd3f..e483516454a37 100644 --- a/src/traversal/__tests__/diffRelayQuery-test.js +++ b/src/traversal/__tests__/diffRelayQuery-test.js @@ -15,15 +15,18 @@ var RelayTestUtils = require('RelayTestUtils'); RelayTestUtils.unmockRelay(); describe('diffRelayQuery', () => { + var GraphQL; var GraphQLRange; var Relay; var RelayConnectionInterface; var RelayQuery; + var RelayQueryPath; var RelayQueryTracker; var RelayRecordStore; var diffRelayQuery; var filterRelayQuery; + var printRelayQuery; var {defer, getNode, getVerbatimNode} = RelayTestUtils; @@ -32,15 +35,18 @@ describe('diffRelayQuery', () => { beforeEach(() => { jest.resetModuleRegistry(); + GraphQL = require('GraphQL'); GraphQLRange = require('GraphQLRange'); Relay = require('Relay'); RelayConnectionInterface = require('RelayConnectionInterface'); RelayQuery = require('RelayQuery'); + RelayQueryPath = require('RelayQueryPath'); RelayQueryTracker = require('RelayQueryTracker'); RelayRecordStore = require('RelayRecordStore'); diffRelayQuery = require('diffRelayQuery'); filterRelayQuery = require('filterRelayQuery'); + printRelayQuery = require('printRelayQuery'); rootCallMap = { viewer: {'': 'client:viewer'}, diff --git a/src/traversal/__tests__/diffRelayQuery_connection-test.js b/src/traversal/__tests__/diffRelayQuery_connection-test.js index e63b4f41941b7..2a0813b4a9296 100644 --- a/src/traversal/__tests__/diffRelayQuery_connection-test.js +++ b/src/traversal/__tests__/diffRelayQuery_connection-test.js @@ -22,6 +22,7 @@ jest describe('diffRelayQuery', () => { var Relay; var RelayConnectionInterface; + var RelayQuery; var RelayQueryTracker; var RelayRecordStore; @@ -38,6 +39,7 @@ describe('diffRelayQuery', () => { Relay = require('Relay'); RelayConnectionInterface = require('RelayConnectionInterface'); + RelayQuery = require('RelayQuery'); RelayQueryTracker = require('RelayQueryTracker'); RelayRecordStore = require('RelayRecordStore'); diff --git a/src/traversal/__tests__/inferRelayFieldsFromData-test.js b/src/traversal/__tests__/inferRelayFieldsFromData-test.js index 56ad6b6803411..9ccc3cfbe38be 100644 --- a/src/traversal/__tests__/inferRelayFieldsFromData-test.js +++ b/src/traversal/__tests__/inferRelayFieldsFromData-test.js @@ -22,7 +22,7 @@ describe('inferRelayFieldsFromData', function() { var inferRelayFieldsFromData; var {getNode, matchers} = RelayTestUtils; - var HAS_NEXT_PAGE, HAS_PREV_PAGE, PAGE_INFO; + var END_CURSOR, HAS_NEXT_PAGE, HAS_PREV_PAGE, PAGE_INFO, START_CURSOR; beforeEach(function() { jest.resetModuleRegistry(); @@ -34,9 +34,11 @@ describe('inferRelayFieldsFromData', function() { inferRelayFieldsFromData = require('inferRelayFieldsFromData'); ({ + END_CURSOR, HAS_NEXT_PAGE, HAS_PREV_PAGE, - PAGE_INFO + PAGE_INFO, + START_CURSOR } = RelayConnectionInterface); jest.addMatchers({ diff --git a/src/traversal/__tests__/splitDeferredRelayQueries-test.js b/src/traversal/__tests__/splitDeferredRelayQueries-test.js index 5d8b6ef183e43..624d10465b826 100644 --- a/src/traversal/__tests__/splitDeferredRelayQueries-test.js +++ b/src/traversal/__tests__/splitDeferredRelayQueries-test.js @@ -16,11 +16,14 @@ RelayTestUtils.unmockRelay(); describe('splitDeferredRelayQueries()', () => { // modules + var GraphQL; var Relay; var RelayQuery; + var RelayQueryTransform; var flattenRelayQuery; var generateRQLFieldAlias; + var printRelayQuery; var splitDeferredRelayQueries; // helper functions @@ -39,11 +42,14 @@ describe('splitDeferredRelayQueries()', () => { // Reset query numbers back to q0. jest.resetModuleRegistry(); + GraphQL = require('GraphQL'); Relay = require('Relay'); RelayQuery = require('RelayQuery'); + RelayQueryTransform = require('RelayQueryTransform'); RelayTestUtils = require('RelayTestUtils'); flattenRelayQuery = require('flattenRelayQuery'); generateRQLFieldAlias = require('generateRQLFieldAlias'); + printRelayQuery = require('printRelayQuery'); splitDeferredRelayQueries = require('splitDeferredRelayQueries'); jest.addMatchers(RelayTestUtils.matchers);