mhallin/graphql_ppx

Skip/Include directives are parsed incorrectly

Closed this issue · 1 comments

Hi!

module MyQuery = [%graphql
{|
query ($var: Boolean!) {
v1: variousScalars {
nullableString @skip(if: $var)
string @skip(if: $var)
}
v2: variousScalars {
nullableString @include(if: $var)
string @include(if: $var)
}
}
|}
];

Using this directives results in a runtime error because parse code assumes that field should be null or correct type

        var match$7 = value$1["committedFields"];
        var tmp$3;
        if (match$7 !== undefined) {
          var match$8 = Js_json.decodeNull(match$7);
          ...
        } else {
          throw [
                Graphql_error$2,
                "Field committedFields on type Module is missing"
              ];
        }

Thanks for this report, the newly released version 0.2.5 fixes this issue.