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

Crash while creating error message for type error in named query without operationName #142

Closed
bullno1 opened this issue Dec 28, 2017 · 3 comments

Comments

@bullno1
Copy link
Contributor

bullno1 commented Dec 28, 2017

That was a handful to type.

Basically, given a named query:

query FindSomething($input: Input!) {
  find(input: $input)
}

$input contains a type error (e.g: negative number for a uint type).
operationName is not given by the client and following graphql-erlang-tutorial, it is set to undefined.

Given this query, graphql will crash with:

#{class => error,
  error => {case_clause,{undefined}},
  module => my_web_handler_module,
  stacktrace =>
      [{graphql_err,'-path/1-F/1-0-',1,
                    [{file,"/home/bullno1/Projects/nm-exchange-api/_build/default/lib/graphql/src/graphql_err.erl"},
                     {line,43}]},
       {graphql_err,'-path/1-lc$^2/1-2-',2,
                    [{file,"/home/bullno1/Projects/nm-exchange-api/_build/default/lib/graphql/src/graphql_err.erl"},
                     {line,60}]},
       {graphql_err,path,1,
                    [{file,"/home/bullno1/Projects/nm-exchange-api/_build/default/lib/graphql/src/graphql_err.erl"},
                     {line,60}]},
       {graphql_err,mk,3,
                    [{file,"/home/bullno1/Projects/nm-exchange-api/_build/default/lib/graphql/src/graphql_err.erl"},
                     {line,20}]},
       {graphql_err,abort,3,
                    [{file,"/home/bullno1/Projects/nm-exchange-api/_build/default/lib/graphql/src/graphql_err.erl"},
                     {line,16}]},
       {graphql_type_check,check_input_object_fields,4,
                           [{file,"/home/bullno1/Projects/nm-exchange-api/_build/default/lib/graphql/src/graphql_type_check.erl"},
                            {line,232}]},
       {graphql_type_check,'-tc_params/3-fun-0-',4,
                           [{file,"/home/bullno1/Projects/nm-exchange-api/_build/default/lib/graphql/src/graphql_type_check.erl"},
                            {line,131}]},
       {lists,foldl,3,[{file,"lists.erl"},{line,1263}]}]}

Which I guess is while it's trying to build the error path, hence the undefined case clause.
After I give operationName a correct value, graphql reports the type error correctly without crashing.

GraphQL commit: 135657f745254198f3d07e35fd3a63623144b119

@jlouis
Copy link
Owner

jlouis commented Dec 28, 2017 via email

@jlouis
Copy link
Owner

jlouis commented Jan 2, 2018

This is definitely an oversight and needs a fix.

jlouis added a commit that referenced this issue Jan 2, 2018
Handle undefined operations. Closes #142.
@jlouis
Copy link
Owner

jlouis commented Jan 2, 2018

This should fix the problem in this Issue.

@jlouis jlouis closed this as completed in 9ed3121 Jun 21, 2018
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

No branches or pull requests

2 participants