facebook / facebook/relay

Missing __TypeSchema for node

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

Description

We have a use case where we create a node on the client and add it to a Connection. The node type is a union of two types:
union ParentType = TypeA | TypeB

TypeA implements Node {}

TypeB implements Node {}

If we have fetched a node of either TypeA or TypeB, create a new one of the same type on the client, and add it to the store, it works fine.

However, if we don't yet have it fetched, creating and adding it to the store using 'insertEdgeAfter' in 'commitLocalUpdate' invalidates it.

We've observed that the __TypeScehma for TypeA and TypeB is missing.

Screenshot 2022-07-25 at 6 38 16 PM

'implentsInterface' identifier is undefined and marks data 'missing'.

As a workaround, If on app initialisation, we do something like:

```
store.create('client:type:TypeA', 'TypeSchema')
.setValue(true, 'isParentType')
.setValue(true, 'isNode');

store.create('client:type:TypeB', 'TypeSchema')
.setValue(true, 'isParentType')
.setValue(true, 'isNode');
```

things work fine, but this feels like a hack.

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.