You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the recipe example, the following should throw a TS error, but doesn't:
@ObjectType()classRecipe{
@Field(type=>ID)id: string;
@Field()title: string;}
@Resolver(Recipe)exportclassRecipeResolver{
@Query(returns=>Recipe)asyncrecipe(@Arg("id")id: string){return{};// expected to throw a TS error as it doesn't have the `id` or `title` properties, but works fine!}}
Running the following query in GraphQL Playground does throw an error as expected:
The @Field(type => [Rate]) is only for providing type info when there's not enough TypeScript's reflection metadata. It doesn't perform the typechecking - the proposal is described in issue #221.
To have a type checking, you have to provide an explicit type annotation (e.g. : Promise<Recipe>):
@Query(returns=>Recipe)asyncrecipe(@Arg("id")id: string): Promise<Recipe>{
return {};// throw a TS error}
Using the recipe example, the following should throw a TS error, but doesn't:
Running the following query in GraphQL Playground does throw an error as expected:
Error:
The text was updated successfully, but these errors were encountered: