Solved

How to provide filter parameters to allCards API query

  • 13 February 2022
  • 7 replies
  • 816 views

Userlevel 3

Hi,

I am trying to understand how to provide parameters to the allCards query.  It seems there is no place where simple example queries are shown, so its becoming difficult to understand how to construct API queries.

Right now I am experimenting with basic queries and trying them with GraphiQL. With the below query I try to filter cards and retrieve all cards where a certain field has a value equal to a certain value, Eduardo in this example. The below query returns errors, it seems it is expecting a string. The error does not resolve if I enclose the field name and/or value between “”. 

The query below does retrieve values if the 4th line is completely removed (i.e. the line with the filter).

How are this filters constructed? What is the basic grammar? What am I missing? Thanks!

 

errors": [{
      "message": "Argument 'field' on InputObject 'AdvancedSearch' has an invalid value (field_24_string). Expected type 'String'.",

The allCards query 

{  
# searching cards based on limited parameters: you cant limit by phase!
allCards (pipeId: 11111,
filter: {field: field_24_string value:Eduardo}
)

{
edges {

node { id
url
createdAt
updated_at
current_phase {
id
name
}
title
fields{
indexName
name
value
}
}
}
pageInfo{ startCursor endCursor
hasNextPage hasPreviousPage }

}}

 

icon

Best answer by genietim 14 February 2022, 07:38

View original

7 replies

Userlevel 7
Badge +12

In my view and understanding of the documentation, the correct filter would look something like this:

 

filter: {
field: "my_field_id",
value: "the value I search for"
}

 

But, as I see, that does not seem to be working.

Userlevel 3

Thanks @genietim for your reply. I have kept experimenting and found that your grammar is correct and does provide a result...as long as you only try to filter by THIS field! 

  allCards (pipeId: 1111, 
filter: {field: "updated_at", operator: gt, value: "2021-12-18T00:00:00-02:00"}
)

It seems the AdvancedSearch filter in allCards is in reality a SimpleSearch(ByJustACoupleOfFields)…. So far it does only work IF the fields used to filter are updated_at and due_date. No other field can be used to filter the cards. See the below post. The documentation does not mention this limitation, which makes it more challenging for users to find it. 

 

See this other post

Userlevel 7
Badge +12

Btw., if you actually want to search other fields by values, use the query `findCards`:

 

query {
findCards(pipeId: <yourPipeId>, search: {
fieldId: "<theFieldId>",
fieldValue: "<theFieldValue>"
}, first: 10) {
edges {
node {
id
suid
}
}
}
}

 

(yes, the inconsistent case and name (“field_id”, “fieldId”, “field) is bugging me a bit too)

Userlevel 3

Btw., if you actually want to search other fields by values, use the query `findCards`:

 

 

But note here that perhaps this findCards query only works with custom fields. I’m trying to filter by created_at / createdAt but the API response tells me that “Field not found with id: createdAt”

Using updated_at doesn’t work either, only at the allCards query.

 

I find it funny that we can filter by custom fields but not by a built-in field.

Userlevel 3
Badge

Olá, ainda nao existe o suporte para que consigamos buscar todos os cards em um pipe usando um filtro da data de criaçao? 

Exemplo, precisamos de uma consulta que nos retorne todos os cards que foram criados nos últimos 30 dias

you'll typically need to include these parameters in the request URL. The exact method may vary depending on the API's documentation and specifications, but here's a general example of how you might structure the request:

GET /api/allCards?parameter1=value1&parameter2=value2

In this example:

  • /api/allCards is the endpoint for the "allCards" query.
  • parameter1 and parameter2 are placeholders for the specific filter parameters you want to apply.
  • value1 and value2 are the values you want to filter the results by.

For example, if you want to filter cards by their rarity and color, your request might look something like this:

GET /api/allCards?rarity=common&color=blue

Make sure to consult the API documentation for the "allCards" endpoint to understand the available filter parameters and their accepted values. Additionally, be mindful of any authentication requirements or rate limits that the API may have.

e.g: bitlife god mode apk

 

 

Userlevel 7
Badge +9

Hi @produtos7!

Did everything go well?

@AmandaJoy thank you for your help!😀

Reply