Sometimes the name of your TypeScript construct is not the name you want in your GraphQL schema: you want a more descriptive name, or a different casing style.

To rename a construct, write the name you want right after its @gql* docblock tag.

Example

Here the TypeScript class for our user is called UserModel, but the schema calls the type User:

UserModel.ts
/** @gqlType User */
export class UserModel {
  /** @gqlField */
  name: string;

  constructor(name: string) {
    this.name = name;
  }
}

And here the getGreeting() method is exposed as a field named greeting:

User.ts
/** @gqlType */
export class User {
  name: string;

  constructor(name: string) {
    this.name = name;
  }

  /** @gqlField greeting */
  getGreeting(): string {
    return `Hello, ${this.name}`;
  }
}