facebook / facebook/relay

usePaginationFragment reordering keys of input object

Open
#3,204 8 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

# Summay

One of my components, written using `usePaginationFragment`, was not loading the next page correctly. After translating it to use `createFragmentContainer`, it started to work. While comparing the logs of both implementations, I noticed that the hook is reordering the keys of my object arguments.

### Expected

Object keys of my arguments should not be reordered. In my case, the keys were the following:

### Arguments definition

```js
@argumentDefinitions(
...
order_by: {
type: "[foo_order_by!]"
defaultValue: { precedence: asc, sub: asc_nulls_first, name: asc }
}
) ...
```

### Console output

```js
// arguments called in createFragmentContainer
{
...
"order_by":{ precedence: asc, sub: asc_nulls_first, name: asc }
}

// arguments called in usePgainationContainer
{
...
"order_by":{ name: asc , precedence: asc, sub: asc_nulls_first}
}
```

# Question

Is there anything that can be done to prevent this? Is it expected that one should not rely on the order of object keys in the arguments?

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.