relay-compiler 13.0.0-rc.0 → 13.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +1 -1
- package/README.md +109 -0
- package/cli.js +1 -1
- package/index.js +4 -2
- package/linux-x64/relay +0 -0
- package/macos-arm64/relay +0 -0
- package/macos-x64/relay +0 -0
- package/package.json +1 -1
- package/win-x64/relay.exe +0 -0
package/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
MIT License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# Relay Compiler
|
2
|
+
|
3
|
+
Relay-Compiler is a code-generation toolkit for GraphQL. It contains the core
|
4
|
+
functionalities of GraphQL code-gen, including file parsing, validation, syntax
|
5
|
+
tree parsing and transformation.
|
6
|
+
|
7
|
+
## Configuration in package.json
|
8
|
+
|
9
|
+
The simplest way to configure relay is to add a new `relay` section to your
|
10
|
+
`package.json` that contains the relay config.
|
11
|
+
|
12
|
+
At minimum, the relay config must specify where to find source files (i.e. files
|
13
|
+
containing `graphql` literals) and the GraphQL schema for the project.
|
14
|
+
|
15
|
+
```
|
16
|
+
// adding new section to package json
|
17
|
+
{
|
18
|
+
...
|
19
|
+
"scripts": {
|
20
|
+
"relay": "relay-compiler"
|
21
|
+
},
|
22
|
+
...
|
23
|
+
// relay configuration
|
24
|
+
"relay": {
|
25
|
+
"src": "./src",
|
26
|
+
"schema": "./src/schema/app_schema.graphql"
|
27
|
+
}
|
28
|
+
}
|
29
|
+
```
|
30
|
+
Relay Compiler will automatically discover the config if:
|
31
|
+
|
32
|
+
- There is a `relay.config.json`, `relay.config.js` file at the root of the
|
33
|
+
project (i.e. in the same folder as the `package.json` file).
|
34
|
+
- The `package.json` file contains a `"relay"` key.
|
35
|
+
|
36
|
+
Additionally, this config file can be specified with the CLI argument `--config`
|
37
|
+
as follows:
|
38
|
+
|
39
|
+
```shell
|
40
|
+
npm run relay --config ./relay.json
|
41
|
+
```
|
42
|
+
|
43
|
+
or with yarn
|
44
|
+
|
45
|
+
```shell
|
46
|
+
yarn relay --config ./relay.json
|
47
|
+
```
|
48
|
+
|
49
|
+
Please note, that if you pass configuration options via --cli arguments, you'll
|
50
|
+
need to provide a separate configuration for the [babel plugin](https://www.npmjs.com/package/babel-plugin-relay).
|
51
|
+
|
52
|
+
## File Finder
|
53
|
+
Relay compiler uses [`watchman`](https://facebook.github.io/watchman/) to find
|
54
|
+
file sources, and "listen" to the file changes in the "watch" mode.
|
55
|
+
If `watchman` is not available, the compiler will
|
56
|
+
use [glob](https://docs.rs/glob/latest/glob/) to query the filesystem for files.
|
57
|
+
|
58
|
+
## Configuration
|
59
|
+
|
60
|
+
### Supported compiler configuration options
|
61
|
+
|
62
|
+
- `src` Root directory of application code. [string] [required]
|
63
|
+
- `schema` Relative path to the file with GraphQL SDL file.
|
64
|
+
[string] [required]
|
65
|
+
- `artifactDirectory` A specific directory to output all artifacts to. When
|
66
|
+
enabling this the babel plugin needs `artifactDirectory`
|
67
|
+
to be set as well. [string]
|
68
|
+
- `language` The name of the language used for input files and
|
69
|
+
generated artifacts.
|
70
|
+
["flow" | "typescript"] [default: "flow"]
|
71
|
+
- `excludes` Directories to ignore under `src`. [array] [default:
|
72
|
+
["**/node_modules/**", "**/__mocks__/**", "**/__generated__/**"]]
|
73
|
+
- `schemaExtensions` List of directories with schema extensions. [array]
|
74
|
+
- `noFutureProofEnums` For `flow` only. This option controls whether or not
|
75
|
+
a catch-all entry is added to enum type definitions
|
76
|
+
values that may be added in the future. Enabling this
|
77
|
+
means you will have to update your application whenever
|
78
|
+
the GraphQL server schema adds new enum values to
|
79
|
+
prevent it from breaking. [boolean][default: false]
|
80
|
+
- `customScalars` Mappings from custom scalars in your schema to built-in
|
81
|
+
GraphQL types, for type emission purposes. [object]
|
82
|
+
- `eagerEsModules` This option enables emitting ES modules artifacts.
|
83
|
+
[boolean][default: false]
|
84
|
+
- `persistConfig`
|
85
|
+
- `url` String, URL to send a POST request to to persist.
|
86
|
+
[string]
|
87
|
+
- `params` The document will be in a `POST`
|
88
|
+
parameter `text`. This map can contain additional
|
89
|
+
parameters to send. [object]
|
90
|
+
- `codegenCommand` Command name that for relay compiler. [string]
|
91
|
+
|
92
|
+
- `isDevVariableName` Name of the global variable for dev mode (`__DEV__`).
|
93
|
+
[string]
|
94
|
+
- `jsModuleFormat` Formatting style for generated files. `commonjs`
|
95
|
+
or `haste`. Default is `commonjs`.
|
96
|
+
[string]
|
97
|
+
|
98
|
+
|
99
|
+
### CLI configuration
|
100
|
+
|
101
|
+
We also support a limited set of CLI arguments that should cover the most cases
|
102
|
+
when you need to run the compiler.
|
103
|
+
|
104
|
+
- `--src` Relative path to the source code.
|
105
|
+
- `--schema` Relative path to schema file.
|
106
|
+
- `--artifactDirectory` Compiler output directory.
|
107
|
+
- `--repersist` Run the persister even if the query has not changed.
|
108
|
+
- `--watch` Run compiler in `watch` mode
|
109
|
+
(requires [`watchman`](https://facebook.github.io/watchman/) to be installed).
|
package/cli.js
CHANGED
package/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* Copyright (c)
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
*
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
@@ -13,8 +13,10 @@
|
|
13
13
|
const path = require('path');
|
14
14
|
|
15
15
|
let binary;
|
16
|
-
if (process.platform === 'darwin') {
|
16
|
+
if (process.platform === 'darwin' && process.arch === 'x64') {
|
17
17
|
binary = path.join(__dirname, 'macos-x64', 'relay');
|
18
|
+
} else if (process.platform === 'darwin' && process.arch === 'arm64') {
|
19
|
+
binary = path.join(__dirname, 'macos-arm64', 'relay');
|
18
20
|
} else if (process.platform === 'linux' && process.arch === 'x64') {
|
19
21
|
binary = path.join(__dirname, 'linux-x64', 'relay');
|
20
22
|
} else if (process.platform === 'win32' && process.arch === 'x64') {
|
package/linux-x64/relay
CHANGED
Binary file
|
Binary file
|
package/macos-x64/relay
CHANGED
Binary file
|
package/package.json
CHANGED
package/win-x64/relay.exe
CHANGED
Binary file
|