graphql-zeus icon indicating copy to clipboard operation
graphql-zeus copied to clipboard

Error encoding arrays of custom scalars

Open IgnisDa opened this issue 2 years ago • 9 comments

Awesome project!

I have a UUID scalar in my graphql schema and someMutation expects [UUID!]! as an input. But when I call the following query:

await gqlSdk('mutation', { scalars })({
   someMutation: [{ ids: [] }, { status: true }]
})

Then the generated query is:

mutation {
   someMutation(id: "") { status } 
}

And the following query generates:

await gqlSdk('mutation', { scalars })({
   someMutation: [{ ids: [uuidv4(), uuidv4()] }, { status: true }]
})
mutation {
   someMutation(id: "dac0b13f-6929-402b-a085-6386db357739,59010d30-0416-47b7-8b21-6f955780e987") { status } 
}

Here is what my scalars looks like

export const scalars = ZeusScalars({
  UUID: {
    encode: (e: unknown) => String(`"${e}"`),
    decode: (e: unknown) => e as string,
  },
});

I expect these scalars to be encoded correctly.

  • Empty inputs should become empty lists ([]).
  • Each element of a non empty array should be encoded individually

Am I doing something wrong or is this a bug?

IgnisDa avatar Nov 01 '22 10:11 IgnisDa

Probably got something to do with this line: https://github.com/graphql-editor/graphql-zeus/blob/0e908549932312dee2857cdd9dc47401e42fb120/src/TreeToTS/functions/new/resolvePath.ts#L139

IgnisDa avatar Nov 01 '22 11:11 IgnisDa

ok looking into it now

aexol avatar Dec 13 '22 15:12 aexol

What it lacks are tests.

aexol avatar Dec 13 '22 15:12 aexol

this still seems to be an issue, correct? amount is of Scalar Type "Money".

image

MurmeltierS avatar Sep 27 '23 16:09 MurmeltierS

@IgnisDa is this still active?

ogil7190 avatar Sep 28 '23 17:09 ogil7190

@ogil7190 no idea. I am not a maintainer.

IgnisDa avatar Sep 28 '23 17:09 IgnisDa

@MurmeltierS is this still open to work?

ogil7190 avatar Sep 28 '23 17:09 ogil7190

@ogil7190 also not a maintainer but it seems to me like this issue is still persisting

MurmeltierS avatar Sep 28 '23 18:09 MurmeltierS

/attempt #346

Vishal-Sikka avatar Sep 29 '23 04:09 Vishal-Sikka