Как и в сообщении, мне нужно иметь возможность искать с 3 возможными сценариями. Мне нужно, чтобы все регистры были прописными, строчными или обычными.
Если это невозможно, есть ли способ вместо этого сделать фильтр без учета регистра?
allMarkdownRemark(filter: { brand: { eq: $normalBrand } }) { //==> Need more here
edges {
node {
webImages {
url
}
}
}
}
Я обнаружил, что некоторые люди делают это:
filter: { OR: [
{brand: { eq: $normalBrand }},
{brand: { eq: $normalBrand2 }},
{brand: { eq: $normalBrand3 }}
]}
Но у меня не работает


В настоящее время нет ничего встроенного в сам graphql, который использует поиск без учета регистра, он полностью основан на любой библиотеке, на которой запущен сервер graphql, и если это решит добавить поддержку для этого. Если вы можете изменить код запроса graphql, вы можете добавить его в себя каким-либо образом или попросить того, кто его размещает / строит, каким-то образом добавить в эту функцию.
Что касается OR, я сомневаюсь, что смогу сказать это лучше, чем https://github.com/graphql/graphql-js/issues/585#issuecomment-262402544
GraphQL doesn't have support for AND/OR operators for exactly the reason you mentioned at the top of your issue: it does not map to any kind of storage. I think to properly understand why it does not have these requires a shift in mental models. We think of GraphQL as more similar to RPC languages than database languages.
To help understand the mental model shift, it's useful to think about fields and arguments like function calls in programming languages. So suppose we ask a similar question of javascript: Why can't you type:
getCaseByStatus("open" OR "closed")? The answer, I would assume, is because JavaScript does not know what OR means in this context. Should the values"open"and"closed"be combined in some way to produce another value? Should the execution of the functiongetCaseByStatuschange in some way? JavaScript can't be sure - because the concept of field-based filtering is not part of JavaScript's semantics. ...
Это не язык запросов, если вы не можете его задать.
Регулярное выражение работает? Что-то вроде
allMarkdownRemark(filter: { brand: {
regex: "/($normalBrand)|($normalBrand2)|($normalBrand3)/"
} }) {
edges {
node {
webImages {
url
}
}
}
}
Попробуйте сделать фильтр с нижним регистром 'или'
фильтр: {или: [{марка: {eq: $ normalBrand}}, {марка: {eq: $ normalBrand2}}, {марка: {eq: $ normalBrand3}}]}
Это может быть актуально: github.com/graphql-compose/graphql-compose-mongoose/issues/9 3