Hotchocolate: OR filter fails with variables

Created on 9 Jan 2020  路  5Comments  路  Source: ChilliCream/hotchocolate

Followup issue of: #1335
Describe the bug
If an OR filter is applied and a variable is inside the filters fail.
I am not sure if this is invalid and i didn't get this of the spec or if it is related to #192

After the argument is resolver with context.Argument<IValueNode>("argname") the variables in a object in a list are not replaced.
Working example with object:
image
Not working example with Array OR:[]:
image

If the variables are not resolved the operation handlers do not recognize the type because in this example Variable == String
https://github.com/ChilliCream/hotchocolate/blob/master/src/Core/Types.Filters/Expressions/OperationHandlers/String/StringOperationHandlerBase.cs#L20

This leads to an empty queue and therefore

Queue empty.
   at System.Collections.Generic.Queue`1.ThrowForEmptyQueue()
   at System.Collections.Generic.Queue`1.Peek()
   at HotChocolate.Types.Filters.QueryableFilterVisitor.CreateFilter[TSource]()
   at HotChocolate.Types.Filters.QueryableFilterMiddleware`1.InvokeAsync(IMiddlewareContext context)
   at HotChocolate.Execution.ExecutionStrategyBase.ExecuteMiddlewareAsync(ResolverContext resolverContext, IErrorHandler errorHandler)

To Reproduce
Executes the tests QueryableFilterTests.Execute_String_Filter_WithVariable_OR in this pull request: #1353

Expected behavior
A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • OS: Windows 10
  • Version Master

Additional context
Thanks to @NickBeukema and @freever for reporting it

bug 馃尪 hot chocolate

Most helpful comment

@michaelstaib My case is working with 10.3.3:

query searchPatents($searchText: String!) {
     patents(where: {OR: [{applicationNumber: $searchText} {patentNumber: $searchText} {publicationNumber: $searchText}]}) {
        totalCount
    }
}

All 5 comments

FYI this also applies to AND

Can you guys recheck with 10.3.3

I tried with 10.3.3 with the following query and still getting the Queue Empty error:

contactGetAll (where: { OR: [{ lastName_contains: $searchTerm }, { firstName_contains: $searchTerm }] }) {
    customer {
        name
    }
}

@PascalSenn has written some tests on the V11 branch ... so I hopefully get my PR tomorrow in. With that I can check what the issue still is.

It might now be something different since I have variables in lists that have objects now under test. There were was an issue the query rewriter regarding this.

@michaelstaib My case is working with 10.3.3:

query searchPatents($searchText: String!) {
     patents(where: {OR: [{applicationNumber: $searchText} {patentNumber: $searchText} {publicationNumber: $searchText}]}) {
        totalCount
    }
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

hognevevle picture hognevevle  路  3Comments

sascha-andres picture sascha-andres  路  4Comments

nigel-sampson picture nigel-sampson  路  5Comments

tunurgitr picture tunurgitr  路  4Comments

RohrerF picture RohrerF  路  3Comments