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

Proof of concept: Allow selecting of slices of assay meta in graphql #827

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

dancoates
Copy link
Contributor

@dancoates dancoates commented Jun 17, 2024

demo query:

query MyQuery {
  project(name: "greek-myth") {
    samples {
      id
      assays {
        id
        type
        coverage: metaValue(path: "$.coverage")
        facility: metaValue(path: "$.facility")
        emoji: metaValue(path: "$.emoji")
      }
    }
  }
}

meta_slice_keys = (
','.join(
[
f'JSON_VALUE(a.meta, \'{m["path"]}\') as _meta_{m["alias"]}'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

definitely a sql injection issue here, would need fixing if we want to do this for real

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should also use JSON_EXTRACT rather than JSON_VALUE

async def metaValue(
self, info: Info, root: 'GraphQLAssay', path: str
) -> strawberry.scalars.JSON:
alias = info.selected_fields[0].alias
Copy link
Contributor Author

Choose a reason for hiding this comment

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

would also need to handle un-aliased fields here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant