Typegraphql
typegraphql.com › docs › custom-decorators.html
Custom decorators · TypeGraphQL
Custom decorators are a great way to reduce the boilerplate and reuse some common logic between different resolvers. TypeGraphQL supports three kinds of custom decorators - method, resolver class and parameter.
GitHub
github.com › MichalLytek › type-graphql
GitHub - MichalLytek/type-graphql: Create GraphQL schema and resolvers with TypeScript, using classes and decorators! · GitHub
Create GraphQL schema and resolvers with TypeScript, using classes and decorators! - MichalLytek/type-graphql
Starred by 8.1K users
Forked by 673 users
Languages TypeScript 94.5% | JavaScript 4.5%
The Guild
the-guild.dev › graphql › codegen › plugins › typescript › typescript-type-graphql
TypeScript TypeGraphQL
April 2, 2026 - This plugin should be compatible with other client-side plugins, such as typescript-operations. Some differences with the types generated by the basic TypeScript plugin: classes are generated instead of interfaces · TypeGraphQL decorators like @ObjectType and @Field will be added ·
Typegraphql
typegraphql.com
TypeGraphQL · Modern framework for GraphQL API in Node.js
Create the schema, types and resolvers only with TypeScript, using classes and decorators! Use features like automatic validation, authorization guards, dependency injection and plenty more... Use only classes and decorators to define your GraphQL schema. No need to define types in SDL and no need to create interfaces for them!
Typegraphql
typegraphql.com › docs › types-and-fields.html
Types and Fields · TypeGraphQL
The first thing we must do is decorate the class with the @ObjectType decorator. It marks the class as the type known from the GraphQL SDL or GraphQLObjectType from graphql-js:
GitHub
github.com › MichalLytek › type-graphql › blob › master › docs › custom-decorators.md
type-graphql/docs/custom-decorators.md at master · MichalLytek/type-graphql
April 18, 2019 - Custom decorators are a great way to reduce the boilerplate and reuse some common logic between different resolvers. TypeGraphQL supports three kinds of custom decorators - method, resolver class and parameter.
Author MichalLytek
GitHub
github.com › Quramy › graphql-decorator
GitHub - Quramy/graphql-decorator
Helps to build GraphQL schema with TypeScript. ... Decorators(@ObjectType, @Schema, @NonNull, and more...) corresponding to GraphQL type system.
Starred by 42 users
Forked by 21 users
Languages TypeScript 99.3% | Shell 0.7% | TypeScript 99.3% | Shell 0.7%
Typegraphql
typegraphql.com › docs › extensions.html
Extensions · TypeGraphQL
Annotating schema types or fields with a custom metadata, that can be then used at runtime by middlewares or resolvers, is a really powerful and useful feature. For such use cases, TypeGraphQL provides the @Extensions decorator, which adds the data we defined to the extensions property of the ...
Top answer 1 of 2
1
I think you are trying to have an Arg of an array whit numbers and strings in that case you should do
@InputType()
class HitsInput
{
@Field()
Hits: [number | string];
}
@Resolver()
export default class SearchResolver {
@Query(() => [String], { nullable: true })
async searchAssetList(@Arg('input') input: HitsInput) {
return []
}
}
if this is not the case and you want an object whit dynamic fields you need to define the object, let say if hits have Name and Id_Hits,
@InputType()
class HitsInput
{
@Field()
Id_Hits: number;
@Field()
Name: string;
}
@Resolver()
export default class SearchResolver {
@Query(() => [String], { nullable: true })
async searchAssetList(@Arg('input') input: HitsInput) {
return []
}
}
and if you want to have a dynamic args base in the user request I am not quite sure that it is possible, but it is possible to do this
@InputType()
class HitsInput
{
[key: string]: any;
}
2 of 2
0
I had exactly the same issue, a couple of days ago, and I solve it using GraphQLScalarType by creating my own custom type here how to do it
import { GraphQLScalarType} from "graphql";
export const GraphQLAny = new GraphQLScalarType({
name: 'Any',
serialize: (value) => value,
parseValue: (value) => value,
parseLiteral: (ast) => ast
});
and in your class you can use your customTpe like this:
@ObjectType()
class SearchListInput {
@Field(() => GraphQLAny)
hits: typeof GraphQLAny;
}
npm
npmjs.com › package › graphql-schema-decorator
graphql-schema-decorator - npm
March 9, 2020 - You can declare a GraphQL schema class with @Schema, @Query and @Mutation decorators. ... A schema class should a field annotated by @Query, which represents that the type of this filed will be a root query of GraphQL.
» npm install graphql-schema-decorator
Published Mar 09, 2020
Version 1.0.0
Author Quramy
GitHub
github.com › tenry92 › graphql-decorators
GitHub - tenry92/graphql-decorators: GraphQL decorators for TypeScript.
This package provides useful TypeScript decorators for easy creation of GraphQL types and inputs as well as controllers for reading and writing data.
Author tenry92
GitHub
github.com › indigotech › graphql-schema-decorator
GitHub - indigotech/graphql-schema-decorator
This project was discontinued and will not be updated anymore. We recommend using type-graphql, that covers most of this project's features and is being constantly updated and maintained. This package makes possible the use of decorators to define a GraphQL schema.
Starred by 38 users
Forked by 11 users
Languages TypeScript 99.8% | Shell 0.2% | TypeScript 99.8% | Shell 0.2%
Telerik
telerik.com › blogs › introduction-typegraphql
Introduction to TypeGraphQL
July 26, 2024 - In the above example, we define the GraphQL object type for a User using TypeScript classes, which enhances type safety and maintainability. Each field of the User object is defined with a @Field decorator, which describes the type of data (such as ID, String, etc.) and whether it is nullable or not.
LogRocket
blog.logrocket.com › home › how to integrate typescript with graphql using typegraphql
How to integrate TypeScript with GraphQL using TypeGraphQL - LogRocket Blog
June 18, 2024 - Additionally, we’re importing both the Property decorator and the getModelForClass method from the @typegoose/typegoose package. The PropertyDecorator is used for setting properties in a class, without which it is just a type and will not be in the final model. Int and ID are aliases for three basic GraphQL scalars, and the getModelForClass method is used to get a model for a given class.
GitHub
github.com › MichalLytek › type-graphql › blob › master › docs › resolvers.md
type-graphql/docs/resolvers.md at master · MichalLytek/type-graphql
September 22, 2020 - Besides declaring GraphQL's object types, TypeGraphQL allows us to easily create queries, mutations and field resolvers - like normal class methods, similar to REST controllers in frameworks like Java Spring, .NET Web API or TypeScript routing-controllers. First we create the resolver class and annotate it with the @Resolver() decorator.
Author MichalLytek