facebook / facebook/relay

[babel-plugin-relay] Feature Request: Look for Relay config with custom file path

Open
#4,407 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

I have a project that queries two separate GraphQL schemas using Relay and am running the Relay compiler multiple times as recommended by past issues (https://github.com/facebook/relay/issues/3153#issuecomment-671307359, https://github.com/facebook/relay/issues/3562#issuecomment-898692677).

With `relay-compiler`, I can provide a [path to the configuration file](https://github.com/facebook/relay/blob/95ec269c01b92a11338d27a276bde4c8676261a1/packages/relay-compiler/README.md?plain=1#L37-L47), but I cannot provide this to the Babel plugin, as [it's looking for a fixed list of places](https://github.com/facebook/relay/blob/a8dc8a93e5b1caadfd7051e0ef8dbd6ce4194e89/packages/babel-plugin-relay/BabelPluginRelay.js#L16-L25).

Can `babel-plugin-relay` be extended to support a custom config path?

I'm anticipating I could configure things like this:

**`babel.config.js`**
```js
module.exports = {
plugins: [
['relay', { configPath: './relay1.config.json' }],
['relay', { configPath: './relay2.config.json' }, 'relay-2'],
]
};
```

**`relay1.config.json`**
```json
{
"artifactDirectory": "./relay-types/schema1",
"schema": "../schema1.graphql",
"src": "./",
"exclude": ["./graphql/schema2"],
"language": "typescript"
}
```

**`relay2.config.json`**
```json
{
"artifactDirectory": "./relay-types/schema2",
"schema": "../schema2.graphql",
"src": "./",
"exclude": ["./graphql/schema1"],
"language": "typescript"
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.