relay-compiler 10.1.3 → 11.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/bin/relay-compiler +46 -20
  2. package/codegen/CodegenDirectory.js.flow +1 -1
  3. package/codegen/writeRelayGeneratedFile.js.flow +16 -0
  4. package/core/IRPrinter.js.flow +1 -0
  5. package/core/RelayParser.js.flow +3 -0
  6. package/index.js +1 -1
  7. package/language/javascript/RelayFlowGenerator.js.flow +1 -0
  8. package/lib/bin/RelayCompilerMain.js +1 -1
  9. package/lib/codegen/CodegenDirectory.js +1 -1
  10. package/lib/codegen/CodegenRunner.js +1 -1
  11. package/lib/codegen/RelayFileWriter.js +1 -1
  12. package/lib/codegen/writeRelayGeneratedFile.js +22 -6
  13. package/lib/core/CompilerContext.js +1 -1
  14. package/lib/core/GraphQLCompilerProfiler.js +1 -1
  15. package/lib/core/IRPrinter.js +3 -2
  16. package/lib/core/IRTransformer.js +1 -1
  17. package/lib/core/IRValidator.js +1 -1
  18. package/lib/core/RelayParser.js +5 -2
  19. package/lib/core/RelaySourceModuleParser.js +1 -1
  20. package/lib/core/getIdentifierForArgumentValue.js +1 -1
  21. package/lib/core/getIdentifierForSelection.js +1 -1
  22. package/lib/language/javascript/RelayFlowBabelFactories.js +1 -1
  23. package/lib/language/javascript/RelayFlowGenerator.js +3 -2
  24. package/lib/runner/BufferedFilesystem.js +1 -1
  25. package/lib/runner/Sources.js +1 -1
  26. package/lib/runner/StrictMap.js +1 -1
  27. package/lib/runner/extractAST.js +1 -1
  28. package/lib/transforms/DeclarativeConnectionMutationTransform.js +1 -1
  29. package/lib/transforms/FieldHandleTransform.js +1 -1
  30. package/lib/transforms/FlattenTransform.js +7 -4
  31. package/lib/transforms/InlineFragmentsTransform.js +1 -1
  32. package/lib/transforms/MaskTransform.js +1 -1
  33. package/lib/transforms/RelayDirectiveTransform.js +1 -1
  34. package/lib/transforms/SkipRedundantNodesTransform.js +3 -2
  35. package/lib/transforms/SkipUnreachableNodeTransform.js +1 -1
  36. package/lib/util/{areEqualOSS.js → areEqualArgValues.js} +4 -3
  37. package/package.json +3 -2
  38. package/relay-compiler.js +3 -3
  39. package/relay-compiler.min.js +3 -3
  40. package/runner/BufferedFilesystem.js.flow +1 -1
  41. package/transforms/DeclarativeConnectionMutationTransform.js.flow +1 -3
  42. package/transforms/FlattenTransform.js.flow +8 -2
  43. package/transforms/SkipRedundantNodesTransform.js.flow +1 -0
  44. package/util/{areEqualOSS.js.flow → areEqualArgValues.js.flow} +5 -3
@@ -144,7 +144,7 @@ class BufferedFilesystem implements Filesystem {
144
144
  return fs.readFileSync(path, encoding);
145
145
  }
146
146
 
147
- statSync(path: string): {isDirectory(): boolean, ...} {
147
+ statSync(path: string): interface {isDirectory(): boolean} {
148
148
  this._assertNotComitted();
149
149
  return fs.statSync(path);
150
150
  }
@@ -164,9 +164,7 @@ function visitLinkedField(field: LinkedField): LinkedField {
164
164
  }
165
165
  const schema = this.getContext().getSchema();
166
166
  if (edgeDirective) {
167
- const fieldType = schema.isList(transformedField.type)
168
- ? transformedField.type.ofType
169
- : transformedField.type;
167
+ const fieldType = schema.getRawType(transformedField.type);
170
168
  const fields = schema.getFields(fieldType);
171
169
  let cursorFieldID;
172
170
  let nodeFieldID;
@@ -14,7 +14,7 @@
14
14
 
15
15
  const IRTransformer = require('../core/IRTransformer');
16
16
 
17
- const areEqual = require('../util/areEqualOSS');
17
+ const areEqualArgValues = require('../util/areEqualArgValues');
18
18
  const getIdentifierForSelection = require('../core/getIdentifierForSelection');
19
19
 
20
20
  const {createCompilerError, createUserError} = require('../core/CompilerError');
@@ -415,7 +415,10 @@ function areEqualArgs(
415
415
  thisArg.value.kind === thatArg.value.kind &&
416
416
  (thisArg.value: any).variableName ===
417
417
  (thatArg.value: any).variableName &&
418
- areEqual((thisArg.value: any).value, (thatArg.value: any).value)
418
+ areEqualArgValues(
419
+ (thisArg.value: any).value,
420
+ (thatArg.value: any).value,
421
+ )
419
422
  );
420
423
  })
421
424
  );
@@ -436,8 +439,11 @@ function mergeHandles<T: LinkedField | ScalarField>(
436
439
  }
437
440
  const uniqueItems = new Map();
438
441
  nodeA.handles
442
+ // $FlowFixMe[incompatible-use]
439
443
  .concat(nodeB.handles)
444
+ // $FlowFixMe[incompatible-use]
440
445
  .forEach(item => uniqueItems.set(item.name + item.key, item));
446
+ // $FlowFixMe[incompatible-return]
441
447
  return Array.from(uniqueItems.values());
442
448
  }
443
449
 
@@ -234,6 +234,7 @@ function transformNode<T: Node>(
234
234
  // $FlowFixMe[escaped-generic]
235
235
  cache.set(node, result);
236
236
  }
237
+ // $FlowFixMe[incompatible-return]
237
238
  return result;
238
239
  }
239
240
 
@@ -8,6 +8,8 @@
8
8
  * @format
9
9
  */
10
10
 
11
+ // TODO: This is only used with `ArgumentValue` types, so it could be simpler.
12
+
11
13
  // flowlint ambiguous-object-type:error
12
14
  'use strict';
13
15
 
@@ -22,7 +24,7 @@ const bStackPool = [];
22
24
  * @copyright 2009-2013 Jeremy Ashkenas, DocumentCloud Inc.
23
25
  * @license MIT
24
26
  */
25
- function areEqual(a: any, b: any): boolean {
27
+ function areEqualArgValues(a: any, b: any): boolean {
26
28
  const aStack = aStackPool.length ? aStackPool.pop() : [];
27
29
  const bStack = bStackPool.length ? bStackPool.pop() : [];
28
30
  const result = eq(a, b, aStack, bStack);
@@ -104,7 +106,7 @@ function eq(a: any, b: any, aStack: Array<any>, bStack: Array<any>): boolean {
104
106
  // HACK: Comparing deeply nested React trees is slow since you end up
105
107
  // comparing the entire tree (all ancestors and all children) and
106
108
  // likely not what you want if you're comparing two elements with
107
- // areEqual. We bail out here for now.
109
+ // areEqualArgValues. We bail out here for now.
108
110
  continue;
109
111
  }
110
112
  if (
@@ -120,4 +122,4 @@ function eq(a: any, b: any, aStack: Array<any>, bStack: Array<any>): boolean {
120
122
  return true;
121
123
  }
122
124
 
123
- module.exports = areEqual;
125
+ module.exports = areEqualArgValues;