gql-query-builder icon indicating copy to clipboard operation
gql-query-builder copied to clipboard

Add enum

Open felipe-gustavo opened this issue 5 years ago • 6 comments

i have some query that need add Enum like that:

{
  diagnostic__defects(page: 1, orderBy: [{field: IS_FUNCTIONAL_DEFECT, order: DESC}]) {
    data {
      id
      name
    }
  }
}

IS_FUNCTIONAL_DEFECT and DESC are ENUM, can't be wrapped by quote

felipe-gustavo avatar Jul 03 '20 20:07 felipe-gustavo

@felipe-gustavo feel free to open a PR for this use case.

atulmy avatar Jul 04 '20 13:07 atulmy

@felipe-gustavo can you try the following command

const gqlquery = query([
  {
    operation: "diagnostic__defects",
    variables: {
      page: {
        value: 1
      },
      orderBy:{
        list: true,
        type: 'type your order input value here, defined in the schema',
        value: {field: 'IS_FUNCTIONAL_DEFECT', order: 'DESC'}
      }
    },
    fields: [{'data':['id','name']}]
  },
]);

Devorein avatar Jul 05 '20 05:07 Devorein

@felipe-gustavo Atm there is no way to embed argument values directly, but hopefully the above will work, otherwise I'll send a PR to embed argument values directly without using variables

Devorein avatar Jul 05 '20 05:07 Devorein

@Devorein @atulmy I have the same use case. The above command you posted did not work for me. Has there been any update on this?

ehrenmurdick avatar Nov 11 '21 20:11 ehrenmurdick

Same here.

julienlagorsse-loreal avatar Jan 31 '23 14:01 julienlagorsse-loreal

To spare the sanity of anyone else who might resort to reading the graphql spec like me, no the graphql spec doesn't say that the server must accept strings in the variables transport for enum values. It specifically says it may accept strings. The relevant section is here: https://spec.graphql.org/October2021/#sec-Enums.Input-Coercion

I think I have enough time today to implement a PR for this so I'm working on it now.

ehrenmurdick avatar Feb 02 '23 19:02 ehrenmurdick