Resolvers
Renaming
On this page
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:
/** @gqlType User */
export class UserModel {
/** @gqlField */
name: string;
constructor(name: string) {
this.name = name;
}
}type User {
name: String
}And here the getGreeting() method is exposed as a field named greeting:
/** @gqlType */
export class User {
name: string;
constructor(name: string) {
this.name = name;
}
/** @gqlField greeting */
getGreeting(): string {
return `Hello, ${this.name}`;
}
}type User {
greeting: String
}