relay-compiler 13.0.0-rc.1 → 13.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +1 -1
- package/README.md +116 -0
- package/cli.js +1 -1
- package/index.js +1 -1
- 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,116 @@
|
|
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
|
+
|
31
|
+
Relay Compiler will automatically discover the config if:
|
32
|
+
|
33
|
+
- There is a `relay.config.json`, `relay.config.js` file at the root of the
|
34
|
+
project (i.e. in the same folder as the `package.json` file).
|
35
|
+
- The `package.json` file contains a `"relay"` key.
|
36
|
+
|
37
|
+
Additionally, this config file can be specified with the CLI argument `--config`
|
38
|
+
as follows:
|
39
|
+
|
40
|
+
```shell
|
41
|
+
npm run relay --config ./relay.json
|
42
|
+
```
|
43
|
+
|
44
|
+
or with yarn
|
45
|
+
|
46
|
+
```shell
|
47
|
+
yarn relay --config ./relay.json
|
48
|
+
```
|
49
|
+
|
50
|
+
Please note, that if you pass configuration options via --cli arguments, you'll
|
51
|
+
need to provide a separate configuration for the
|
52
|
+
[babel plugin](https://www.npmjs.com/package/babel-plugin-relay).
|
53
|
+
|
54
|
+
## File Finder
|
55
|
+
|
56
|
+
Relay compiler uses [`watchman`](https://facebook.github.io/watchman/) to find
|
57
|
+
file sources, and "listen" to the file changes in the "watch" mode. If
|
58
|
+
`watchman` is not available, the compiler will use
|
59
|
+
[glob](https://docs.rs/glob/latest/glob/) to query the filesystem for files.
|
60
|
+
|
61
|
+
## Configuration
|
62
|
+
|
63
|
+
### Supported compiler configuration options
|
64
|
+
|
65
|
+
- `src` Root directory of application code. [string] [required]
|
66
|
+
- `schema` Relative path to the file with GraphQL SDL file. [string] [required]
|
67
|
+
- `schemaConfig`
|
68
|
+
- `nodeInterfaceIdField` Configure the name of the globally unique ID field on
|
69
|
+
the Node interface. Useful if you can't use the default `id` field name.
|
70
|
+
[string][default: "id"]
|
71
|
+
- `artifactDirectory` A specific directory to output all artifacts to. When
|
72
|
+
enabling this the babel plugin needs `artifactDirectory` to be set as well.
|
73
|
+
[string]
|
74
|
+
- `language` The name of the language used for input files and generated
|
75
|
+
artifacts. ["flow" | "typescript"] [default: "flow"]
|
76
|
+
- `excludes` Directories to ignore under `src`. [array] [default:
|
77
|
+
["**/node_modules/**", "**/__mocks__/**", "**/__generated__/**"]]
|
78
|
+
- `schemaExtensions` List of directories with schema extensions. [array]
|
79
|
+
- `noFutureProofEnums` For `flow` only. This option controls whether or not a
|
80
|
+
catch-all entry is added to enum type definitions values that may be added in
|
81
|
+
the future. Enabling this means you will have to update your application
|
82
|
+
whenever the GraphQL server schema adds new enum values to prevent it from
|
83
|
+
breaking. [boolean][default: false]
|
84
|
+
- `customScalars` Mappings from custom scalars in your schema to built-in
|
85
|
+
GraphQL types, for type emission purposes. [object]
|
86
|
+
- `eagerEsModules` This option enables emitting ES modules artifacts.
|
87
|
+
[boolean][default: false]
|
88
|
+
- `persistConfig`
|
89
|
+
- `url` String, URL to send a POST request to to persist. This field is
|
90
|
+
required in `persistConfig` [string]
|
91
|
+
- `params` The document will be in a `POST` parameter `text`. This map can
|
92
|
+
contain additional parameters to send. [object]
|
93
|
+
- `concurrency` The maximum number concurrent requests that will be made to
|
94
|
+
`url`. Use a value greater than 0. [number]
|
95
|
+
- `codegenCommand` Command name that for relay compiler. [string]
|
96
|
+
|
97
|
+
- `isDevVariableName` Name of the global variable for dev mode (`__DEV__`).
|
98
|
+
[string]
|
99
|
+
- `jsModuleFormat` Formatting style for generated files. `commonjs` or `haste`.
|
100
|
+
Default is `commonjs`. [string]
|
101
|
+
|
102
|
+
### CLI configuration
|
103
|
+
|
104
|
+
We also support a limited set of CLI arguments that should cover the most cases
|
105
|
+
when you need to run the compiler.
|
106
|
+
|
107
|
+
- `--src` Relative path to the source code.
|
108
|
+
- `--schema` Relative path to schema file.
|
109
|
+
- `--artifactDirectory` Compiler output directory.
|
110
|
+
- `--repersist` Run the persister even if the query has not changed.
|
111
|
+
- `--watch` Run compiler in `watch` mode. Requires
|
112
|
+
[`watchman`](https://facebook.github.io/watchman/) to be installed.
|
113
|
+
- `--output` Output format of the compiler. Supported options: `debug` |
|
114
|
+
`verbose` | `quiet` | `quietWithErrors`. The default value is `verbose`.
|
115
|
+
- `--validate` Looks for pending changes and exits with non-zero code instead of
|
116
|
+
writing to disk.
|
package/cli.js
CHANGED
package/index.js
CHANGED
package/linux-x64/relay
CHANGED
Binary file
|
package/macos-arm64/relay
CHANGED
Binary file
|
package/macos-x64/relay
CHANGED
Binary file
|
package/package.json
CHANGED
package/win-x64/relay.exe
CHANGED
Binary file
|