-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add metadata for Vector's API #3872
Comments
To add some context to this, GraphQL APIs are 'self-documenting' -- the schema is fully typed, providing known inputs/outputs for every query type. This can be augmented with doc comments that become part of the public API. By default, this schema is available to all GraphQL clients, that can fire off an introspection query to get at it. Incidentally, this is what we do in both vector-ui and as of #3778, in Vector too. Types/clients are generated entirely off the back of schema introspection. For Vector users, this is accessible in a more friendly way via the playground that will (by default) run on http://localhost:8686/playground, and shows up in a sidebar like this: No doubt we'll want to extract that documentation, and make it navigatable as part of public Vector docs, so this can be acknowledged by prospective users even before firing up Vector. There's likely some tooling to make the schema easier to navigate. There's also the option of setting up a sandboxed environment with dummy data, and providing a hosted version of the playground, similar to Github's own -- that'd be a neat, low-friction way to assess the power of direct Vector observability. We could also implement a build step / CLI command for updating the docs based on the current live schema. A few different ways we could go with this. It being a typed schema should aid it, in any case. |
@binarylogic - could you clarify kind of metadata you're wanting here please? I'll move this to the backlog for now. Feel free to move it back into the sprint if this is something that needs addressing soon. |
Anything required for the reference docs. Such as queries, mutations, and so on. If we would prefer to lean on the explorer, then we can defer to that. I still think there is value in having explicit reference docs we can link to though. |
I think there's three ways we could go: Static docsThere are a few generators listed at https://nordicapis.com/graphql-documentation-generators-explorers-and-tools/ we could leverage, depending on what we like the look of. An example is graphdoc, which would wind up looking something like this. Pros:
Cons:
Live playgroundWe could host a real Vector instance + GraphQL Playground, which would include the introspected docs, have sample queries that could be executed, and responses coming back from the server. The same experience as using http://localhost:8686/playground on a locally running Vector instance, but with our own curated dummy data. Pros:
Cons:
Regular docs, automated with 'try this query'A hybrid approach: Regular content hosted in our own UI, with some concept of 'execute this query, live' -- a button, or other action that allows results to be seen in-view, or via an external playground. Github does this: https://developer.github.com/v4/guides/using-the-explorer/ (In GH's case, they send the user to a GraphQL Playground.) Since we control the UI, one option would be to embed a GraphQL client directly in it, so results could be shown in a design layout that we can control. Pros:
Cons:
CC'ing @sghall - he might have some thoughts on the above. |
A separate docs site just for the GraphQL API is a non-starter. If we go that route I would rather figure out a way to add that data to our Cue files and use the docs site we already have. Is there any reason we couldn't do that? I don't know that we need a hosted eplorer just yet. |
Worth @sghall weighing in. I don't have much context with either cue, or how the current docs are generated. One of GraphQL's touted features is self-documentation; hopefully we can avoid maintaining separate cue files.
|
Right, but you'll need to get context and help with documentation. It's why we assigned you #4368 and #4347. The bottom line is:
|
Part of it is definitely just not being familiar with cue syntax, but I think the bigger part is knowing what we want from the experience. Many GraphQL APIs are interactive and tied to a playground. If I went ahead and built a static cue-based reference and then we realise we want some way to interact with the GraphQL API, it could all be for nought. There's also apparently zero references of anyone that I could find from a superficial search, mapping GraphQL schema -> cue. What I did find were a couple of issues that seemed to suggest cue changes to accommodate a more GraphQL-like schema: cuelang/cue#339, cuelang/cue#69. Again, I don't have a ton of context at this stage, so I will look more specifically at cue jumping to any conclusions. But I thought it was worth prompting what we're hoping to get out of documentation first to get some idea of a starting point. Knowing we don't want a playground or a way to execute live queries is good background to have. |
@binarylogic @leebenson If we have the resources to create GraphQL doc templates and generate the reference docs within our current setup, that's the way to go. I do think, however, that it'd be best to use If we don't have the resources to create our own GraphQL doc templates, then we can add a docs build step that uses one of the many generators to build the HTML under vector.dev and not in a separate site per se. The look and feel would be separate—although I think that some customization may be possible—but it's worth bearing in mind that many docs portals do have separate, non-integrated REST/GraphQL docs, so that may not be too discordant with reader expectations. |
Agreed. This is what struck me as odd. We already have a full But I don't know enough about cue to conclude that. There may well have been an existing gql -> cue generator, but I can't see anything obvious.
Agreed. FWIW @binarylogic, I wasn't advocating for external docs. Just pointing out the existing generators. I also think @sghall might want to chime in with some thoughts, since he's worked extensively on both the docs and GraphQL in the front-end in general, and may have some ideas for how we can leverage the existing toolchain to make for a better UX. It's very possible to build something in-house and make it interactive, even if we don't opt for a generator. |
We should add metadata for Vector's new GraphQL API. This will allow us to generate docs and include it in our reference documentation.
The text was updated successfully, but these errors were encountered: