Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error encoding arrays of custom scalars #346

Open
IgnisDa opened this issue Nov 1, 2022 · 9 comments
Open

Error encoding arrays of custom scalars #346

IgnisDa opened this issue Nov 1, 2022 · 9 comments

Comments

@IgnisDa
Copy link

IgnisDa commented Nov 1, 2022

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
Copy link
Author

IgnisDa commented Nov 1, 2022

Probably got something to do with this line:

return (scalars?.[scalarKey]?.encode?.(a) as string) || JSON.stringify(a);

@aexol
Copy link
Collaborator

aexol commented Dec 13, 2022

ok looking into it now

@aexol
Copy link
Collaborator

aexol commented Dec 13, 2022

What it lacks are tests.

@MurmeltierS
Copy link

MurmeltierS commented Sep 27, 2023

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

image

@ogil7190
Copy link

@IgnisDa is this still active?

@IgnisDa
Copy link
Author

IgnisDa commented Sep 28, 2023

@ogil7190 no idea. I am not a maintainer.

@ogil7190
Copy link

@MurmeltierS is this still open to work?

@MurmeltierS
Copy link

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

@Vishal-Sikka
Copy link

/attempt #346

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants