Title: [Spring Graphql] Knowing which fields are requested by a query/subscription? · graphql-java/graphql-java · Discussion #3444 · GitHub
Open Graph Title: [Spring Graphql] Knowing which fields are requested by a query/subscription? · graphql-java/graphql-java · Discussion #3444
X Title: [Spring Graphql] Knowing which fields are requested by a query/subscription? · graphql-java/graphql-java · Discussion #3444
Description: [Spring Graphql] Knowing which fields are requested by a query/subscription?
Open Graph Description: I'm trying to make a GraphQL interface on top of the data coming from a very slow physical device (I have both a solar converter and a heatpump that both only speak modbus). The root problem I have...
X Description: I'm trying to make a GraphQL interface on top of the data coming from a very slow physical device (I have both a solar converter and a heatpump that both only speak modbus). The root problem I ...
Opengraph URL: https://github.com/graphql-java/graphql-java/discussions/3444
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"[Spring Graphql] Knowing which fields are requested by a query/subscription?","text":"I'm trying to make a GraphQL interface on top of the data coming from a very slow physical device (I have both a solar converter and a heatpump that both only speak modbus).
\nThe root problem I have is that these devices have many fields available (my solarconverter has a few hundred fields) and there is a limit on modbus of a maximum of only 125 fields per call. On some of my devices such a call sometimes takes almost a second.
\nTo allow getting the data as often as possible I want to only fetch the fields from the real device for which there is an actual need in either a query or subscription.
\nIn a related project (not modbus, so I get the full record in all cases) I have used the Spring Graphql library and used a QueryMapping and a SubscriptionMapping to implement the query and subscription.
\nThis works fine but I do not see a way to get the data I think I need.
\nFor the modbus case I see a need to have
\n\n- A way to know which fields are requested in both the query and subscription scenarios.
\n- Have hooks/handlers for starting and stopping the subscription that can register/unregister the need for the queried fields towards the (slow) backend.
\n
\nThe only example code I have found so far that does something like this was this ~7 year old StockTickerWebSocket example.
\nThis does however use something completely different than Spring-graphql.
\nWhat I'm looking for a some guidance going into the right direction.
\n\n- Can what I need be done with spring-graphql?
\n- If it cannot be done with spring-graphql (yet) then is the example I found still the best way forward?
\n- If this is not the best way; what is?
\n
\nIn all of the above: Any example/javadoc/code link that points me towards how to do this is highly appreciated.
\nThanks.
","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"The bottom of this article is about you need I believe. I tried it a few weeks ago in a Spring 3 app and the context includes the fields got queried.
","upvoteCount":1,"url":"https://github.com/graphql-java/graphql-java/discussions/3444#discussioncomment-8476584"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:6759d702-7c95-de61-332b-23c811a11a67 |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | A358:2D650D:C2E0E4:1146219:696FBB70 |
| html-safe-nonce | 4f2172526965ddaf526b251ce380fd9eea3febdfe7a3ab045b5193003f5e3116 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzU4OjJENjUwRDpDMkUwRTQ6MTE0NjIxOTo2OTZGQkI3MCIsInZpc2l0b3JfaWQiOiI2NDU2NDU2NjU4MDI3NTI3MDI0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ad65e4832c92847f604a631ea31bec01ae1976db379d615d8d105cc59578f8c4 |
| hovercard-subject-tag | discussion:6206190 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/graphql-java/graphql-java/3444/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/3dca758682df82a85121976159d919d92601c26a4359003c848e894862266a6a/graphql-java/graphql-java/discussions/3444 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3dca758682df82a85121976159d919d92601c26a4359003c848e894862266a6a/graphql-java/graphql-java/discussions/3444 |
| og:image:alt | I'm trying to make a GraphQL interface on top of the data coming from a very slow physical device (I have both a solar converter and a heatpump that both only speak modbus). The root problem I have... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 40ce4030a7db32193be29054756ed7f7eceec3a82973f060300035bdff8cf777 |
| turbo-cache-control | no-preview |
| go-import | github.com/graphql-java/graphql-java git https://github.com/graphql-java/graphql-java.git |
| octolytics-dimension-user_id | 14289921 |
| octolytics-dimension-user_login | graphql-java |
| octolytics-dimension-repository_id | 38602457 |
| octolytics-dimension-repository_nwo | graphql-java/graphql-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 38602457 |
| octolytics-dimension-repository_network_root_nwo | graphql-java/graphql-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1cdcabe0d7ddc4be91a713d57280849e4c89f5cd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width