Search code examples
jupyter-notebookgraphqlblaze

Translation from blaze query to GraphQL query


I have a data consumer which is a Jupyter Notebook. Is there any way to translate queries written in blaze to graphQL queries?

for example in blaze we have:

accounts[accounts.balance < 0].name

and in GraphQL we might have this:

{
accounts(balance<0)
{
name
}
}

Solution

  • GraphQL doesn't expose any built-in filtering capability. It can be implemented manually in form of the parameters. So depending on your needs you may define query field like:

    type Query {
        accounts(balanceBelow: Int!): [Account!]
    }
    

    or:

    type Constraint {
        fieldName: String!
        operator: OperatorEnum!
        value: String!
    }
    type Query {
        accounts(where: Constraint): [Account!]
    }
    

    or something in between. But if things like custom query filtering and aggregations are common in your domain, you may find GraphQL cumbersome choice to work with.