Skip to content

Relay Runtime "bad error message" - error Invariant Violation #5056

@rbrtbrnschn

Description

@rbrtbrnschn

This is the error message we get when the backend is returning a 3D array.

I would expect better error handling here or a clearer message.

This error still occurs with.

    "relay-runtime": "18.2.0",
error Invariant Violation: RelayResponseNormalizer(): Expected a typename for record `[
  {
    "kind": "String23",
    "__typename": "StringTableValue",
    "string": "Warranty"
  }
]`.
    at invariant (browser.js:38:1)
    at RelayResponseNormalizer._getRecordType (RelayResponseNormalizer.js:106:1)
    at RelayResponseNormalizer.js:419:1
    at Array.forEach (<anonymous>)
    at RelayResponseNormalizer._normalizePluralLink (RelayResponseNormalizer.js:409:1)
    at RelayResponseNormalizer._normalizeField (RelayResponseNormalizer.js:329:1)
    at RelayResponseNormalizer._traverseSelections (RelayResponseNormalizer.js:115:1)
    at RelayResponseNormalizer._normalizeLink (RelayResponseNormalizer.js:402:1)
    at RelayResponseNormalizer._normalizeField (RelayResponseNormalizer.js:331:1)
    at RelayResponseNormalizer._traverseSelections (RelayResponseNormalizer.js:115:1) 

// FE

export const CREATE_TABLE_FROM_TABLE_DEFINITION_MUTATION = graphql`
	mutation right_createTableFromTableDefinitionMutation(
		$input: CreateTableFromTableDefinitionInput!
	) {
		TableDefinition {
			createTableFromTableDefinition(input: $input) {
				table {
					
					kind
					__typeName
					... on BigDecimalTableValue {
						bigDecimal
					}
					... on StringTableValue {
						string
					}
						
				}
			}
		}
	}
`;

When table returns [[MyType!]!]! this will throw said error message, regardless if __typeName is inferred or not.

Rebuilding the backend to give this structure fixed the issue.

export const CREATE_TABLE_FROM_TABLE_DEFINITION_MUTATION = graphql`
	mutation right_createTableFromTableDefinitionMutation(
		$input: CreateTableFromTableDefinitionInput!
	) {
		TableDefinition {
			createTableFromTableDefinition(input: $input) {
				table {
					rows {
						cells {
							kind
							... on BigDecimalTableValue {
								bigDecimal
							}
							... on StringTableValue {
								string
							}
						}
					}
				}
			}
		}
	}
`;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions