Skip to content

Usage decorator (Input/Output/InputOutput) #4486

Open

Description

Clear and concise description of the problem

We have heard from a few places (GraphQL, Azure specs) where it would be useful to explicitly annotate the usage of a data type as being input only, output only, or both. For GraphQL, input and output shapes have different constraints, and so this annotation would allow a graphql validator/emitter to help developers stick to these constraints. For REST APIs, client codegen can be different depending on if a type is input/output/both, and it can be a breaking change to move between these access categories.

There are various options we could land on:

  • Syntax, like in/out/inout modifiers on declaration forms.
  • Decorator in core, either @input/@output/@inputOutput, or @usage(AccessFlag.Input).
  • Language/protocol specific decorators

There may be more options, so let's explore the space and see what makes sense.

Checklist

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

compiler:coreIssues for @typespec/compilerdesign:neededA design request has been raised that needs a proposaltriaged:core

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions