Skip to content

Conversation

MetRonnie
Copy link
Member

Check List

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Tests, changelog, docs not needed

@MetRonnie MetRonnie self-assigned this Jul 14, 2025
Copy link
Contributor

@ChrisPaulBennett ChrisPaulBennett 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 not sure I am the correct person to review this.
I'm not sure what the introspection query is for, or how I would even test it. Can you give me a little bit more info on this update

The AOTF changes seem fine. I assume that is how you type check in javascript? ugh....I see why type script is a thing.

@MetRonnie
Copy link
Member Author

The introspection query is a GraphQL query that the UI client makes on first load in order to determine the full GraphQL schema of the server, including the GraphQL types. The UI does this here:

this.introspection = this.loadTypes()

/**
* Load mutations, queries and types from GraphQL introspection.
*
* @returns {Promise<IntrospectionObj>}
*/
async loadTypes () {
// TODO: this assumes all workflows use the same schema which is and
// isn't necessarily true, not quite sure, come back to this later.
let response
try {
response = await this.apolloClient.query({
query: getIntrospectionQuery(),
fetchPolicy: 'no-cache'
})
} catch (err) {
console.error(err)
// eslint-disable-next-line no-console
console.log('retrying introspection query')
await new Promise(resolve => setTimeout(resolve, 2000))
return this.loadTypes()
}
const mutations = response.data.__schema.mutationType.fields
const queries = response.data.__schema.queryType.fields
const { types } = response.data.__schema
mutations.push(...dummyMutations)
processMutations(mutations, types)
return { mutations, queries, types }
}

This is used to populate the command menu when you click on a task icon, as well as all the fields in the form that comes up when you click the pencil/edit button on the menu.

The "mock" introspection query response is used to provide this in the "offline"/"mock" mode, which is when you run yarn run serve or its alias yarn run dev. There is some more info here:

# Mock data for Cylc UI
The files in this directory include:
- `*.json` these a [json-server](https://github.com/typicode/json-server) database
files. For each of these, when exported, you should have an entry in the `/db`
endpoint.
- `index.cjs` this is a JS module that exports the imported JSON files. The names
used in the export section drive the value that appears in the `json-server`
endpoints (see `/db` to inspect what values are available).
## Introspection query
The following query is a combination of the request generated by
GraphiQL, combined with extra information for the `mutationType`
(instead of just `name`, we ask for `...FullType`).
```graphql
query IntrospectionQuery {
__schema {

For this PR I ran the full query from the README file on the Cylc 8.5.0 uiserver and overwrote the JSON file with the results. This brings the offline mode up to date.

If you feel the developer docs could do with more info anywhere, do shout 👍

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

Successfully merging this pull request may close these issues.

2 participants