question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Directive-driven documentation and metadata?

See original GitHub issue

Hello! I just tried spectaql for the first time, and it successfully generated nice-looking (but bare bones) documentation for my rather large API (5288 lines of SDL)!

My GraphQL service is entirely SDL-first, with C/U/D mutations, SQL schema, and most Typescript resolver code generated based on directive-annotated SDL, so it contains many directives that declare semantics, validation, etc. Therefore, Iā€™m wondering whether you have considered or have recommendations on how one might supply metadata (such as undocumented) or generate documentation snippets (e.g. ā€œThis field is read-only and has a maximum length of 40 characters.ā€) using directives.

Obviously, there are very few standard directives (such as @deprecated), so most will be project/framework-specific. Therefore, custom code would likely be required to map a given set of directives onto the metadata supported by the documentation formatter. I think the question basically comes down to whether there is or could be a single place to hook up this user-supplied mapping function.

Another possibility would be to have a separate tool generate JSON metadata for spectaql based on SDL directives. That would work for the existing metadata features of examples and documented/undocumented. To support generated descriptions, I think additional metadata would be needed, such as descriptionPrefix and/or descriptionSuffix. Alternatively, the tool could also generate a new SDL file with generated descriptions inserted. This separate tool approach involves fewer or even no changes to spectaql, but likely involves more work to develop and use.

Anyway, just wondering if this is on your radar. If it sounds interesting and you can suggest how/where to support it, Iā€™m happy to create a PR.

For sake of argument, hereā€™s an example type declaration with directives:

type ContactAddress {
  id: ID! @rid # random base-62 ID
  principal: Principal! @immutable
  organization: Organization @immutable
  type: AddressType! @immutable
  address: String! @length(max: 255)
  label: String @length(max: 40)
  visibility: Visibility!
  systemUse: Boolean! @default(value: "false")
  createDate: DateTime! @sqlType(type: "timestamp") @createdAt
  lastVerified: DateTime @sqlType(type: "timestamp") @readonly
  _id: Int! @id @autoinc @undocumented
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

1reaction
newhousecommented, Jul 28, 2022

OK @trevorr @gonzalezzfelipe @stephen-opal @rajington

I have added support for adding metadata in via a @spectaql directive. The usage is pretty straightforward, and reasonably customizable. It is now out in main and in version 1.5.0.

I decided to make the options you pass a more generic LIST of objects that have the following shape: { key: String!, value: String! }. This will allow for a bit more flexibility, IMO, even though it requires a bit more verbosity/verboseness to write.

Please see https://github.com/anvilco/spectaql#the-spectaql-directive for more information, and let me know how it works for you!

0reactions
gonzalezzfelipecommented, Jul 28, 2022

@gonzalezzfelipe Is it working for you?

Yep, it is working just fine šŸ‘

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation & metadata | Data management - MIT Libraries
Data documentation, also known as metadata, helps you understand your data in detail, and also helps other researchers find, use, and properly cite...
Read more >
Data Documentation and Metadata | Data Cooperative
Data documentation will ensure that your data will be understood and interpreted by any user. It will explain how your data was created,...
Read more >
Working with data: Data Documentation and Metadata
On this page you will find information: methods of documenting your data, metadata, writing a readme file, examples of readme files,Ā ...
Read more >
Documentation & Metadata | Data Management
Metadata is structured information that describes, explains, locates, or otherwise makes it easier to retrieve, use, or manage an information resource.
Read more >
Documentation & Metadata - Research Data Management
Metadata is the information that describes and documents research data. Metadata will make your datasets searchable in an archive orĀ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found