graphql-spec icon indicating copy to clipboard operation
graphql-spec copied to clipboard

Add descriptions to executable definitions

Open IvanGoncharov opened this issue 4 years ago • 4 comments

Was already discussed during WG: https://github.com/graphql/graphql-wg/blob/main/notes/2021-04-01.md#adding-descriptions-to-queries-and-fragments-ivan

I prepare a format proposal, here is a couple of key points:

  1. You can add descriptions on operations, fragments, and query variables
  2. You can't add description on the short form of operation only full form.

Example:

"Some description"
query SomeOperation(
  "ID you should provide"
  $id: String
  
  "Switch for experiment ...."
  $enableBaz: Boolean = false,
) {
  foo(id: $id) {
    bar
    baz @include(if: $enableBaz) {
      ...BazInfo
    }
  }
}

"Some description here"
fragment BazInfo on Baz {
  # ...
}

IvanGoncharov avatar Oct 07 '21 16:10 IvanGoncharov

✔️ Deploy Preview for graphql-spec-draft ready!

🔨 Explore the source changes: 14cce6147cc1621dfa9c532ab979168c50a05bea

🔍 Inspect the deploy log: https://app.netlify.com/sites/graphql-spec-draft/deploys/615f262e5946770008f041ee

😎 Browse the preview: https://deploy-preview-892--graphql-spec-draft.netlify.app/draft

netlify[bot] avatar Oct 07 '21 16:10 netlify[bot]

It's an incomplete PR at the moment:

  • [ ] Need to expand "Descriptions" in Section 2
  • [ ] Need to figure out what to do with duplicating "Descriptions" in Section 3

IvanGoncharov avatar Oct 07 '21 16:10 IvanGoncharov

Capturing feedback from WG (suggested by @fotoetienne): Add a note that descriptions on executable definitions or comments (retroactive change) must not change execution, validation, or response of graphql document. And it is safe to remove comments and descriptions from executable documents.

IvanGoncharov avatar Oct 07 '21 20:10 IvanGoncharov

Implemented in https://github.com/graphql/graphql-js/pull/3402

IvanGoncharov avatar Dec 03 '21 21:12 IvanGoncharov