facebook / facebook/relay

[Modern] Best way to write platform-specific (ios, android, web) fragments?

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

Description

I have the following fragment:

```graphql
info: graphql.experimental`
fragment Url_info on Url @argumentDefinitions(
web: { type: "Boolean!", defaultValue: false }
ios: { type: "Boolean!", defaultValue: false }
android: { type: "Boolean!", defaultValue: false }
) {
id
webUrl
appUrl: webUrl @include(if: $web)
appUrl: iosUrl @include(if: $ios)
appUrl: androidUrl @include(if: $android)
}
`,
```

This is okay, but it becomes very cumbersome to duplicate @argumentDefinitions and @arguments over and over for all parent containers and pass down variables all the way down to platform-specific components.

I tried using `index.ios.js` and `index.android.js`, but it does not work because fragments in different files will share the same fragment unique id.

Is there any convenient way for this?

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.