Replies: 1 comment 6 replies
-
Presently there isn't a way to provide an array such as that for the filter, but you could achieve it slightly differently by using the query filterItems {
items(filter: { or: [{ userPhoneNumber: { eq: "0000" } } { userPhoneNumber: { eq: "1111" } }]) {
item {
partitionKey
userPhoneNumber
userDisplayName
}
}
} (The filter is written from memory, it should be something close to that if I didn't get it right) Since you probably have a dynamically sizes list of phone numbers, you're best building the filter in code and passing it as a variable. I'll just JS as an example: const phoneNumbers = [ /* some phone numbers */ ];
const filters = phoneNumbers.map(phoneNumber => ({ userPhoneNumber: { eq: phoneNumber } }));
const filter = { or: filters };
const query = `
query filterItems ($filter: itemsQueryFilter!) {
items(filter: $filter) {
items {
partitionKey
...
}
}
}
`;
const results = await execGraphQLQuery(query, { variables: { filter } }); This is a little pseudocode esq, but hopefully you can see the intent. |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am not sure if this would be possible using the data-api-builder as of now. I want to retrieve data from the database by sending a list as an argument, an example of a such a list would be
["4161231234","7202228799"]
.I have a query like below which works, now I want to send the above array to the query and retrieve data that contains each of the item on the array.
An example of such a query on Postgres is -
SELECT user_id FROM users WHERE user_id LIKE ANY(contacts);
In the above statement the contacts will have the list of phone numbers.
Beta Was this translation helpful? Give feedback.
All reactions