trompamusic / ce-api

The Contributor Environment API for the TROMPA project
https://trompamusic.eu
Apache License 2.0
6 stars 1 forks source link

Bug when performing filters with substring matches #187

Open alastair opened 3 years ago

alastair commented 3 years ago

I added some data to the production API, ItemList id e91489d7-a776-40dd-8abf-0c934922bd99 I can query it and get all items (these queries work on prod api):

query {
  ItemList(identifier:"e91489d7-a776-40dd-8abf-0c934922bd99") {
    identifier
    name
    itemListElement {
      identifier
      name
    }
  }
}

and I can also filter and ask it to give me the item list, and all itemListElements that have a particular name:

query {
  ItemList(identifier:"e91489d7-a776-40dd-8abf-0c934922bd99") {
    identifier
    name
    itemListElement(filter:{name:"Magnificat quinti toni"}) {
      identifier
      name
    }
  }
}

But I'd also like to be able to do a more wildcard-like search, so I tried:

query {
  ItemList(identifier:"e91489d7-a776-40dd-8abf-0c934922bd99") {
    identifier
    name
    itemListElement(filter:{name_starts_with:"Missa"}) {
      identifier
      name
    }
  }
}

However this fails with an error:

Invalid input '_filter': expected
  "OR"
  "XOR"
  "AND"
  "="
  "!="
  "<>"
  "<="
  ">="
  "<"
  ">"
  "+"
  "-"
  "*"
  "/"
  "%"
  "^"
  "."
  ")"
  "["
  ":" (line 1, column 251 (offset: 250))
"MATCH (`itemList`:`ItemList` {identifier:$identifier}) RETURN `itemList` { .identifier , .name ,itemListElement: [(`itemList`)-[:`ITEM_LIST_ELEMENT`]->(`itemList_itemListElement`:`ThingInterface`) WHERE (`itemList_itemListElement`.name STARTS WITH $1_filter.name_starts_with) | `itemList_itemListElement` {FRAGMENT_TYPE: head( [ label IN labels(`itemList_itemListElement`) WHERE label IN $ThingInterface_derivedTypes ] ), .identifier , .name }] } AS `itemList`"

This makes me think that there's an issue with all of the automatically generated filters that work on strings, but I'm not sure if this is related to the graphql bindings, or something that we do with them.

alastair commented 3 years ago

For now I've been able to work around it by using the regexp match:

query {
  ItemList(identifier:"e91489d7-a776-40dd-8abf-0c934922bd99") {
    identifier
    name
    itemListElement(filter:{name_regexp:"(?i).*missa.*"}) {
      identifier
      name
    }
  }
}
ChristiaanScheermeijer commented 3 years ago

I think this is an issue in the neo4j-graphql-js package. I will have to debug some more to find the issue.