Skip to content

Conversation

toy0605
Copy link

@toy0605 toy0605 commented Sep 19, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #3687

What is the new behavior?

Code First

Code

// New `isOneOf` property
@InputType({ isOneOf: true })
export class UserByInput {
  @Field(type => ID)
  id: string;

  @Field(type => String)
  email: string;

  @Field(type => String)
  username: string;
}

@Resolver(of => User)
export class UserResolver {
  @Query(type => User)
  user(@Args("by") by: UserByInput) {
    // ...
  }
}

Result (Auto Generated GraphQL Schema)

input UserByInput @oneOf {
  id: ID
  email: String
  username: String
}

type Query {
  user(by: UserByInput!): User
}

Schema First

GraphQL Schema

input UserByInput @oneOf {
  id: ID
  email: String
  username: String
}

type Query {
  user(by: UserByInput!): User
}

Code (Auto Generated Type)

export class UserByInput {
  id: string;
  email: string;
  username: string;
}

// ...

export abstract class IQuery {
    abstract user(by: UserByInput): Nullable<User> | Promise<Nullable<User>>;
}

type Nullable<T> = T | null;

Resolver

@Resolver("User")
export class UserResolver {
  @Query()
  user(@Args("by") by: UserByInput) {
    // ...
  }
}

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

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

Successfully merging this pull request may close these issues.

1 participant