relay-compiler 0.0.0-main-e0f88a3b → 0.0.0-main-2087b512

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. package/bin/RelayCompilerBin.js.flow +2 -3
  2. package/bin/RelayCompilerMain.js.flow +12 -14
  3. package/bin/relay-compiler +5613 -5548
  4. package/codegen/CodegenDirectory.js.flow +4 -5
  5. package/codegen/CodegenRunner.js.flow +11 -13
  6. package/codegen/CodegenWatcher.js.flow +3 -4
  7. package/codegen/NormalizationCodeGenerator.js.flow +13 -14
  8. package/codegen/ReaderCodeGenerator.js.flow +14 -16
  9. package/codegen/RelayCodeGenerator.js.flow +7 -7
  10. package/codegen/RelayFileWriter.js.flow +20 -22
  11. package/codegen/compileRelayArtifacts.js.flow +5 -6
  12. package/codegen/writeRelayGeneratedFile.js.flow +7 -9
  13. package/core/ASTCache.js.flow +3 -4
  14. package/core/ASTConvert.js.flow +7 -8
  15. package/core/CompilerContext.js.flow +5 -7
  16. package/core/CompilerError.js.flow +2 -2
  17. package/core/DotGraphQLParser.js.flow +4 -6
  18. package/core/IR.js.flow +2 -2
  19. package/core/IRPrinter.js.flow +3 -4
  20. package/core/IRTransformer.js.flow +4 -5
  21. package/core/IRValidator.js.flow +3 -4
  22. package/core/IRVisitor.js.flow +2 -2
  23. package/core/JSModuleParser.js.flow +2 -2
  24. package/core/RelayCompilerScope.js.flow +2 -2
  25. package/core/RelayFindGraphQLTags.js.flow +6 -7
  26. package/core/RelayGraphQLEnumsGenerator.js.flow +2 -2
  27. package/core/RelayIRTransforms.js.flow +3 -3
  28. package/core/RelayParser.js.flow +16 -18
  29. package/core/RelaySourceModuleParser.js.flow +7 -9
  30. package/core/Schema.js.flow +24 -24
  31. package/core/SchemaUtils.js.flow +3 -3
  32. package/core/filterContextForNode.js.flow +2 -3
  33. package/core/getFieldDefinition.js.flow +3 -3
  34. package/core/getIdentifierForArgumentValue.js.flow +2 -2
  35. package/core/getIdentifierForSelection.js.flow +3 -4
  36. package/core/inferRootArgumentDefinitions.js.flow +5 -6
  37. package/index.js +1 -1
  38. package/index.js.flow +33 -35
  39. package/language/RelayLanguagePluginInterface.js.flow +3 -3
  40. package/language/javascript/FindGraphQLTags.js.flow +2 -3
  41. package/language/javascript/RelayFlowBabelFactories.js.flow +1 -1
  42. package/language/javascript/RelayFlowGenerator.js.flow +16 -19
  43. package/language/javascript/RelayFlowTypeTransformers.js.flow +3 -5
  44. package/language/javascript/RelayLanguagePluginJavaScript.js.flow +2 -3
  45. package/lib/bin/RelayCompilerBin.js +2 -2
  46. package/lib/bin/RelayCompilerMain.js +10 -10
  47. package/lib/codegen/CodegenDirectory.js +2 -3
  48. package/lib/codegen/CodegenRunner.js +9 -9
  49. package/lib/codegen/CodegenWatcher.js +2 -2
  50. package/lib/codegen/NormalizationCodeGenerator.js +11 -4
  51. package/lib/codegen/ReaderCodeGenerator.js +7 -6
  52. package/lib/codegen/RelayCodeGenerator.js +11 -4
  53. package/lib/codegen/RelayFileWriter.js +14 -14
  54. package/lib/codegen/compileRelayArtifacts.js +3 -3
  55. package/lib/codegen/writeRelayGeneratedFile.js +4 -4
  56. package/lib/core/CompilerContext.js +5 -5
  57. package/lib/core/CompilerError.js +2 -1
  58. package/lib/core/DotGraphQLParser.js +4 -4
  59. package/lib/core/IRPrinter.js +2 -2
  60. package/lib/core/IRTransformer.js +2 -2
  61. package/lib/core/IRValidator.js +2 -2
  62. package/lib/core/RelayCompilerScope.js +34 -0
  63. package/lib/core/RelayFindGraphQLTags.js +2 -2
  64. package/lib/core/RelayIRTransforms.js +4 -4
  65. package/lib/core/RelayParser.js +10 -10
  66. package/lib/core/RelaySourceModuleParser.js +5 -5
  67. package/lib/core/Schema.js +2 -2
  68. package/lib/core/filterContextForNode.js +2 -1
  69. package/lib/core/getIdentifierForArgumentValue.js +2 -1
  70. package/lib/core/getIdentifierForSelection.js +3 -2
  71. package/lib/core/inferRootArgumentDefinitions.js +3 -3
  72. package/lib/index.js +46 -46
  73. package/lib/language/RelayLanguagePluginInterface.js +13 -1
  74. package/lib/language/javascript/FindGraphQLTags.js +2 -2
  75. package/lib/language/javascript/RelayFlowBabelFactories.js +2 -2
  76. package/lib/language/javascript/RelayFlowGenerator.js +3 -3
  77. package/lib/language/javascript/RelayFlowTypeTransformers.js +2 -2
  78. package/lib/language/javascript/RelayLanguagePluginJavaScript.js +2 -2
  79. package/lib/runner/Artifacts.js +3 -3
  80. package/lib/runner/BufferedFilesystem.js +2 -1
  81. package/lib/runner/GraphQLASTNodeGroup.js +2 -2
  82. package/lib/runner/GraphQLNodeMap.js +2 -2
  83. package/lib/runner/Sources.js +2 -2
  84. package/lib/runner/compileArtifacts.js +2 -2
  85. package/lib/runner/extractAST.js +2 -2
  86. package/lib/transforms/ApplyFragmentArgumentTransform.js +6 -6
  87. package/lib/transforms/ClientExtensionsTransform.js +2 -2
  88. package/lib/transforms/ConnectionTransform.js +6 -6
  89. package/lib/transforms/DeclarativeConnectionMutationTransform.js +2 -2
  90. package/lib/transforms/DeferStreamTransform.js +4 -4
  91. package/lib/transforms/DisallowIdAsAlias.js +2 -2
  92. package/lib/transforms/DisallowTypenameOnRoot.js +2 -2
  93. package/lib/transforms/FilterDirectivesTransform.js +2 -1
  94. package/lib/transforms/FlattenTransform.js +6 -6
  95. package/lib/transforms/InlineDataFragmentTransform.js +2 -2
  96. package/lib/transforms/MaskTransform.js +4 -4
  97. package/lib/transforms/MatchTransform.js +4 -4
  98. package/lib/transforms/ReactFlightComponentTransform.js +4 -4
  99. package/lib/transforms/RefetchableFragmentTransform.js +4 -4
  100. package/lib/transforms/RelayDirectiveTransform.js +2 -2
  101. package/lib/transforms/RequiredFieldTransform.js +4 -4
  102. package/lib/transforms/SkipHandleFieldTransform.js +2 -1
  103. package/lib/transforms/SkipRedundantNodesTransform.js +11 -3
  104. package/lib/transforms/SkipUnusedVariablesTransform.js +2 -1
  105. package/lib/transforms/SplitModuleImportTransform.js +2 -2
  106. package/lib/transforms/TestOperationTransform.js +3 -3
  107. package/lib/transforms/ValidateGlobalVariablesTransform.js +3 -2
  108. package/lib/transforms/ValidateRequiredArgumentsTransform.js +2 -2
  109. package/lib/transforms/ValidateServerOnlyDirectivesTransform.js +2 -2
  110. package/lib/transforms/ValidateUnusedVariablesTransform.js +2 -2
  111. package/lib/transforms/query-generators/FetchableQueryGenerator.js +2 -2
  112. package/lib/transforms/query-generators/NodeQueryGenerator.js +4 -4
  113. package/lib/transforms/query-generators/index.js +3 -3
  114. package/lib/util/joinArgumentDefinitions.js +2 -1
  115. package/package.json +2 -2
  116. package/relay-compiler.js +4 -4
  117. package/relay-compiler.min.js +4 -4
  118. package/reporters/ConsoleReporter.js.flow +2 -2
  119. package/runner/Artifacts.js.flow +4 -5
  120. package/runner/BufferedFilesystem.js.flow +3 -3
  121. package/runner/GraphQLASTNodeGroup.js.flow +2 -3
  122. package/runner/GraphQLNodeMap.js.flow +3 -3
  123. package/runner/Sources.js.flow +5 -6
  124. package/runner/compileArtifacts.js.flow +5 -6
  125. package/runner/extractAST.js.flow +4 -6
  126. package/runner/getChangedNodeNames.js.flow +2 -2
  127. package/runner/getSchemaInstance.js.flow +3 -3
  128. package/transforms/ApplyFragmentArgumentTransform.js.flow +9 -11
  129. package/transforms/ClientExtensionsTransform.js.flow +3 -4
  130. package/transforms/ConnectionTransform.js.flow +11 -13
  131. package/transforms/DeclarativeConnectionMutationTransform.js.flow +3 -5
  132. package/transforms/DeferStreamTransform.js.flow +5 -7
  133. package/transforms/DisallowIdAsAlias.js.flow +3 -4
  134. package/transforms/DisallowTypenameOnRoot.js.flow +3 -4
  135. package/transforms/FieldHandleTransform.js.flow +3 -5
  136. package/transforms/FilterCompilerDirectivesTransform.js.flow +2 -2
  137. package/transforms/FilterDirectivesTransform.js.flow +2 -2
  138. package/transforms/FlattenTransform.js.flow +5 -7
  139. package/transforms/GenerateIDFieldTransform.js.flow +4 -5
  140. package/transforms/GenerateTypeNameTransform.js.flow +4 -6
  141. package/transforms/InlineDataFragmentTransform.js.flow +3 -4
  142. package/transforms/InlineFragmentsTransform.js.flow +3 -4
  143. package/transforms/MaskTransform.js.flow +6 -8
  144. package/transforms/MatchTransform.js.flow +7 -9
  145. package/transforms/ReactFlightComponentTransform.js.flow +5 -6
  146. package/transforms/RefetchableFragmentTransform.js.flow +7 -9
  147. package/transforms/RelayDirectiveTransform.js.flow +3 -4
  148. package/transforms/RequiredFieldTransform.js.flow +10 -12
  149. package/transforms/SkipClientExtensionsTransform.js.flow +2 -2
  150. package/transforms/SkipHandleFieldTransform.js.flow +2 -2
  151. package/transforms/SkipRedundantNodesTransform.js.flow +6 -8
  152. package/transforms/SkipSplitOperationTransform.js.flow +2 -2
  153. package/transforms/SkipUnreachableNodeTransform.js.flow +3 -4
  154. package/transforms/SkipUnusedVariablesTransform.js.flow +2 -2
  155. package/transforms/SplitModuleImportTransform.js.flow +4 -5
  156. package/transforms/TestOperationTransform.js.flow +2 -2
  157. package/transforms/ValidateGlobalVariablesTransform.js.flow +3 -4
  158. package/transforms/ValidateRequiredArgumentsTransform.js.flow +5 -6
  159. package/transforms/ValidateServerOnlyDirectivesTransform.js.flow +3 -4
  160. package/transforms/ValidateUnusedVariablesTransform.js.flow +3 -4
  161. package/transforms/query-generators/FetchableQueryGenerator.js.flow +4 -5
  162. package/transforms/query-generators/NodeQueryGenerator.js.flow +5 -7
  163. package/transforms/query-generators/QueryQueryGenerator.js.flow +4 -4
  164. package/transforms/query-generators/ViewerQueryGenerator.js.flow +4 -4
  165. package/transforms/query-generators/index.js.flow +4 -5
  166. package/util/RelayCompilerCache.js.flow +0 -1
  167. package/util/TimeReporter.js.flow +2 -2
  168. package/util/argumentContainsVariables.js.flow +1 -1
  169. package/util/generateAbstractTypeRefinementKey.js.flow +2 -2
  170. package/util/getDefinitionNodeHash.js.flow +2 -3
  171. package/util/joinArgumentDefinitions.js.flow +2 -2
@@ -12,16 +12,15 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const Profiler = require('../core/GraphQLCompilerProfiler');
15
+ // flowlint nonstrict-import:warn
16
+ import type {KeepExtraFileFn} from './CodegenRunner';
17
+ import type {SourceControl} from './SourceControl';
16
18
 
19
+ const Profiler = require('../core/GraphQLCompilerProfiler');
17
20
  const crypto = require('crypto');
18
21
  const invariant = require('invariant');
19
22
  const path = require('path');
20
23
 
21
- // flowlint nonstrict-import:warn
22
- import type {KeepExtraFileFn} from './CodegenRunner';
23
- import type {SourceControl} from './SourceControl';
24
-
25
24
  type Changes = {|
26
25
  +deleted: Array<string>,
27
26
  +updated: Array<string>,
@@ -12,19 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const CodegenDirectory = require('./CodegenDirectory');
16
- const CodegenWatcher = require('./CodegenWatcher');
17
- const GraphQLWatchmanClient = require('../core/GraphQLWatchmanClient');
18
- const Profiler = require('../core/GraphQLCompilerProfiler');
19
-
20
- const invariant = require('invariant');
21
- const path = require('path');
22
-
23
- const {create: createSchema} = require('../core/Schema');
24
- /* $FlowFixMe[untyped-import] - importing immutable, which is untyped (and flow
25
- * is sad about it) */
26
- const {Map: ImmutableMap} = require('immutable');
27
-
28
15
  import type ASTCache from '../core/ASTCache';
29
16
  import type {Schema} from '../core/Schema';
30
17
  import type {Reporter} from '../reporters/Reporter';
@@ -33,6 +20,17 @@ import type {FileFilter, WatchmanExpression} from './CodegenWatcher';
33
20
  import type {SourceControl} from './SourceControl';
34
21
  import type {DocumentNode, Source} from 'graphql';
35
22
 
23
+ const Profiler = require('../core/GraphQLCompilerProfiler');
24
+ const GraphQLWatchmanClient = require('../core/GraphQLWatchmanClient');
25
+ const {create: createSchema} = require('../core/Schema');
26
+ const CodegenDirectory = require('./CodegenDirectory');
27
+ const CodegenWatcher = require('./CodegenWatcher');
28
+ /* $FlowFixMe[untyped-import] - importing immutable, which is untyped (and flow
29
+ * is sad about it) */
30
+ const {Map: ImmutableMap} = require('immutable');
31
+ const invariant = require('invariant');
32
+ const path = require('path');
33
+
36
34
  export type ParserConfig = {|
37
35
  baseDir: string,
38
36
  getFileFilter?: (baseDir: string) => FileFilter,
@@ -12,15 +12,14 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const GraphQLWatchmanClient = require('../core/GraphQLWatchmanClient');
16
- const Profiler = require('../core/GraphQLCompilerProfiler');
15
+ import type {File} from './CodegenTypes';
17
16
 
17
+ const Profiler = require('../core/GraphQLCompilerProfiler');
18
+ const GraphQLWatchmanClient = require('../core/GraphQLWatchmanClient');
18
19
  const crypto = require('crypto');
19
20
  const fs = require('fs');
20
21
  const path = require('path');
21
22
 
22
- import type {File} from './CodegenTypes';
23
-
24
23
  const SUBSCRIPTION_NAME = 'graphql-codegen';
25
24
  const QUERY_RETRIES = 3;
26
25
 
@@ -12,29 +12,21 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const argumentContainsVariables = require('../util/argumentContainsVariables');
16
- const generateAbstractTypeRefinementKey = require('../util/generateAbstractTypeRefinementKey');
17
- const partitionArray = require('../util/partitionArray');
18
- const sortObjectByKey = require('./sortObjectByKey');
19
-
20
- const {createCompilerError, createUserError} = require('../core/CompilerError');
21
- const {getStorageKey, stableCopy} = require('relay-runtime');
22
-
23
15
  import type {
24
16
  Argument,
25
17
  ArgumentValue,
26
18
  ClientExtension,
19
+ Condition,
20
+ Defer,
21
+ InlineFragment,
22
+ LinkedField,
23
+ LocalArgumentDefinition,
27
24
  Metadata,
25
+ ModuleImport,
28
26
  Root,
29
27
  Selection,
30
28
  SplitOperation,
31
- LinkedField,
32
- Defer,
33
29
  Stream,
34
- Condition,
35
- InlineFragment,
36
- ModuleImport,
37
- LocalArgumentDefinition,
38
30
  } from '../core/IR';
39
31
  import type {Schema, TypeID} from '../core/Schema';
40
32
  import type {
@@ -52,6 +44,13 @@ import type {
52
44
  NormalizationTypeDiscriminator,
53
45
  } from 'relay-runtime';
54
46
 
47
+ const {createCompilerError, createUserError} = require('../core/CompilerError');
48
+ const argumentContainsVariables = require('../util/argumentContainsVariables');
49
+ const generateAbstractTypeRefinementKey = require('../util/generateAbstractTypeRefinementKey');
50
+ const partitionArray = require('../util/partitionArray');
51
+ const sortObjectByKey = require('./sortObjectByKey');
52
+ const {getStorageKey, stableCopy} = require('relay-runtime');
53
+
55
54
  /**
56
55
  * @public
57
56
  *
@@ -12,31 +12,23 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const CodeMarker = require('../util/CodeMarker');
16
-
17
- const argumentContainsVariables = require('../util/argumentContainsVariables');
18
- const generateAbstractTypeRefinementKey = require('../util/generateAbstractTypeRefinementKey');
19
-
20
- const {createCompilerError, createUserError} = require('../core/CompilerError');
21
- const {getStorageKey, stableCopy} = require('relay-runtime');
22
-
23
15
  import type {
24
16
  Argument,
25
- ArgumentValue,
26
17
  ArgumentDefinition,
18
+ ArgumentValue,
27
19
  ClientExtension,
20
+ Condition,
28
21
  Defer,
29
- Stream,
30
- Metadata,
31
22
  Fragment,
32
- Selection,
33
- Condition,
34
- LinkedField,
35
- ScalarField,
36
23
  FragmentSpread,
24
+ InlineDataFragmentSpread,
37
25
  InlineFragment,
26
+ LinkedField,
27
+ Metadata,
38
28
  ModuleImport,
39
- InlineDataFragmentSpread,
29
+ ScalarField,
30
+ Selection,
31
+ Stream,
40
32
  } from '../core/IR';
41
33
  import type {Schema, TypeID} from '../core/Schema';
42
34
  import type {RequiredDirectiveMetadata} from '../transforms/RequiredFieldTransform';
@@ -55,6 +47,12 @@ import type {
55
47
  RequiredFieldAction,
56
48
  } from 'relay-runtime';
57
49
 
50
+ const {createCompilerError, createUserError} = require('../core/CompilerError');
51
+ const argumentContainsVariables = require('../util/argumentContainsVariables');
52
+ const CodeMarker = require('../util/CodeMarker');
53
+ const generateAbstractTypeRefinementKey = require('../util/generateAbstractTypeRefinementKey');
54
+ const {getStorageKey, stableCopy} = require('relay-runtime');
55
+
58
56
  /**
59
57
  * @public
60
58
  *
@@ -12,13 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const NormalizationCodeGenerator = require('./NormalizationCodeGenerator');
16
- const ReaderCodeGenerator = require('./ReaderCodeGenerator');
17
- const sortObjectByKey = require('./sortObjectByKey');
18
- const md5 = require('../util/md5');
19
- const nullthrows = require('nullthrows');
20
- const {createCompilerError} = require('../core/CompilerError');
21
-
22
15
  import type {Fragment, Request, SplitOperation} from '../core/IR';
23
16
  import type {Schema} from '../core/Schema';
24
17
  import type {
@@ -27,6 +20,13 @@ import type {
27
20
  ReaderFragment,
28
21
  } from 'relay-runtime';
29
22
 
23
+ const {createCompilerError} = require('../core/CompilerError');
24
+ const md5 = require('../util/md5');
25
+ const NormalizationCodeGenerator = require('./NormalizationCodeGenerator');
26
+ const ReaderCodeGenerator = require('./ReaderCodeGenerator');
27
+ const sortObjectByKey = require('./sortObjectByKey');
28
+ const nullthrows = require('nullthrows');
29
+
30
30
  /**
31
31
  * @public
32
32
  *
@@ -12,40 +12,38 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const ASTConvert = require('../core/ASTConvert');
16
- const CodegenDirectory = require('./CodegenDirectory');
17
- const CompilerContext = require('../core/CompilerContext');
18
- const Profiler = require('../core/GraphQLCompilerProfiler');
19
- const RelayParser = require('../core/RelayParser');
20
-
21
- const compileRelayArtifacts = require('./compileRelayArtifacts');
22
- const graphql = require('graphql');
23
- const invariant = require('invariant');
24
- const md5 = require('../util/md5');
25
- const nullthrows = require('nullthrows');
26
- const path = require('path');
27
- const writeRelayGeneratedFile = require('./writeRelayGeneratedFile');
28
-
29
- const {
30
- getReaderSourceDefinitionName,
31
- } = require('../core/GraphQLDerivedFromMetadata');
32
- const {isExecutableDefinitionAST} = require('../core/SchemaUtils');
33
- const {Map: ImmutableMap} = require('immutable');
34
-
35
15
  import type {Schema} from '../core/Schema';
16
+ import type {ScalarTypeMapping} from '../language/javascript/RelayFlowTypeTransformers';
36
17
  import type {
37
18
  FormatModule,
38
19
  PluginInterface,
39
20
  TypeGenerator,
40
21
  } from '../language/RelayLanguagePluginInterface';
41
- import type {ScalarTypeMapping} from '../language/javascript/RelayFlowTypeTransformers';
42
22
  import type {Reporter} from '../reporters/Reporter';
43
23
  import type {Filesystem} from './CodegenDirectory';
44
- import type {SourceControl} from './SourceControl';
45
24
  import type {RelayCompilerTransforms} from './compileRelayArtifacts';
25
+ import type {SourceControl} from './SourceControl';
46
26
  import type {DocumentNode, ValidationContext} from 'graphql';
47
27
  import type {RequestParameters} from 'relay-runtime';
48
28
 
29
+ const ASTConvert = require('../core/ASTConvert');
30
+ const CompilerContext = require('../core/CompilerContext');
31
+ const Profiler = require('../core/GraphQLCompilerProfiler');
32
+ const {
33
+ getReaderSourceDefinitionName,
34
+ } = require('../core/GraphQLDerivedFromMetadata');
35
+ const RelayParser = require('../core/RelayParser');
36
+ const {isExecutableDefinitionAST} = require('../core/SchemaUtils');
37
+ const md5 = require('../util/md5');
38
+ const CodegenDirectory = require('./CodegenDirectory');
39
+ const compileRelayArtifacts = require('./compileRelayArtifacts');
40
+ const writeRelayGeneratedFile = require('./writeRelayGeneratedFile');
41
+ const graphql = require('graphql');
42
+ const {Map: ImmutableMap} = require('immutable');
43
+ const invariant = require('invariant');
44
+ const nullthrows = require('nullthrows');
45
+ const path = require('path');
46
+
49
47
  export type GenerateExtraFiles = (
50
48
  getOutputDirectory: (path?: string) => CodegenDirectory,
51
49
  compilerContext: CompilerContext,
@@ -12,18 +12,17 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const Printer = require('../core/IRPrinter');
16
- const Profiler = require('../core/GraphQLCompilerProfiler');
17
- const RelayCodeGenerator = require('./RelayCodeGenerator');
18
-
19
- const filterContextForNode = require('../core/filterContextForNode');
20
-
21
15
  import type CompilerContext from '../core/CompilerContext';
22
16
  import type {IRTransform} from '../core/CompilerContext';
23
17
  import type {GeneratedDefinition} from '../core/IR';
24
18
  import type {Reporter} from '../reporters/Reporter';
25
19
  import type {GeneratedNode} from 'relay-runtime';
26
20
 
21
+ const filterContextForNode = require('../core/filterContextForNode');
22
+ const Profiler = require('../core/GraphQLCompilerProfiler');
23
+ const Printer = require('../core/IRPrinter');
24
+ const RelayCodeGenerator = require('./RelayCodeGenerator');
25
+
27
26
  export type RelayCompilerTransforms = {
28
27
  commonTransforms: $ReadOnlyArray<IRTransform>,
29
28
  codegenTransforms: $ReadOnlyArray<IRTransform>,
@@ -12,15 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const CodeMarker = require('../util/CodeMarker');
16
-
17
- const createPrintRequireModuleDependency = require('./createPrintRequireModuleDependency');
18
- const dedupeJSONStringify = require('../util/dedupeJSONStringify');
19
- const invariant = require('invariant');
20
- const md5 = require('../util/md5');
21
-
22
- const {RelayConcreteNode} = require('relay-runtime');
23
-
24
15
  import type {GeneratedDefinition} from '../core/IR';
25
16
  import type {Schema} from '../core/Schema';
26
17
  import type {
@@ -30,6 +21,13 @@ import type {
30
21
  import type CodegenDirectory from './CodegenDirectory';
31
22
  import type {GeneratedNode, RequestParameters} from 'relay-runtime';
32
23
 
24
+ const CodeMarker = require('../util/CodeMarker');
25
+ const dedupeJSONStringify = require('../util/dedupeJSONStringify');
26
+ const md5 = require('../util/md5');
27
+ const createPrintRequireModuleDependency = require('./createPrintRequireModuleDependency');
28
+ const invariant = require('invariant');
29
+ const {RelayConcreteNode} = require('relay-runtime');
30
+
33
31
  function getConcreteType(node: GeneratedNode): string {
34
32
  switch (node.kind) {
35
33
  case RelayConcreteNode.FRAGMENT:
@@ -12,14 +12,13 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const Profiler = require('./GraphQLCompilerProfiler');
15
+ import type {File} from '../codegen/CodegenTypes';
16
+ import type {DocumentNode} from 'graphql';
16
17
 
18
+ const Profiler = require('./GraphQLCompilerProfiler');
17
19
  // $FlowFixMe[untyped-import] : Immutable is not typed
18
20
  const {Map: ImmutableMap} = require('immutable');
19
21
 
20
- import type {File} from '../codegen/CodegenTypes';
21
- import type {DocumentNode} from 'graphql';
22
-
23
22
  type ParseFn = (baseDir: string, file: File) => ?DocumentNode;
24
23
 
25
24
  class ASTCache {
@@ -12,14 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const Profiler = require('./GraphQLCompilerProfiler');
16
-
17
- const {
18
- isExecutableDefinitionAST,
19
- isSchemaDefinitionAST,
20
- } = require('./SchemaUtils');
21
- const {extendSchema, parse, print, visit} = require('graphql');
22
-
23
15
  import type {Fragment, Root} from './IR';
24
16
  import type {Schema} from './Schema';
25
17
  import type {
@@ -33,6 +25,13 @@ import type {
33
25
  TypeSystemExtensionNode,
34
26
  } from 'graphql';
35
27
 
28
+ const Profiler = require('./GraphQLCompilerProfiler');
29
+ const {
30
+ isExecutableDefinitionAST,
31
+ isSchemaDefinitionAST,
32
+ } = require('./SchemaUtils');
33
+ const {extendSchema, parse, print, visit} = require('graphql');
34
+
36
35
  type ASTDefinitionNode = FragmentDefinitionNode | OperationDefinitionNode;
37
36
  type TransformFn = (
38
37
  schema: Schema,
@@ -12,17 +12,15 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const Profiler = require('./GraphQLCompilerProfiler');
16
-
17
- const invariant = require('invariant');
15
+ import type {Reporter} from '../reporters/Reporter';
16
+ import type {Fragment, Location, Root, SplitOperation} from './IR';
17
+ import type {Schema} from './Schema';
18
18
 
19
19
  const {createUserError} = require('./CompilerError');
20
+ const Profiler = require('./GraphQLCompilerProfiler');
20
21
  // $FlowFixMe[untyped-import] - immutable.js is not flow-typed
21
22
  const {OrderedMap: ImmutableOrderedMap} = require('immutable');
22
-
23
- import type {Reporter} from '../reporters/Reporter';
24
- import type {Fragment, Location, Root, SplitOperation} from './IR';
25
- import type {Schema} from './Schema';
23
+ const invariant = require('invariant');
26
24
 
27
25
  export type IRTransform = CompilerContext => CompilerContext;
28
26
 
@@ -12,11 +12,11 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const {GraphQLError} = require('graphql');
16
-
17
15
  import type {Location} from './IR';
18
16
  import type {ASTNode, Source, SourceLocation} from 'graphql';
19
17
 
18
+ const {GraphQLError} = require('graphql');
19
+
20
20
  // Combined results of multiple user errors
21
21
  export opaque type CombinedUserError: Error = Error;
22
22
 
@@ -12,16 +12,14 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const ASTCache = require('./ASTCache');
15
+ import type {File} from '../codegen/CodegenTypes';
16
+ import type {DocumentNode} from 'graphql';
16
17
 
18
+ const ASTCache = require('./ASTCache');
17
19
  const fs = require('fs');
20
+ const {Source, parse} = require('graphql');
18
21
  const path = require('path');
19
22
 
20
- const {parse, Source} = require('graphql');
21
-
22
- import type {File} from '../codegen/CodegenTypes';
23
- import type {DocumentNode} from 'graphql';
24
-
25
23
  function parseFile(baseDir: string, file: File): ?DocumentNode {
26
24
  const text = fs.readFileSync(path.join(baseDir, file.relPath), 'utf8');
27
25
  return parse(new Source(text, file.relPath), {
package/core/IR.js.flow CHANGED
@@ -13,10 +13,10 @@
13
13
  'use strict';
14
14
 
15
15
  import type {
16
- LinkedFieldTypeID,
17
- ScalarFieldTypeID,
18
16
  CompositeTypeID,
19
17
  InputTypeID,
18
+ LinkedFieldTypeID,
19
+ ScalarFieldTypeID,
20
20
  } from './Schema';
21
21
  import type {Source} from 'graphql';
22
22
 
@@ -12,10 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const invariant = require('invariant');
16
-
17
- const {DEFAULT_HANDLE_KEY} = require('../util/DefaultHandleKey');
18
-
19
15
  import type {CompilerContextDocument} from './CompilerContext';
20
16
  import type {
21
17
  Argument,
@@ -29,6 +25,9 @@ import type {
29
25
  } from './IR';
30
26
  import type {Schema, TypeID} from './Schema';
31
27
 
28
+ const {DEFAULT_HANDLE_KEY} = require('../util/DefaultHandleKey');
29
+ const invariant = require('invariant');
30
+
32
31
  const INDENT = ' ';
33
32
 
34
33
  /**
@@ -12,10 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const invariant = require('invariant');
16
-
17
- const {eachWithCombinedError} = require('./CompilerError');
18
-
19
15
  import type CompilerContext, {CompilerContextDocument} from './CompilerContext';
20
16
  import type {
21
17
  Argument,
@@ -25,9 +21,9 @@ import type {
25
21
  Directive,
26
22
  Fragment,
27
23
  FragmentSpread,
28
- IR,
29
24
  InlineDataFragmentSpread,
30
25
  InlineFragment,
26
+ IR,
31
27
  LinkedField,
32
28
  ListValue,
33
29
  Literal,
@@ -44,6 +40,9 @@ import type {
44
40
  Variable,
45
41
  } from './IR';
46
42
 
43
+ const {eachWithCombinedError} = require('./CompilerError');
44
+ const invariant = require('invariant');
45
+
47
46
  type NodeVisitor<S> = {|
48
47
  Argument?: NodeVisitorFunction<Argument, S>,
49
48
  ClientExtension?: NodeVisitorFunction<ClientExtension, S>,
@@ -12,10 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const invariant = require('invariant');
16
-
17
- const {eachWithCombinedError} = require('./CompilerError');
18
-
19
15
  import type CompilerContext, {CompilerContextDocument} from './CompilerContext';
20
16
  import type {
21
17
  Argument,
@@ -44,6 +40,9 @@ import type {
44
40
  Variable,
45
41
  } from './IR';
46
42
 
43
+ const {eachWithCombinedError} = require('./CompilerError');
44
+ const invariant = require('invariant');
45
+
47
46
  type NodeVisitor<S> = {|
48
47
  Argument?: NodeVisitorFunction<Argument, S>,
49
48
  ClientExtension?: NodeVisitorFunction<ClientExtension, S>,
@@ -12,8 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const {visit} = require('graphql');
16
-
17
15
  import type {
18
16
  Argument,
19
17
  ClientExtension,
@@ -37,6 +35,8 @@ import type {
37
35
  Variable,
38
36
  } from './IR';
39
37
 
38
+ const {visit} = require('graphql');
39
+
40
40
  const NodeKeys = {
41
41
  Argument: ['value'],
42
42
  ClientExtension: ['selections'],
@@ -12,11 +12,11 @@
12
12
 
13
13
  'use strict';
14
14
 
15
+ import type {SourceModuleParser} from './RelaySourceModuleParser';
16
+
15
17
  const FindGraphQLTags = require('../language/javascript/FindGraphQLTags');
16
18
  const RelaySourceModuleParser = require('./RelaySourceModuleParser');
17
19
 
18
- import type {SourceModuleParser} from './RelaySourceModuleParser';
19
-
20
20
  const JSModuleParser: SourceModuleParser = RelaySourceModuleParser(
21
21
  FindGraphQLTags.find,
22
22
  );
@@ -12,8 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const {createUserError, eachWithCombinedError} = require('./CompilerError');
16
-
17
15
  import type {
18
16
  Argument,
19
17
  ArgumentDefinition,
@@ -23,6 +21,8 @@ import type {
23
21
  Variable,
24
22
  } from './IR';
25
23
  import type {Schema} from './Schema';
24
+
25
+ const {createUserError, eachWithCombinedError} = require('./CompilerError');
26
26
  /**
27
27
  * A scope is a mapping of the values for each argument defined by the nearest
28
28
  * ancestor root or fragment of a given IR selection. A scope maps argument
@@ -12,19 +12,18 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const RelayCompilerCache = require('../util/RelayCompilerCache');
16
-
17
- const getModuleName = require('../util/getModuleName');
18
- const graphql = require('graphql');
19
- const path = require('path');
20
- const util = require('util');
21
-
22
15
  import type {File} from '../codegen/CodegenTypes';
23
16
  import type {
24
17
  GraphQLTag,
25
18
  GraphQLTagFinder,
26
19
  } from '../language/RelayLanguagePluginInterface';
27
20
 
21
+ const getModuleName = require('../util/getModuleName');
22
+ const RelayCompilerCache = require('../util/RelayCompilerCache');
23
+ const graphql = require('graphql');
24
+ const path = require('path');
25
+ const util = require('util');
26
+
28
27
  const cache = new RelayCompilerCache('RelayFindGraphQLTags', 'v1');
29
28
 
30
29
  function memoizedFind(
@@ -12,11 +12,11 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const SignedSource = require('signedsource');
16
-
17
15
  import type CodegenDirectory from '../codegen/CodegenDirectory';
18
16
  import type {Schema} from '../core/Schema';
19
17
 
18
+ const SignedSource = require('signedsource');
19
+
20
20
  function writeForSchema(
21
21
  schema: Schema,
22
22
  licenseHeader: $ReadOnlyArray<string>,
@@ -12,6 +12,9 @@
12
12
 
13
13
  'use strict';
14
14
 
15
+ import type {IRTransform} from './CompilerContext';
16
+
17
+ const RelayFlowGenerator = require('../language/javascript/RelayFlowGenerator');
15
18
  const ApplyFragmentArgumentTransform = require('../transforms/ApplyFragmentArgumentTransform');
16
19
  const ClientExtensionsTransform = require('../transforms/ClientExtensionsTransform');
17
20
  const ConnectionTransform = require('../transforms/ConnectionTransform');
@@ -32,7 +35,6 @@ const MatchTransform = require('../transforms/MatchTransform');
32
35
  const ReactFlightComponentTransform = require('../transforms/ReactFlightComponentTransform');
33
36
  const RefetchableFragmentTransform = require('../transforms/RefetchableFragmentTransform');
34
37
  const RelayDirectiveTransform = require('../transforms/RelayDirectiveTransform');
35
- const RelayFlowGenerator = require('../language/javascript/RelayFlowGenerator');
36
38
  const RequiredFieldTransform = require('../transforms/RequiredFieldTransform');
37
39
  const SkipClientExtensionsTransform = require('../transforms/SkipClientExtensionsTransform');
38
40
  const SkipHandleFieldTransform = require('../transforms/SkipHandleFieldTransform');
@@ -46,8 +48,6 @@ const ValidateGlobalVariablesTransform = require('../transforms/ValidateGlobalVa
46
48
  const ValidateRequiredArgumentsTransform = require('../transforms/ValidateRequiredArgumentsTransform');
47
49
  const ValidateUnusedVariablesTransform = require('../transforms/ValidateUnusedVariablesTransform');
48
50
 
49
- import type {IRTransform} from './CompilerContext';
50
-
51
51
  // Transforms applied to the code used to process a query response.
52
52
  const relaySchemaExtensions: $ReadOnlyArray<string> = [
53
53
  ConnectionTransform.SCHEMA_EXTENSION,