graphql-editor / graphql-zeus

GraphQL client and GraphQL code generator with GraphQL autocomplete library generation ⚡⚡⚡ for browser,nodejs and react native ( apollo compatible )
https://graphqleditor.com/docs/zeus
MIT License
1.95k stars 106 forks source link

Serialization of JSONObject not working #144

Closed cjanietz closed 4 weeks ago

cjanietz commented 4 years ago

Hi @aexol Still appreciating your great work on this lib I have come across a new issue unfortunately, which is a custom GraphQL Scalar.

The scalar in question is: https://github.com/taion/graphql-type-json While of course its arguably weird to be able to specify arbitrary objects in a GQL query, JSON and JSONObject are as of today valid usages. Would you mind extending the ScalarResolver to accommodate these types as well for input? Otherwise if okay with you I can also create a PR

Regards, Christopher

aexol commented 4 years ago

Hi @cjanietz I am a little busy now so I will be happy with your PR :) if you have time of course. Regards, Artur

Gozala commented 3 years ago

I've encountered this and am willing to write a pr if this is reopened

machiaveli88 commented 2 years ago

Is there any news here? I am struggling with the same problem as I am using the open source headless CMS Strapi with associated Graphql plugins (strapi-plugin-graphql until version 3 and @strapi/plugin-graphql from version 4) which uses the mentioned above plugin. Now I would like to use Graphql Zeus in the frontend but it doesn't work, because zeus adds quotes to the JSON objects, e.g.

Gql('query')({ user: [ { where: { active: true, }, }, { id: true } ], });

results to

query { user(where: { "active": true }) { id } }

instead of

query { user(where: { active: true }) { id } }

Are there any workarounds?

gfsd3v commented 2 years ago

Having the same problem, also trying to implement using StrapiCMS schema, any updates @Gozala @aexol? Lmk if u guys need any help, I'm not so experienced with GraphQL but I'm here if needed.

Thanks for the awesome work :)

machiaveli88 commented 2 years ago

Any updates here?

assafnoahkoren commented 2 years ago

Got stuck on this too... Had to change my DB schema to work around this. No more JSONB for me...

I prefer to change my DB schema instead of working without graphql-zeus. god bless this library - changed my life.

aexol commented 2 years ago

Use serializers check scalars section inside docs

aexol commented 2 years ago

@AsafKaravani

tuoxiansp commented 3 months ago

try

const $ = (t) => `ZEUS_VAR$${t.join('')}`

thunder.mutation(
    {
      insert_Jsonb_one: [
        {
          object: {
            data: $`data`,
          },
        },
        {
          id: true,
        },
      ],
    },
    {
      variables: {
        data: {...[your data object]},
      },
    }
  )