twenty
twenty copied to clipboard
Discrepancy for JSON type between GraphiQL and API
GraphiQL (whether the docs version or the one on api.twenty.com) expects ECMA-404 formatting for JSON fields (i.e. a stringified JSON). But what the API expect is actually normal JSON (non sitringified).
In the screen below, the request was underlined as if it would fail but it turns out this request worked perfectly:
Query:
mutation CreateOneFieldMetadataItem($input: CreateOneFieldMetadataInput!) {
createOneField(input: $input) {
id
type
name
label
description
icon
isCustom
isActive
isNullable
createdAt
updatedAt
}
}
Variables:
{
"input": {
"field": {
"description": null,
"icon": "IconBuildingFactory2",
"label": "Industry",
"name": "industry",
"options": [
{
"color": "gray",
"label": "📊 Accounting",
"position": 0,
"value": "ACCOUNTING"
},
{
"color": "gray",
"label": "✈️ Airlines/Aviation",
"position": 1,
"value": "AIRLINES_AVIATION"
}
],
"objectMetadataId": "3e028c57-0d5b-4467-975b-ad08cc00c966",
"type": "SELECT"
}
}
}
https://github.com/graphql/graphiql/pull/168
@martmull any idea for a quickfix on this since you've touched the console? Or does that seem like a more complex issue?
@gitstart-twenty could you please look into this and see if you find a quick fix? Thanks
Here is the GitStart Ticket for this issue: https://clients.gitstart.com/twenty/5449/tickets/TWNTY-3306
Hey @FelixMalfait
It appears that GraphiQL has issues validating custom scalars in general and not just JSON. The errors however, do not affect the queries as they still work as expected.
Please refer to the issues below for context:
- JSON object as String in query variables #262
- graphiql shows error Expected value of type "jsonb" #4787
There's also an RFC that proposes attaching a URI to custom scalars to provide a link to the scalar's definition here