forked from relay-tools/relay-compiler-webpack-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetWriter.js
More file actions
62 lines (59 loc) · 1.44 KB
/
getWriter.js
File metadata and controls
62 lines (59 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { FileWriter, IRTransforms } from 'relay-compiler'
import type { Map } from 'immutable'
import type { GraphQLSchema } from 'graphql'
const {
commonTransforms,
codegenTransforms,
fragmentTransforms,
printTransforms,
queryTransforms,
schemaExtensions
} = IRTransforms
interface WriterConfig {
onlyValidate: boolean;
schema: GraphQLSchema;
documents: Map<string, Object>;
baseDocuments: Map<string, Object>;
sourceControl: any;
reporter: any;
}
export default function getWriter (
languagePlugin: any,
baseDir: string,
outputDir: ?string
) {
return (config: WriterConfig | boolean, ...args) => {
const cfg =
typeof config === 'object'
? config
: {
onlyValidate: config,
schema: args[0],
documents: args[1],
baseDocuments: args[2],
sourceControl: args[3],
reporter: args[4]
}
return new FileWriter({
...cfg,
config: {
baseDir,
compilerTransforms: {
commonTransforms,
codegenTransforms,
fragmentTransforms,
printTransforms,
queryTransforms
},
customScalars: {},
extension: languagePlugin.outputExtension,
formatModule: languagePlugin.formatModule,
inputFieldWhiteListForFlow: [],
outputDir,
schemaExtensions,
typeGenerator: languagePlugin.typeGenerator,
useHaste: false
}
})
}
}