twenty icon indicating copy to clipboard operation
twenty copied to clipboard

Discrepancy for JSON type between GraphiQL and API

Open FelixMalfait opened this issue 1 year ago • 3 comments

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:

Screenshot 2024-01-08 at 14 03 06

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"
    }
  }
}

FelixMalfait avatar Jan 08 '24 13:01 FelixMalfait

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?

FelixMalfait avatar Jan 09 '24 10:01 FelixMalfait

@gitstart-twenty could you please look into this and see if you find a quick fix? Thanks

FelixMalfait avatar May 15 '24 07:05 FelixMalfait

Here is the GitStart Ticket for this issue: https://clients.gitstart.com/twenty/5449/tickets/TWNTY-3306

gitstart-app[bot] avatar May 15 '24 07:05 gitstart-app[bot]

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:

There's also an RFC that proposes attaching a URI to custom scalars to provide a link to the scalar's definition here

gitstart-twenty avatar Jul 11 '24 10:07 gitstart-twenty