facebook / facebook/relay

[relay-compiler 13] Invalid use of @stream on scalar field

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

Description

With v13 (even on @main) I get error when using @stream on a List of scalars, while it works for objects.
Is this defined somewhere in the spec? It is not clear to me ([spec for @stream](https://github.com/graphql/graphql-wg/blob/main/rfcs/DeferStream.md#stream)) , just the field must be List type. The `data` in `payload` could be any scalar too.

```graphql
type Query {
alphabet: [String!]
}
```

```javascript
alphabet: {
type: new GraphQLList(new GraphQLNonNull(GraphQLString)),
resolve: async function* () {
for (let letter = 65; letter <= 90; letter += await bumpy(1)) {
yield String.fromCharCode(letter);
}
},
},
```

```javascript
query demo3Query {
alphabet @stream(initial_count: 3) // <== [ERROR] ✖︎ Invalid use of @stream on scalar field 'alphabet'
}
```

Note: the [test](https://github.com/facebook/relay/blob/86842c141eb59b31269893f224bf24375a2b3539/compiler/crates/relay-transforms/tests/defer_stream/fixtures/fragment-with-stream-on-scalar-field.invalid.expected) is correct for such case, but it does not cover the above mentioned case but it is pretty much similar, just a different query field.

The above example works for this kind of query:

```javascript
query demo3Query {
alphabet @stream(initial_count: 3) {
char
}
}
```

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.