-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Auto-generate GraphQL comments in SDL to support a self-documenting API #5824
Auto-generate GraphQL comments in SDL to support a self-documenting API #5824
Conversation
✅ Deploy Preview for redwoodjs-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Nice work, I fully describe my prisma models with model Game {
/// The underlaying ID
id String @id @unique
/// The pretty url reference for the game
slug String @unique
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
/// The pretty name for the game
displayName String
/// What the current SHA for the JS/files looks like
assetsSha String
/// Name of the function we should run
exposedGlobalFunction String @default("runGameWithHost")
... |
Thanks! @orta
Interesting. Turns out Prisma does parse the schema in what it calls the DMMF document and each field has a name, type and .... documentation. For example:
Which I can then use to generate:
So, if there is a comment doc in Prisma, I use that or default. Great idea! |
Have added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly want to default to single-line comments whenever possible to make it less verbose/overwhelming
packages/cli/src/commands/generate/sdl/templates/sdl.js.template
Outdated
Show resolved
Hide resolved
packages/cli/src/commands/generate/sdl/templates/sdl.js.template
Outdated
Show resolved
Hide resolved
Co-authored-by: Tobbe Lundberg <[email protected]>
I don't think you can use any markdown.
It just says that you can use the "block string" which is mark of markdown. I tried and got errors. But I think that is expected.
Done! |
@jtoar I've updated the docs to match the quotation use. Should be good to go. |
Co-authored-by: Tobbe Lundberg <[email protected]>
Co-authored-by: Tobbe Lundberg <[email protected]>
Co-authored-by: Tobbe Lundberg <[email protected]>
Co-authored-by: Tobbe Lundberg <[email protected]>
Co-authored-by: Tobbe Lundberg <[email protected]>
Co-authored-by: Tobbe Lundberg <[email protected]>
Co-authored-by: Tobbe Lundberg <[email protected]>
I've wanted to support comments in SDL to help auto-generate a self-documenting GraphQL api for awhile.
It helps document in both the GraphiQL Playground, but also can be used by Docusaurus plug-ins to generate publishable docs. See: https://github.com/graphql-markdown/graphql-markdown
This PR adds comments to
with default comments and descriptions to help self-document the GraphQL API.
What are comments and descriptions?
See: graphql/graphql-spec#420
This can add comments in GraphiQL for:
For example:
Prisma Comments
Per @orta 's suggestion, the description now defaults to the Prisma documentation comment if present.
For example:
Can default to ...
ToDo
Note:
I did consider added a generator option to include or exclude comment generation, but thought including comments is a better practice.
But, if others think they should be on be default with an option to run off (or vice versa) I can see that, too.