8000 ParseQueryWithTokenLimit's error is not processed correctly by gqlgen · Issue #3693 · 99designs/gqlgen · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content 8000
ParseQueryWithTokenLimit's error is not processed correctly by gqlgen #3693
Closed
@hansod1

Description

@hansod1

This concerns the token limit config option added last year: #3136

I was testing it and noticed that it doesn't send the correct error to the client because this part of the gqlgen codebase does not correctly interpret the token limit error as a parsing error because it is not returned from the parser as a *gqlerror.Error, and rather is an errors.errorString created with fmt.Errorf:

	doc, err := parser.ParseQueryWithTokenLimit(&ast.Source{Input: query}, e.parserTokenLimit)
	if err != nil {
		gqlErr, ok := err.(*gqlerror.Error)
		if ok {
			errcode.Set(gqlErr, errcode.ParseFailed)
			return nil, gqlerror.List{gqlErr}
		}
	}

For reference, here is the change in gqlparser that added the new error.

Is there a deeper reason why this function isn't designed to return all errors out of ParseQueryWithTokenLimit and is instead only checking for *gqlerror.Error?

I am unsure why they didn't create a gqlerror over in the parser, but I suspect that's the right place to fix this. That being said, let me know if you'd accept a PR returning all errors, not just gqlerror, from ParseQueryWithTokenLimit and I'll submit it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0