Skip to content

Error encoding arrays of custom scalars #346

@IgnisDa

Description

@IgnisDa

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions