Skip to content
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

✨ functions: support enum argument types #6780

Open
rsteube opened this issue Feb 29, 2024 · 2 comments
Open

✨ functions: support enum argument types #6780

rsteube opened this issue Feb 29, 2024 · 2 comments

Comments

@rsteube
Copy link

rsteube commented Feb 29, 2024

What are you trying to do?

  • Provide a way to define possible argument values of functions (e.g. [male, female] for gender).

Why is this important to you?

shell completion

How are you currently working around this?

No response

@helderco helderco changed the title ✨ functions: argument values ✨ functions: support enum argument types Feb 29, 2024
@helderco

This comment was marked as resolved.

@helderco
Copy link
Contributor

helderco commented May 7, 2024

High level design for the schema required for this:

To support defining new enums via the API it’s similar to ObjectTypeDef, where the fields are just a list of values and their descriptions:

type EnumTypeDef {
  name: String!
  description: String!
  values: [EnumValueTypeDef!]!
}

type EnumValueTypeDef {
  name: String!
  description: String!
}

type TypeDef {
  """
  If kind is ENUM_KIND, the enum-specific type definition.
  If kind is not ENUM_KIND, this will be null.
  """
  asEnum: EnumTypeDef
    
  """
  Returns a TypeDef of kind Enum with the provided name.
  
  Note that an enum's values may be omitted if the intent is only to refer to an enum.
  This is how functions are able to return their own, or any other circular reference.
  """
  withEnum(name: String!, description: String = ""): TypeDef!

  """
  Adds a static value for an Enum TypeDef, failing if the type is not an enum.
  """
  withValue(name: String!, description: String = ""): TypeDef!
}

enum TypeDefKind {
  """
  A GraphQL enum type and its values.
  
  Always paired with an EnumTypeDef.
  """
  ENUM_KIND
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants