facebook / facebook/relay

RecordProxy: how to access fields with complex arguments?

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

Description

_This is somehow similar to https://github.com/facebook/relay/issues/3065 but it's not really the same._

Hi, we have a `count` field on a connection which accepts complex arguments like so:

```graphql
count(legacyFilter: LeadsLegacyFilter): Int

# input LeadsLegacyFilter {
# labels: [ID!]
# owners: [ID!]
# sources: [ID!]
# status: ALL | ARCHIVED | ...
# }
```

Now, let's say we want to update the `count` number for status `ALL` no matter what labels or other parts of the filter are set (notice the filter fields are all optional). A typical use-case would be a deletion of the record(s) => decrease counter. Here is the issue - the count field is internally stored like so:

```text
count(legacyFilter:{"status":"ALL"})
count(legacyFilter:{"labels":[],"owners":[],"sources":[],"status":"ALL"})
count(legacyFilter:{"labels":["abcdef"],"owners":[],"sources":[],"status":"ALL"})

// ... any other possible combination ∞
```

❓How can I access these fields easily considering `RecordProxy.(get|set)Value` works with explicit arguments and doesn't return the fields unless I know the args in advance?

I'd like to acknowledge that this is a poorly designed GraphQL schema and we have to fix it, however, this issue directly translates to any other field with complex args.

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.