-
Notifications
You must be signed in to change notification settings - Fork 7
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
Parse -api graphql schema and determine what is available #151
Comments
Currently, when the root component is mounted, all defined apis are iterated through and a graphql client created for each defined api by calling CoreApi.createClient(). In createClient(), it stores the client state in vuex:
The 'state' is set to Periodically (once per second), the root component (src/App.vue) fires a timer which scans each client and if it hasn't been seen active within the last ten seconds it marks the 'state' as false again. Then, a component will add GraphQL queries/subscription that it needs, by calling something like: This is quite effective, but limited. It assumes that if it receives a We assume that the There are two methods to work round this problem:
|
Naively, can we replace Assuming we fetch the schema from The status message can contain a schema hightide timestamp. If the timestamp is greater than the one stored in the api metadata:
The next time the query is executed |
What you're describing will work, but it's awfully complicated and requires multiple pulls/parses of the remote schema. Isn't it just easier to add a schema/modules field to the Status message that keeps an up to date list of what is available? This will be automatically updated through the Status message subscription in the client, with 1/100th of the code and effort, and will be more immediate and faster without the remote schema pull/parsing. I get the schema parse is more 'correct', but technically -api should be able to reliably set in Message.schema what is in the schema anyway? |
I think it will be much more fragile consuming API data via graphql as you propose (rather than using the published schema). The code to pull and verify the schema is already in place in -web where as I would need to write python code to grab all the graphql info and then a graphql message(s) to discribe the queries. We would then need to somehow match the -web graphql queries against the details published by -api via naming or similar. IMO it has its own set of implementation issues while being less robust. |
If you are agreeable to let me do the leg work on this issue I'll happily go down the python route if / when the JavaScript route fails spectacularly. |
Sure, your ideas usually work out better than mine anyway!! |
verifyQuery() needs the gql document which isn't always available. For example in plugins/core/CoreApi.js there is a watcher set that fires whenever the window is not visible, to turn off all the gql queries. When it becomes visible again, it turns them all on. However this now turns on all the 'skipped' queries that verifyQuery was used to disable. There's no way to verify all the queries in all the components because we don't know what gql documents were used to create them. |
If verifyQuery() gets a schema which isn't complete or correct (eg. incomplete schema happens during component bootstrap, sometimes is still present during mounted()), then the validation fails and produces errors. I've trapped the errors but it returns incorrectly and causes failure. |
The Re the incomplete schema during component bootstrap, can we move the schema request to the start of the client creation and run the client creation in an async call (at the same time) as the schema request. Then at the end of the client creation we await the schema call to return (if it hasn't already). This way we know for sure when the modules find the client instance the validation code is ready to go? |
re
See 91c8846 |
It's all getting a bit complicated.. I've been trying to keep the graphql setup as simple as possible, with as little code as possible, because the setup is very delicate. What about leaving the schema fetch and any validation requests until after the api has been marked good? When a client is created, a connection is made straight away. It then creates a Status query/subscription for that api, and when it gets a successful Status message back from -api, it marks |
Wont the Status query/subscription for that api fail without validation? or are we not validating that?Either way we have to wait for the schema before we can attach any more queries... |
Yeah currently we just assume that the Status query is available - I think that's a reasonable assumption, a reasonable basic dependency that -api provides Status at all times. |
When an api is defined and thus a new graphql client created, download the schema, parse and work out what is available and what is not.
The text was updated successfully, but these errors were encountered: