relay-compiler 1.3.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. package/LICENSE +16 -26
  2. package/bin/relay-compiler +7348 -5939
  3. package/index.js +3 -6
  4. package/lib/{FileParser.js → ASTCache.js} +17 -14
  5. package/lib/ASTConvert.js +84 -70
  6. package/lib/CodegenDirectory.js +122 -28
  7. package/lib/{RelayCodegenRunner.js → CodegenRunner.js} +110 -186
  8. package/lib/CodegenTypes.js +12 -0
  9. package/lib/{RelayCodegenWatcher.js → CodegenWatcher.js} +53 -43
  10. package/lib/DefaultHandleKey.js +2 -4
  11. package/lib/DotGraphQLParser.js +27 -0
  12. package/lib/FilterDirectivesTransform.js +11 -11
  13. package/lib/FindGraphQLTags.js +33 -52
  14. package/lib/FlattenTransform.js +197 -0
  15. package/lib/GraphQLCompilerContext.js +158 -0
  16. package/lib/GraphQLCompilerProfiler.js +271 -0
  17. package/lib/GraphQLCompilerPublic.js +27 -22
  18. package/lib/GraphQLCompilerUserError.js +26 -0
  19. package/lib/GraphQLConsoleReporter.js +58 -0
  20. package/lib/GraphQLIR.js +12 -0
  21. package/lib/{RelayPrinter.js → GraphQLIRPrinter.js} +42 -38
  22. package/lib/{RelayIRTransformer.js → GraphQLIRTransformer.js} +47 -38
  23. package/lib/GraphQLIRTransforms.js +6 -15
  24. package/lib/{RelayIRVisitor.js → GraphQLIRVisitor.js} +7 -6
  25. package/lib/GraphQLMultiReporter.js +50 -0
  26. package/lib/GraphQLParser.js +743 -0
  27. package/lib/GraphQLReporter.js +12 -0
  28. package/lib/GraphQLSchemaUtils.js +10 -36
  29. package/lib/GraphQLValidator.js +13 -15
  30. package/lib/{RelayWatchmanClient.js → GraphQLWatchmanClient.js} +15 -17
  31. package/lib/InlineFragmentsTransform.js +48 -0
  32. package/lib/PatchedBabelGenerator.js +58 -0
  33. package/lib/RelayApplyFragmentArgumentTransform.js +37 -18
  34. package/lib/RelayCodeGenerator.js +130 -60
  35. package/lib/RelayCompilerBin.js +80 -35
  36. package/lib/RelayCompilerCache.js +18 -11
  37. package/lib/RelayCompilerPublic.js +24 -10
  38. package/lib/RelayCompilerScope.js +2 -4
  39. package/lib/RelayConcreteNode.js +31 -14
  40. package/lib/RelayConnectionConstants.js +2 -4
  41. package/lib/RelayConnectionTransform.js +34 -38
  42. package/lib/RelayDefaultHandleKey.js +2 -4
  43. package/lib/RelayDeferrableFragmentTransform.js +464 -0
  44. package/lib/RelayError.js +2 -6
  45. package/lib/RelayFieldHandleTransform.js +15 -11
  46. package/lib/RelayFileWriter.js +119 -98
  47. package/lib/RelayFlowBabelFactories.js +113 -0
  48. package/lib/RelayFlowGenerator.js +180 -200
  49. package/lib/RelayFlowTypeTransformers.js +109 -0
  50. package/lib/RelayGenerateIDFieldTransform.js +131 -0
  51. package/lib/RelayGenerateTypeNameTransform.js +75 -0
  52. package/lib/RelayGraphQLEnumsGenerator.js +65 -0
  53. package/lib/RelayIRTransforms.js +19 -23
  54. package/lib/RelayInternalTypes.js +2 -5
  55. package/lib/RelayInternals.js +2 -5
  56. package/lib/RelayJSModuleParser.js +64 -0
  57. package/lib/RelayMaskTransform.js +129 -0
  58. package/lib/RelayMetricsRecorder.js +9 -9
  59. package/lib/RelayMockRenderer.js +3 -8
  60. package/lib/RelayNetworkDebug.js +4 -7
  61. package/lib/RelayParser.js +28 -645
  62. package/lib/RelayProfiler.js +7 -7
  63. package/lib/RelayQueryCaching.js +2 -5
  64. package/lib/RelayRelayDirectiveTransform.js +47 -33
  65. package/lib/RelayRuntimeTypes.js +22 -0
  66. package/lib/RelayShallowMock.js +4 -7
  67. package/lib/RelaySkipHandleFieldTransform.js +13 -11
  68. package/lib/RelayTaskQueue.js +2 -5
  69. package/lib/RelayTransformUtils.js +20 -0
  70. package/lib/RelayTypes.js +2 -5
  71. package/lib/RelayValidator.js +9 -8
  72. package/lib/RelayViewerHandleTransform.js +22 -18
  73. package/lib/SkipClientFieldTransform.js +36 -53
  74. package/lib/SkipRedundantNodesTransform.js +22 -29
  75. package/lib/SkipUnreachableNodeTransform.js +57 -36
  76. package/lib/SourceControl.js +61 -0
  77. package/lib/StripUnusedVariablesTransform.js +86 -41
  78. package/lib/areEqualOSS.js +2 -4
  79. package/lib/compileRelayArtifacts.js +72 -0
  80. package/lib/dedent.js +2 -5
  81. package/lib/dedupeJSONStringify.js +132 -0
  82. package/lib/deepFreeze.js +3 -5
  83. package/lib/deepMergeAssignments.js +68 -0
  84. package/lib/filterContextForNode.js +5 -7
  85. package/lib/formatGeneratedModule.js +5 -9
  86. package/lib/{getIdentifierForRelayArgumentValue.js → getIdentifierForArgumentValue.js} +8 -10
  87. package/lib/getIdentifierForSelection.js +37 -0
  88. package/lib/getLiteralArgumentValues.js +26 -0
  89. package/lib/getModuleName.js +2 -4
  90. package/lib/getRelayHandleKey.js +2 -4
  91. package/lib/isCompatibleRelayFragmentType.js +2 -5
  92. package/lib/isEquivalentType.js +55 -0
  93. package/lib/isPromise.js +2 -5
  94. package/lib/isScalarAndEqual.js +3 -5
  95. package/lib/murmurHash.js +2 -4
  96. package/lib/nullthrowsOSS.js +7 -5
  97. package/lib/recycleNodesInto.js +2 -4
  98. package/lib/relayUnstableBatchedUpdates.js +2 -5
  99. package/lib/relayUnstableBatchedUpdates.native.js +2 -5
  100. package/lib/requestsForOperation.js +75 -0
  101. package/lib/simpleClone.js +2 -4
  102. package/lib/stableCopy.js +35 -0
  103. package/lib/testEditDistance.js +2 -5
  104. package/lib/throwFailedPromise.js +2 -5
  105. package/lib/writeRelayGeneratedFile.js +84 -50
  106. package/package.json +16 -15
  107. package/relay-compiler.js +7208 -5872
  108. package/relay-compiler.min.js +7200 -5867
  109. package/ARCHITECTURE.md +0 -94
  110. package/PATENTS +0 -33
  111. package/lib/AutoAliasTransform.js +0 -80
  112. package/lib/GraphQLFileParser.js +0 -27
  113. package/lib/GraphQLTextParser.js +0 -46
  114. package/lib/RelayCodegenTypes.js +0 -14
  115. package/lib/RelayCompiledTypes.js +0 -13
  116. package/lib/RelayCompiler.js +0 -144
  117. package/lib/RelayCompilerContext.js +0 -133
  118. package/lib/RelayCompilerUserError.js +0 -30
  119. package/lib/RelayConsoleReporter.js +0 -40
  120. package/lib/RelayFileIRParser.js +0 -66
  121. package/lib/RelayFlattenTransform.js +0 -278
  122. package/lib/RelayFlowParser.js +0 -188
  123. package/lib/RelayGenerateRequisiteFieldsTransform.js +0 -189
  124. package/lib/RelayIR.js +0 -14
  125. package/lib/RelayMultiReporter.js +0 -40
  126. package/lib/RelayReporter.js +0 -14
  127. package/lib/RelayTestSchema.js +0 -21
  128. package/lib/formatStorageKey.js +0 -37
  129. package/lib/getIdentifierForRelaySelection.js +0 -54
  130. package/lib/getRelayLiteralArgumentValues.js +0 -28
  131. package/lib/parseGraphQLText.js +0 -33
  132. package/lib/prettyStringify.js +0 -35
  133. package/lib/printFlowTypes.js +0 -282
  134. package/lib/stableJSONStringify.js +0 -45
  135. package/lib/stableJSONStringifyOSS.js +0 -44
  136. package/lib/transformInputObjectToIR.js +0 -85
  137. package/lib/writeLegacyFlowFile.js +0 -24
package/lib/deepFreeze.js CHANGED
@@ -1,13 +1,11 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
- *
10
7
  * @providesModule deepFreeze
8
+ *
11
9
  * @format
12
10
  */
13
11
 
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Copyright (c) 2013-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ * @format
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ /**
14
+ * Given a object of nested properties, return JavaScript text that would merge
15
+ * in an object named `objectName` by a series of individual assignments.
16
+ */
17
+
18
+ function deepMergeAssignments(objectName, properties) {
19
+ var assignments = [];
20
+ collectAssignmentsInto(assignments, [], properties);
21
+ var jsAssignments = assignments.map(function (_ref) {
22
+ var path = _ref.path,
23
+ value = _ref.value;
24
+ return formatJSAssignment(objectName, path, value);
25
+ });
26
+ return jsAssignments.length === 0 ? '' : jsAssignments.join('\n');
27
+ }
28
+
29
+ // Recursively collect assignments
30
+ function collectAssignmentsInto(assignments, parentPath, parentValue) {
31
+ // Iterate over the entries in the array or object.
32
+ forEach(parentValue, function (value, key) {
33
+ // The "path" is the sequence of keys to arrive at this assignment.
34
+ var path = parentPath.concat(key);
35
+ // For each entry, either add an assignment or recurse.
36
+ if (typeof value === 'object' && value !== null) {
37
+ collectAssignmentsInto(assignments, path, value);
38
+ } else {
39
+ assignments.push({ path: path, value: value });
40
+ }
41
+ });
42
+ }
43
+
44
+ // Print a path/value pair as a JS assignment expression.
45
+ function formatJSAssignment(objectName, path, value) {
46
+ var assignmentPath = path.map(function (p) {
47
+ return typeof p === 'string' ? '.' + p : '[' + p + ']';
48
+ }).join('');
49
+ var jsValue = value === undefined ? 'undefined' : JSON.stringify(value);
50
+ return '' + objectName + assignmentPath + ' = ' + jsValue + ';';
51
+ }
52
+
53
+ // Utility for looping over entries in both Arrays and Objects.
54
+ function forEach(value, fn) {
55
+ if (Array.isArray(value)) {
56
+ for (var i = 0; i < value.length; i++) {
57
+ fn(value[i], i);
58
+ }
59
+ } else {
60
+ for (var k in value) {
61
+ if (value.hasOwnProperty(k)) {
62
+ fn(value[k], k);
63
+ }
64
+ }
65
+ }
66
+ }
67
+
68
+ module.exports = deepMergeAssignments;
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule filterContextForNode
10
8
  *
@@ -13,16 +11,16 @@
13
11
 
14
12
  'use strict';
15
13
 
16
- var _require = require('./RelayIRVisitor'),
14
+ var _require = require('./GraphQLIRVisitor'),
17
15
  visit = _require.visit;
18
16
 
19
17
  /**
20
- * Returns a RelayCompilerContext containing only the documents referenced
18
+ * Returns a GraphQLCompilerContext containing only the documents referenced
21
19
  * by and including the provided node.
22
20
  */
23
21
  function filterContextForNode(node, context) {
24
22
  var queue = [node];
25
- var filteredContext = new (require('./RelayCompilerContext'))(context.schema).add(node);
23
+ var filteredContext = new (require('./GraphQLCompilerContext'))(context.serverSchema, context.clientSchema).add(node);
26
24
  var visitorConfig = {
27
25
  FragmentSpread: function FragmentSpread(fragmentSpread) {
28
26
  var name = fragmentSpread.name;
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule formatGeneratedModule
10
8
  *
@@ -20,14 +18,12 @@ var formatGeneratedModule = function formatGeneratedModule(_ref) {
20
18
  concreteText = _ref.concreteText,
21
19
  flowText = _ref.flowText,
22
20
  hash = _ref.hash,
23
- devTextGenerator = _ref.devTextGenerator,
24
- relayRuntimeModule = _ref.relayRuntimeModule;
21
+ relayRuntimeModule = _ref.relayRuntimeModule,
22
+ sourceHash = _ref.sourceHash;
25
23
 
26
- var objectName = documentType === 'ConcreteBatch' ? 'batch' : 'fragment';
27
24
  var docTextComment = docText ? '\n/*\n' + docText.trim() + '\n*/\n' : '';
28
25
  var hashText = hash ? '\n * ' + hash : '';
29
- var devOnlyText = devTextGenerator ? devTextGenerator(objectName) : '';
30
- return '/**\n * ' + '@' + 'flow' + hashText + '\n */\n\n/* eslint-disable */\n\n\'use strict\';\n\n/*::\nimport type {' + documentType + '} from \'' + relayRuntimeModule + '\';\n' + (flowText || '') + '\n*/\n\n' + docTextComment + '\nconst ' + objectName + ' /*: ' + documentType + '*/ = ' + concreteText + ';\n' + devOnlyText + '\nmodule.exports = ' + objectName + ';\n';
26
+ return '/**\n * ' + '@' + 'flow' + hashText + '\n */\n\n/* eslint-disable */\n\n\'use strict\';\n\n/*::\nimport type { ' + documentType + ' } from \'' + relayRuntimeModule + '\';\n' + (flowText || '') + '\n*/\n\n' + docTextComment + '\nconst node/*: ' + documentType + '*/ = ' + concreteText + ';\n(node/*: any*/).hash = \'' + sourceHash + '\';\nmodule.exports = node;\n';
31
27
  };
32
28
 
33
29
  module.exports = formatGeneratedModule;
@@ -1,12 +1,10 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
- * @providesModule getIdentifierForRelayArgumentValue
7
+ * @providesModule getIdentifierForArgumentValue
10
8
  *
11
9
  * @format
12
10
  */
@@ -17,7 +15,7 @@
17
15
  * Generates an identifier for an argument value. The identifier is based on the
18
16
  * structure/order of items and keys in the value.
19
17
  */
20
- function getIdentifierForRelayArgumentValue(value) {
18
+ function getIdentifierForArgumentValue(value) {
21
19
  switch (value.kind) {
22
20
  case 'Variable':
23
21
  return { variable: value.variableName };
@@ -26,7 +24,7 @@ function getIdentifierForRelayArgumentValue(value) {
26
24
  case 'ListValue':
27
25
  return {
28
26
  list: value.items.map(function (item) {
29
- return getIdentifierForRelayArgumentValue(item);
27
+ return getIdentifierForArgumentValue(item);
30
28
  })
31
29
  };
32
30
  case 'ObjectValue':
@@ -34,13 +32,13 @@ function getIdentifierForRelayArgumentValue(value) {
34
32
  object: value.fields.map(function (field) {
35
33
  return {
36
34
  name: field.name,
37
- value: getIdentifierForRelayArgumentValue(field.value)
35
+ value: getIdentifierForArgumentValue(field.value)
38
36
  };
39
37
  })
40
38
  };
41
39
  default:
42
- require('fbjs/lib/invariant')(false, 'getIdentifierForRelayArgumentValue(): Unsupported AST kind `%s`.', value.kind);
40
+ require('fbjs/lib/invariant')(false, 'getIdentifierForArgumentValue(): Unsupported AST kind `%s`.', value.kind);
43
41
  }
44
42
  }
45
43
 
46
- module.exports = getIdentifierForRelayArgumentValue;
44
+ module.exports = getIdentifierForArgumentValue;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright (c) 2013-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ * @providesModule getIdentifierForSelection
9
+ * @format
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var _require = require('./GraphQLIRPrinter'),
15
+ printArguments = _require.printArguments,
16
+ printDirectives = _require.printDirectives;
17
+
18
+ /**
19
+ * Generates an identifier that is unique to a given selection: the alias for
20
+ * fields, the type for inline fragments, and a summary of the condition
21
+ * variable and passing value for conditions.
22
+ */
23
+ function getIdentifierForSelection(node) {
24
+ if (node.kind === 'LinkedField' || node.kind === 'ScalarField') {
25
+ return node.directives.length === 0 ? node.alias || node.name : (node.alias || node.name) + printDirectives(node.directives);
26
+ } else if (node.kind === 'FragmentSpread' || node.kind === 'DeferrableFragmentSpread') {
27
+ return node.args.length === 0 ? '...' + node.name : '...' + node.name + printArguments(node.args);
28
+ } else if (node.kind === 'InlineFragment') {
29
+ return 'I:' + node.typeCondition.name;
30
+ } else if (node.kind === 'Condition') {
31
+ return 'C:' + (node.condition.kind === 'Variable' ? '$' + node.condition.variableName : String(node.condition.value)) + String(node.passingValue);
32
+ } else {
33
+ require('fbjs/lib/invariant')(false, 'getIdentifierForSelection: Unexpected kind `%s`.', node.kind);
34
+ }
35
+ }
36
+
37
+ module.exports = getIdentifierForSelection;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) 2013-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @providesModule getLiteralArgumentValues
8
+ *
9
+ * @format
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ // Copy of Variables type from '../../../react-relay/classic/tools/RelayTypes'
15
+ // Duplicating here rather than importing it since we can't take on a dependency
16
+ // outside of graphql-compiler.
17
+ function getLiteralArgumentValues(args) {
18
+ var values = {};
19
+ args.forEach(function (arg) {
20
+ require('fbjs/lib/invariant')(arg.value.kind === 'Literal', 'getLiteralArgumentValues(): Expected all args to be literals.');
21
+ values[arg.name] = arg.value.value;
22
+ });
23
+ return values;
24
+ }
25
+
26
+ module.exports = getLiteralArgumentValues;
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule getModuleName
10
8
  *
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  *
10
8
  * @providesModule getRelayHandleKey
@@ -1,12 +1,9 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
- * @providesModule isCompatibleRelayFragmentType
10
7
  *
11
8
  * @format
12
9
  */
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Copyright (c) 2013-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ * @format
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ var _require = require('./GraphQLSchemaUtils'),
14
+ getRawType = _require.getRawType;
15
+
16
+ var _require2 = require('graphql'),
17
+ GraphQLNonNull = _require2.GraphQLNonNull,
18
+ GraphQLList = _require2.GraphQLList;
19
+
20
+ /**
21
+ * Determine if a type is the same type (same name and class) as another type.
22
+ * Needed if we're comparing IRs created at different times: we don't yet have
23
+ * an IR schema, so the type we assign to an IR field could be !== than
24
+ * what we assign to it after adding some schema definitions or extensions.
25
+ */
26
+ function isEquivalentType(typeA, typeB) {
27
+ // Easy short-circuit: equal types are equal.
28
+ if (typeA === typeB) {
29
+ return true;
30
+ }
31
+
32
+ // If either type is non-null, the other must also be non-null.
33
+ if (typeA instanceof GraphQLNonNull && typeB instanceof GraphQLNonNull) {
34
+ return isEquivalentType(typeA.ofType, typeB.ofType);
35
+ }
36
+
37
+ // If either type is a list, the other must also be a list.
38
+ if (typeA instanceof GraphQLList && typeB instanceof GraphQLList) {
39
+ return isEquivalentType(typeA.ofType, typeB.ofType);
40
+ }
41
+
42
+ // Make sure the two types are of the same class
43
+ if (typeA.constructor.name === typeB.constructor.name) {
44
+ var rawA = getRawType(typeA);
45
+ var rawB = getRawType(typeB);
46
+
47
+ // And they must have the exact same name
48
+ return rawA.name === rawB.name;
49
+ }
50
+
51
+ // Otherwise the types are not equal.
52
+ return false;
53
+ }
54
+
55
+ module.exports = isEquivalentType;
package/lib/isPromise.js CHANGED
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule isPromise
10
8
  *
@@ -13,7 +11,6 @@
13
11
 
14
12
  'use strict';
15
13
 
16
- // eslint-disable-next-line no-redeclare
17
14
  function isPromise(p) {
18
15
  return !!p && typeof p.then === 'function';
19
16
  }
@@ -1,13 +1,11 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
- *
10
7
  * @providesModule isScalarAndEqual
8
+ *
11
9
  * @format
12
10
  */
13
11
 
package/lib/murmurHash.js CHANGED
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * Based on implementations by Gary Court and Austin Appleby, 2011, MIT.
10
8
  *
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule nullthrowsOSS
10
8
  *
@@ -13,10 +11,14 @@
13
11
  'use strict';
14
12
 
15
13
  var nullthrows = function nullthrows(x) {
14
+ var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Got unexpected null or undefined';
15
+
16
16
  if (x != null) {
17
17
  return x;
18
18
  }
19
- throw new Error('Got unexpected null or undefined');
19
+ var error = new Error(message);
20
+ error.framesToPop = 1; // Skip nullthrows own stack frame.
21
+ throw error;
20
22
  };
21
23
 
22
24
  module.exports = nullthrows;
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule recycleNodesInto
10
8
  *
@@ -1,12 +1,9 @@
1
1
  /**
2
2
  * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
- * @providesModule relayUnstableBatchedUpdates
10
7
  *
11
8
  * @format
12
9
  */
@@ -1,12 +1,9 @@
1
1
  /**
2
2
  * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
- * @providesModule relayUnstableBatchedUpdates
10
7
  * @format
11
8
  */
12
9
 
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Copyright (c) 2013-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ * @format
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ var _extends3 = _interopRequireDefault(require('babel-runtime/helpers/extends'));
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
16
+
17
+ var _require = require('./GraphQLCompilerPublic'),
18
+ filterContextForNode = _require.filterContextForNode,
19
+ Printer = _require.Printer;
20
+
21
+ function requestsForOperation(printContext, codeGenContext, initialRootName) {
22
+ var operationToRequestName = new Map();
23
+ return requestsInto([], {
24
+ operationName: initialRootName,
25
+ argumentDependencies: []
26
+ });
27
+ function requestsInto(requests, dependent) {
28
+ var name = dependent.operationName;
29
+ // Create a unique name for this request.
30
+ var num = 0;
31
+ var requestName = void 0;
32
+ do {
33
+ requestName = name + (++num > 1 ? num : '');
34
+ } while (requests.some(function (request) {
35
+ return request.name === requestName;
36
+ }));
37
+ operationToRequestName.set(name, requestName);
38
+ // Collect the dependent arguments for this request.
39
+ var codeGenRoot = codeGenContext.getRoot(name);
40
+ var argumentDependencies = dependent.argumentDependencies;
41
+ var dependentRequests = codeGenRoot.dependentRequests;
42
+ var rerunDependency = dependentRequests.find(function (next) {
43
+ return next.operationName === dependent.operationName;
44
+ });
45
+ if (rerunDependency) {
46
+ dependentRequests = dependentRequests.filter(function (next) {
47
+ return next !== rerunDependency;
48
+ });
49
+ argumentDependencies = argumentDependencies.concat(rerunDependency.argumentDependencies);
50
+ }
51
+ // Create a request for this operation.
52
+ requests.push({
53
+ kind: 'Request',
54
+ name: requestName,
55
+ id: null,
56
+ text: printOperation(printContext, name),
57
+ argumentDependencies: argumentDependencies.map(function (argDep) {
58
+ return (0, _extends3['default'])({}, argDep, {
59
+ fromName: operationToRequestName.get(argDep.fromName)
60
+ });
61
+ }),
62
+ root: codeGenRoot,
63
+ metadata: dependent.metadata || undefined
64
+ });
65
+ // Collect any requests that were dependent on this one as well.
66
+ return dependentRequests.reduce(requestsInto, requests);
67
+ }
68
+ }
69
+
70
+ function printOperation(printContext, name) {
71
+ var printableRoot = printContext.getRoot(name);
72
+ return filterContextForNode(printableRoot, printContext).documents().map(Printer.print).join('\n');
73
+ }
74
+
75
+ module.exports = requestsForOperation;
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule simpleClone
10
8
  *
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright (c) 2013-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @providesModule stableCopy
8
+ *
9
+ * @format
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ /**
15
+ * Creates a copy of the provided value, ensuring any nested objects have their
16
+ * keys sorted such that equivalent values would have identical JSON.stringify
17
+ * results.
18
+ */
19
+
20
+ function stableCopy(value) {
21
+ if (!value || typeof value !== 'object') {
22
+ return value;
23
+ }
24
+ if (Array.isArray(value)) {
25
+ return value.map(stableCopy);
26
+ }
27
+ var keys = Object.keys(value).sort();
28
+ var stable = {};
29
+ for (var i = 0; i < keys.length; i++) {
30
+ stable[keys[i]] = stableCopy(value[keys[i]]);
31
+ }
32
+ return stable;
33
+ }
34
+
35
+ module.exports = stableCopy;
@@ -1,12 +1,9 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
- * @providesModule testEditDistance
10
7
  *
11
8
  * @format
12
9
  *
@@ -1,13 +1,10 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  *
10
- * @providesModule throwFailedPromise
11
8
  * @format
12
9
  */
13
10