Invariant Violation: RelayResponseNormalizer(): Expected a typename for record
- Dominant language
- Rust
- Stars
- 19k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
Hello, I'm getting the following error whenever I try to run a specific test on jest using the relay-test-utils to mock the response.
```
Error: Uncaught [Invariant Violation: RelayResponseNormalizer(): Expected a typename for record `{
"data": {
"id": "chartData:88e431a2-01f7-4a21-8e13-767e0cb856f4",
"datapoints": [
{
"labels": "",
"timestamp": "",
"value": ""
}
],
"resolution": ""
}
}`.]
```
This is my resolver:
```tsx
const resolver = {
Dashboard: (): any => ({
id: 'dashboard:34a04e31-4fbf-4f3a-826c-ceafbd1768d9',
defaultTimeWindow: null,
widgets: [
{
__typename: 'ChartWidget',
id: 'widget:75a7c752-90d1-4fb1-a390-bb0af1f1eb5d',
// extra data...
chart: {
__typename: 'DonutChart',
id: 'chart:715b526e-07f5-42ab-89b4-29d37819e41a',
// extra data...
data: {
__typename: 'ChartData',
id: 'chartData:88e431a2-01f7-4a21-8e13-767e0cb856f4',
// extra data...
},
},
},
],
}),
};
```
And this is my test that I create a mock environment and pass it to the queueOperationResolver:
```tsx
it('should render the dashboard widgets', () => {
const environment = createMockEnvironment();
environment.mock.queueOperationResolver(operation => MockPayloadGenerator.generate(operation, resolver));
render({
component: (
),
environment: environment,
translation: translation,
});
...
});
```
This test is using `useLazyLoadQuery`, other tests that use the same fragments through `useFragment` or `useRefetchableFragment` are working as expected.
Contributor guide
Assessment
This issue has not been assessed yet.