Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Querying workflow instances by variables #16

Open
asaf opened this issue Mar 28, 2020 · 11 comments
Open

Querying workflow instances by variables #16

asaf opened this issue Mar 28, 2020 · 11 comments
Labels
enhancement New feature or request scope-graphql Related to the GraphQL API

Comments

@asaf
Copy link

asaf commented Mar 28, 2020

Support querying workflow instances by specific variables names & values.

@saig0
Copy link
Contributor

saig0 commented Mar 30, 2020

Sounds interesting 👍

Do you have an idea of how the GraphQL query/schema should look like?

@asaf
Copy link
Author

asaf commented Apr 1, 2020

it's a bit challenging with GraphQL as it requires static definitions of the args,
the easiest way would be to find some filter string that can be easily converted to JPA query or just provide extra sql clause (need to be careful with injections though)

maybe we can do something in the form of:

{
    variables(filter: "foo == \"bar\" and bar != null") {
      name
      value
    }
}

@saig0
Copy link
Contributor

saig0 commented Apr 1, 2020

A query string sounds like a simple way. But passing a SQL/JPA query as filter argument feels not right 😅

What do you think about something like the following?

{
  variable(filter: { name: "foo", value_eq: "bar"}) {
    name
    value
  }
}

So, the workflow instances would be collected by the variables.

{
  variable(filter: { name: "foo", value_eq: "bar"}) {
    name
    value

    scope {
      workflowInstance {
        key
      }
    }
  }
}

Does this work for you?

@asaf
Copy link
Author

asaf commented Apr 3, 2020

@saig0 i think that this syntax restricts a single filter condition, i would make filter an array if possible for multi conditions

@saig0
Copy link
Contributor

saig0 commented Apr 7, 2020

Ok. Let's try to make it as simple as possible (because filtering can get complicated 😅).

Which queries do you need exactly?

@asaf
Copy link
Author

asaf commented May 5, 2020

@saig0 i don't have specific demands atm, it was more a suggestion for your project :)

@saig0 saig0 added enhancement New feature or request scope-graphql Related to the GraphQL API hacktoberfest labels Sep 2, 2020
@saig0
Copy link
Contributor

saig0 commented Sep 2, 2020

We can give it a try and see how it works out. We should start with a filter for variables first that allow filtering by a variable name and a value. The value must match exactly to make it easy.

@aanodin
Copy link

aanodin commented Jan 25, 2023

@saig0 @asaf any updates on this? We are looking for that feature too.
To be more specific, we have an order management system that creates many workflow instances, one instance for one order.
Lets say we have a variable "order" in each our process instance:

{
  "customer": {
    "msisdn": "123456789",
    "name": "John"
  },
  "items": [
	{
		"name": "some product 1",
                "quantity": 1
	},
	{
		"name": "some product 2",
                "quantity": 2
	}	
  ]
}

Now we want to find all processes created by the same customer. At this point we can't know how exact json of each order looks. What we need to do is to find them all using a filter like "order.customer.msisdn": "123456789".

There is an example of how such GraphQL model can be implemented: https://chillicream.com/docs/hotchocolate/v12/integrations/mongodb#filtering
This is how HotChocolate (GraphQL implementation for .NET) interacts with MongoDB databases, transforming GraphQL queries into native MongoDB ones.

query GetPersons {
  persons(
    where: {
      name: { eq: "Yorker Shorton" }
      addresses: { some: { street: { eq: "04 Leroy Trail" } } }
    }
  ) {
    name
    addresses {
      street
      city
    }
  }
}

@saig0
Copy link
Contributor

saig0 commented Jan 26, 2023

@aanodin no updates so far. Currently, I don't need this feature at the moment. So, I don't plan to implement something like this soon.

Your request is also more complicated than the initial one. Instead of finding a variable based on a concrete value, you want to find a variable (i.e. the process instance) based on a partial JSON value.

I'm not sure how we could implement this query based on JPA. ZeeQS is not bound to a specific database. Maybe, QueryDSL could help here, but not sure how far.

@shahamit
Copy link

We hit through this use case too. I am new to graphql a bit. @saig0 - could you please elaborate what would it mean to support such kind of filter queries in zeeqs? What kind of code changes are required?

@saig0 saig0 self-assigned this May 15, 2023
@saig0
Copy link
Contributor

saig0 commented May 16, 2023

@shahamit you can have a look at the following examples:

From the code perspective, you would need to:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request scope-graphql Related to the GraphQL API
Projects
None yet
Development

No branches or pull requests

4 participants