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

[#1405] Feature/query filter #1610

Merged
merged 4 commits into from
Jan 2, 2024

Conversation

kanchan-dhamane
Copy link
Contributor

Description of the PR

Fixes - #1405

Adds a custom GraphQL directive to filter results using two options contains and startswith
example-

query ArtifactsQ1 {
  artifacts(artifactSpec: {}) @filter(keyName: "digest", operation: STARTSWITH, value: "322") {
    algorithm
    digest
  }
}

Copy link
Collaborator

@pxp928 pxp928 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @kanchan-dhamane! This is great stuff!

Copy link
Collaborator

@mihaimaruseac mihaimaruseac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really great. Thank you!

internal/testing/e2e/expectArtifactsQ1.json Outdated Show resolved Hide resolved
@kanchan-dhamane
Copy link
Contributor Author

kanchan-dhamane commented Dec 31, 2023

Thanks @pxp928 and @mihaimaruseac for reviewing the PR. This PR doesn't handle the filter on nested keys. filter on keyName subject.id won't work in the below query. If this is a valid use case, I can look into it.

query GetAllSLSA {
  HasSLSA (hasSLSASpec: {}) @filter(keyName: "subject.id", operation: CONTAINS, value: "710") {
  id
 subject {
    id
    algorithm
    digest
  }
  }
}

@pxp928
Copy link
Collaborator

pxp928 commented Dec 31, 2023

Thanks @pxp928 and @mihaimaruseac for reviewing the PR. This PR doesn't handle the filter on nested keys. filter on keyName subject.id won't work in the below query. If this is a valid use case, I can look into it.


query GetAllSLSA {

  HasSLSA (hasSLSASpec: {}) @filter(keyName: "subject.id", operation: CONTAINS, value: "710") {

  id

 subject {

    id

    algorithm

    digest

  }

  }

}

Hey @kanchan-dhamane! Yes that would be a valid usecase. We can do that in another PR if that is easier.

@mihaimaruseac
Copy link
Collaborator

+1 to doing it in a separate PR

@pxp928
Copy link
Collaborator

pxp928 commented Jan 2, 2024

@kanchan-dhamane just need to sign your commits and this will auto-merge.

@kanchan-dhamane kanchan-dhamane force-pushed the feature/query-filter branch 2 times, most recently from 294cf29 to d4e64f0 Compare January 2, 2024 13:49
Kanchan Dhamane and others added 4 commits January 2, 2024 19:19
@kanchan-dhamane
Copy link
Contributor Author

I've signed the previous commits. Thanks @pxp928!

@kodiakhq kodiakhq bot merged commit dbb2ffb into guacsec:main Jan 2, 2024
8 checks passed
@pxp928
Copy link
Collaborator

pxp928 commented Jan 2, 2024

Thanks @pxp928 and @mihaimaruseac for reviewing the PR. This PR doesn't handle the filter on nested keys. filter on keyName subject.id won't work in the below query. If this is a valid use case, I can look into it.


query GetAllSLSA {

  HasSLSA (hasSLSASpec: {}) @filter(keyName: "subject.id", operation: CONTAINS, value: "710") {

  id

 subject {

    id

    algorithm

    digest

  }

  }

}

Hey @kanchan-dhamane! Yes that would be a valid usecase. We can do that in another PR if that is easier.

created issue to capture this: #1615

m-brophy pushed a commit to trustification/guac that referenced this pull request Feb 8, 2024
* query filter initial commit

Signed-off-by: Kanchan Dhamane <[email protected]>

* query filter - removes the comment from the directive resolver file

Signed-off-by: Kanchan Dhamane <[email protected]>

* chore[query-filter] - adds the new line at the end of e2e file and updates expectArtifactsQ1.json file

Signed-off-by: Kanchan Dhamane <[email protected]>

* chore[query-filter] - updates the e2e file

Signed-off-by: Kanchan Dhamane <[email protected]>

---------

Signed-off-by: Kanchan Dhamane <[email protected]>
Co-authored-by: Kanchan Dhamane <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants