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

10 query available beamlines #13

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

callumforrester
Copy link
Contributor

Fixes #10

Expand configuration query to be able to return multiple configurations. Change name to configurations. Make beamline parameter optional (and rename to beamlineFilter). When a filter is provided, only details for that beamline are returned, otherwise all beamline configurations are returned.

Expose the name of a configuration (which typically matches the name the beamline) in the GraphQL API. Now that we have a query that a list of configurations it is useful to have a field that differentiate between them.

@callumforrester callumforrester force-pushed the 10-query-available-beamlines branch from b7348be to 165b8f8 Compare December 6, 2024 14:41
src/graphql.rs Outdated Show resolved Hide resolved
@callumforrester callumforrester force-pushed the 10-query-available-beamlines branch 4 times, most recently from 9d0fc79 to 05d85ea Compare December 6, 2024 14:57
Copy link
Collaborator

@tpoliaw tpoliaw left a comment

Choose a reason for hiding this comment

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

I'm still not sure of the use case for this beyond curiosity so this may answer itself.

Instead of beamline_filter being a single string that returns a list of one configuration, would the more graphql-ish approach to pass in a list of names and it returns a list of (possibly null) configurations so that mapping from beamline name to configuration is easier. Not passing the filter list would be the same as it currently is. Passing an empty list would be pointless but would return an empty list.

src/graphql.rs Outdated Show resolved Hide resolved
src/graphql.rs Outdated
match beamline_filter {
Some(filter) => {
trace!("Getting configs matching {filter:?}");
let singleton = db.current_configuration(&filter).await?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This currently returns an error if the beamline has no configuration. Given that the query now returns a list, would it make more sense to return an empty list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've done this but I'm on the fence about it. The DB service returns an error if it can't find the beamline because the other queries like to fail when there's no configuration. It now seems a bit inconsistent. This query basically returns an Option and everything else returns a Result.

README.md Outdated Show resolved Hide resolved
Expand configuration query to be able to return multiple configurations.
Change name to configurations. Make beamline parameter optional (and
rename to beamlineFilter). When a filter is provided, only details for
that beamline are returned, otherwise all beamline configurations are
returned.

Also add a test for the multi-configuration DB query and update the
example query in the README.
Expose the name of a configuration (which matches the name of
the beamline) in the GraphQL API. Now that we have a query that returns
a list of configurations it is useful to have a field that can
differentiate between them.
Return an empty vector from the configurations query if a beamlineFilter
is provided but does not match a beamline, previously the API returned
an error in this case.
@tpoliaw
Copy link
Collaborator

tpoliaw commented Jan 28, 2025

Setting this back to a draft for now, some of the tests might still be relevant but most of this change has been moved to #72

@tpoliaw tpoliaw marked this pull request as draft January 28, 2025 11:52
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.

Query which beamlines are available
2 participants