-
Notifications
You must be signed in to change notification settings - Fork 31
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
[Story] GraphQL Fetcher
s should only populate response as-needed
#994
Comments
In #924 I separated the retrieving of active and archived recordings using this method so that the Archives view could populate its archived recordings count data without needing to open a target JMX connection:
I left the nullability of the involved data types as is, and retrieving just the active recordings or just the archived recordings works without any issues, despite both the
So this should be a simpler change than expected. |
So it seems the The remaining In light of this, I don't think we need to populate responses as needed for any other |
I agree, I think the only currently existing case for it is the |
In that case, I believe the |
Yep, looks good. Closed by #924 |
For example: https://github.com/cryostatio/cryostat/blob/2b052d65717f71c2f00c43b3539c5edbc2133ed7/src/main/java/io/cryostat/net/web/http/api/v2/graph/RecordingsFetcher.java#L110
When performing a query for only archived recordings, for example, this implementation unconditionally populates both the
active
andarchived
fields of therecordings
object. This means that the GraphQL resolver ends up opening a JMX connection and querying for active recordings, potentially across very many different targets across the network, when all that is actually needed to be done is to list the contents of the archived directories in local filesystem.This is a common pattern in GraphQL so there are well-known techniques to solve it: https://stackoverflow.com/questions/65935113/getting-requested-fields-on-resolver-level-from-graphql
In this particular example, the
RecordingsFetcher
should check the requested fields from theDataFetchingEnvironment
and only populate them as needed. If the API client has only requested information about archived recordings, theactive
side of theRecordings
structure should be left unpopulated (null
or just empty list? In types.graphqls this is defined as non-null) and no target JMX connections opened.This is a
[Story]
because the nullability of various GraphQL response types should be re-evaluated, and there are a lot of GraphQL implementation points that should be reviewed as well to ensure that response computations only occur if it's part of the client's requested fields.The text was updated successfully, but these errors were encountered: