profile
viewpoint
Michał Lytek MichalLytek @gorrion-io Poland https://typegraphql.com/ Full-stack developer with a tendency to perfectionism. GraphQL and TypeScript evangelist, Node.js and React enthusiast. Author of the TypeGraphQL framework.

MichalLytek/type-graphql 5401

Create GraphQL schema and resolvers with TypeScript, using classes and decorators!

MichalLytek/class-transformer-validator 142

A simple plugin for class-transformer and class-validator which combines them in a nice and programmer-friendly API.

MichalLytek/typegraphql-nestjs 39

TypeGraphQL integration with NestJS

MichalLytek/routing-controllers-multiparam 5

A simple plugin for routing-controllers which allows to inject param from multiple sources.

MichalLytek/Java-Serial-Terminal 4

A simple app to communicate using serial (COM) ports

MichalLytek/awesome-graphql 1

Awesome list of GraphQL & Relay

MichalLytek/routing-controllers 1

Allows to create class-based controllers for express.js app using Typescript

push eventMichalLytek/type-graphql

Travis CI User

commit sha 7784f58703c7e356aa2d94f3e78c8671d6da65af

Deploy website Deploy website version based on fcb48341cccdc8c651b66d1f4d7cc190703bbd23

view details

push time in 15 hours

push eventMichalLytek/type-graphql

Pav

commit sha fcb48341cccdc8c651b66d1f4d7cc190703bbd23

docs(subscriptions): fix arguments of the `subscribe` option (#739)

view details

push time in 15 hours

PR merged MichalLytek/type-graphql

docs(subscriptions): fix arguments of the `subscribe` option Community :family_man_girl: Documentation :book:

This PR fixes the docs for the function arguments of the subscribe option (as per the ResolverFn signature).

+1 -1

1 comment

1 changed file

n1te1337

pr closed time in 15 hours

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

push eventMichalLytek/type-graphql

Michał Lytek

commit sha f2d80da4fdfdfaa19c15ab8ad683a025f3c803d1

fix(inputs): properly transform nested array of input type classes

view details

push time in a day

PR opened MichalLytek/type-graphql

Properly transform nested array of input type classes Bugfix :bug: :hammer:

Closes #734 🔒

+35 -3

0 comment

3 changed files

pr created time in a day

create barnchMichalLytek/type-graphql

branch : fix-nested-arrays-inputs

created branch time in a day

pull request commentMichalLytek/type-graphql

Docs, add dark mode feature

Navbar is the right place:

image

I consider interacting with docusaurus navbar is pretty tough.

I agree, that's why I haven't dig into that yet.

king-leonidas1337

comment created time in a day

PullRequestReviewEvent
PullRequestReviewEvent

issue commentMichalLytek/type-graphql

SDL converter

@a-suenami Ask on graphql-code-generator repository for assist with that, I'm not the author of the plugin.

I agree that it would be nice to generate resolvers classes with args that would just throw "not implemented" error in body.

MichalLytek

comment created time in a day

issue commentMichalLytek/typegraphql-prisma

Empty Input Type

@rossinicolas Could you also raise the issue in Prisma repo?

It looks like the schema introspection should detect your case and model it as a many-to-many relation in models, without the need of sgp_ch_turnos_agente in the middle 🤔

rossinicolas

comment created time in a day

issue commentMichalLytek/typegraphql-prisma

Import all generated code

Barrel export of all resolvers and args/model/input classes as a kinda namespace is on my roadmap 😉

For now you can try to use index.ts files in crud and other subfolders - I haven't tested if it really works.

jlavric

comment created time in a day

issue commentMichalLytek/typegraphql-prisma

RangeError: Maximum call stack size exceeded while running prisma generate

I think it might be an issue with ts-morph which is responsible for generating the code files.

@Hebilicious @rossinicolas Are you using the default approach with generating transpilled files to node_modules? Or you emit source code TS files in your repo folder?

Hebilicious

comment created time in a day

issue commentMichalLytek/typegraphql-prisma

Relay-compliant GraphQL schema

Yes, that's why it's a nice to have feature but requires more time and has lower priority for now.

FluorescentHallucinogen

comment created time in a day

issue commentMichalLytek/typegraphql-prisma

Add custom decorators on top of prisma schema resolvers

@reflash That config can be defined in a modular fashion - it gonna generate the root tree type composed from smaller subsets, so you can define query in different file, mutations in different, etc. Just 1:1 like with apollo resolvers 😉

MichalLytek

comment created time in a day

PR closed MichalLytek/type-graphql

use optional chaining to get value inside reflectedType Community :family_man_girl: Need More Info :man_shrugging:

Describe the Bug I'm not sure if it is a bug, or my specific use case. I'm creating a custom decorator that inject a generic find function as field function in the ObjectType class. to achive it i'm using the Args decorator as a function but it throws a error in runtine.

Cannot read property '0' of undefined

To Reproduce

@ArgsType()
class Ca{
   @Field(() => String)
   a: string;
}

@ObjectType()
class A {
    @ConnectionField( () => ProductFindArgs )
    prueba;
}

export function ConnectionField( findArgs: any, options?: FieldOptions ) {
	return function ConnectionDecorator( target: any, propertyKey: string | symbol ) {
		const newPropertyName = `_${String( propertyKey )}Connection`;
		const field = Field( () => String , { name: String( propertyKey ) } );
		const args = Args(findArgs);
		target[newPropertyName] = async function ConnectionFieldResolver( { a }: any ) {
			return findMany( a );
		};
		const descriptor :PropertyDescriptor = { configurable: true, enumerable: true, writable: true };
		args( target, newPropertyName, 0 );
		field( target, newPropertyName, descriptor );
	};
}

Expected Behavior I expected that it create a function to resolve prueba field inside object type, but it throws a error

I can resolve the problem just adding a optional chaining in line 11 inside /dist/helpers/findType.js , just like

 metadataDesignType = reflectedType?.[parameterIndex];

Logs at .../node_modules/type-graphql/dist/helpers/findType.js:11 metadataDesignType = reflectedType[parameterIndex]; ^ TypeError: Cannot read property '0' of undefined at .../node_modules/type-graphql/dist/helpers/findType.js:11:43) at Object.getParamInfo (.../node_modules/type-graphql/dist/helpers/params.js:10:49) at. .../node_modules/type-graphql/dist/decorators/Args.js:12:25

Environment (please complete the following information):

  • OS: mac os
  • Node 14.0
  • Package version lastest
  • TypeScript version 4.0.3
+1 -1

6 comments

1 changed file

techo207

pr closed time in a day

pull request commentMichalLytek/type-graphql

use optional chaining to get value inside reflectedType

Closing as superset by #733 🔒

techo207

comment created time in a day

push eventMichalLytek/type-graphql

Michał Lytek

commit sha 8dbec0a8d08c2a8aa81a7298bc9973e05cd4c711

fix(reflection): prevent crashing when reflected type is undefined

view details

Michał Lytek

commit sha 9566b0869d0695382a0f0c5e41bde7aa51e8cab2

Merge pull request #733 from MichalLytek/fix-reflected-type-check Prevent crashing when reflected type is undefined

view details

Michał Lytek

commit sha b7928d302f7a6931703e78ddecb7f6fafe915acc

tests(interfaces): add test case to reproduce auto registering issue

view details

Michał Lytek

commit sha 59f42ebd64ac0870c23f96d76e675c62c17e9e90

fix(interfaces): auto register implementations in field type case

view details

push time in a day

delete branch MichalLytek/type-graphql

delete branch : fix-reflected-type-check

delete time in a day

push eventMichalLytek/type-graphql

Michał Lytek

commit sha 8dbec0a8d08c2a8aa81a7298bc9973e05cd4c711

fix(reflection): prevent crashing when reflected type is undefined

view details

Michał Lytek

commit sha 9566b0869d0695382a0f0c5e41bde7aa51e8cab2

Merge pull request #733 from MichalLytek/fix-reflected-type-check Prevent crashing when reflected type is undefined

view details

push time in a day

issue closedMichalLytek/type-graphql

Args decorator try to read property of undefined

Describe the Bug I'm not sure if it is a bug, or my specific use case. I'm creating a custom decorator that inject a generic find function as field function in the ObjectType class. to achive it i'm using the Args decorator as a function but it throws a error in runtine.

Cannot read property '0' of undefined

To Reproduce

@ArgsType()
class Ca{
   @Field(() => String)
   a: string;
}

@ObjectType()
class A {
    @ConnectionField( () => ProductFindArgs )
    prueba;
}

export function ConnectionField( findArgs: any, options?: FieldOptions ) {
	return function ConnectionDecorator( target: any, propertyKey: string | symbol ) {
		const newPropertyName = `_${String( propertyKey )}Connection`;
		const field = Field( () => String , { name: String( propertyKey ) } );
		const args = Args(findArgs);
		target[newPropertyName] = async function ConnectionFieldResolver( { a }: any ) {
			return findMany( a );
		};
		const descriptor :PropertyDescriptor = { configurable: true, enumerable: true, writable: true };
		args( target, newPropertyName, 0 );
		field( target, newPropertyName, descriptor );
	};
}

Expected Behavior I expected that it create a function to resolve prueba field inside object type, but it throws a error

I can resolve the problem just adding a optional chaining in line 11 inside /dist/helpers/findType.js , just like

 metadataDesignType = reflectedType?.[parameterIndex];

Logs at .../node_modules/type-graphql/dist/helpers/findType.js:11 metadataDesignType = reflectedType[parameterIndex]; ^ TypeError: Cannot read property '0' of undefined at .../node_modules/type-graphql/dist/helpers/findType.js:11:43) at Object.getParamInfo (.../node_modules/type-graphql/dist/helpers/params.js:10:49) at. .../node_modules/type-graphql/dist/decorators/Args.js:12:25

Environment (please complete the following information):

  • OS: mac os
  • Node 14.0
  • Package version lastest
  • TypeScript version 4.0.3

closed time in a day

techo207

create barnchMichalLytek/type-graphql

branch : fix-implements-auto-register

created branch time in a day

issue commentMichalLytek/typegraphql-nestjs

Possibility to emit schema file in offline context

NestJS has some mechanism to do that: https://docs.nestjs.com/graphql/generating-sdl

However, it doesn't use modules but explicit resolvers class array, which is an awful idea.

You can do the same thing just by using buildSchema imported from type-graphql. You can put emitSchemaFile option or use emitSchemaDefinitionFile function explicitly.

I will leave that issue open to create TypeGraphQLSchemaBuilderModule which gonna accepts modules and which gonna have method for emitting SDL instead of importing printSchema requirement.

JohannesKlauss

comment created time in a day

issue commentMichalLytek/type-graphql

TypeGraphQL ESLint plugin

Personally I would not like to use a precompiler to TypeScript

In the future, the typescript compiler plugin will be the default recommended setting, while the old, reflect-metadata based one with () => Type helpers will be a fallback, compatibility mode, mostly for babel users.

borremosch

comment created time in 3 days

PR opened MichalLytek/type-graphql

fix(reflection): prevent crashing when reflected type is undefined Bugfix :bug: :hammer:

Closes #724

+75 -4

0 comment

3 changed files

pr created time in 3 days

issue commentMichalLytek/type-graphql

Args decorator try to read property of undefined

Reopening the issue as the proper fix is ready on #733

techo207

comment created time in 3 days

IssuesEvent

create barnchMichalLytek/type-graphql

branch : fix-reflected-type-check

created branch time in 3 days

pull request commentMichalLytek/type-graphql

use optional chaining to get value inside reflectedType

From what I understand, you have object type with simple field (let's say bar in English instead of your local pueba):

@ObjectType()
class Foo {
  @Field()
  bar!: string;
}

And what you want to achieve is that it has another barConnection field in graphql query can accept some args (ProductFindArgs) and will automatically resolve that relation using findMany function?

If so, why you can't just create a field resolver for that?

@ObjectType()
class Foo {
  bar!: FooBarObjectType[];

  @Field(returns => FooBarObjectType)
  barConnection(@Args() args: ProductFindArgs) {
    return findMany(args);
  }
}

Your snippet is missing the type of the field, which is why TS reflection fails, as well as your code.

Try to use less magic. The code will be more reliable and easier to understand by others.

techo207

comment created time in 3 days

pull request commentMichalLytek/type-graphql

docs(interfaces): clarify chained interface syntax

@jtassin Your example without explanation doesn't give too much valuable info.

The error "Type Person must implement Node because it is implemented by IPerson" is clear and there's no any special thing to do than making implements: [IPerson, Node] which is straightforward.

The behavior is well described in GraphQL spec:

Transitively implemented interfaces (interfaces implemented by the interface that is being implemented) must also be defined on an implementing type or interface.

jtassin

comment created time in 4 days

pull request commentMichalLytek/type-graphql

use optional chaining to get value inside reflectedType

to resolve a one to many relacion

Please describe your use case in more detail, I still don't know how your printed graphql schema looks like, how the other classes looks like and why you need to call the decorator fn manually instead of using generic types and resolvers feature.

techo207

comment created time in 4 days

issue closedMichalLytek/type-graphql

Custom npm package for object validation?

Hello,

I want to implement my custom validation using an external package that can be found in this git repo https://github.com/oussamahamdaoui/forgJs.

How can I replace the class-validator with forgJS?

Can I have a schema wide validation for all my objects?

Thanks in advance

closed time in 4 days

wolfiton

issue commentMichalLytek/type-graphql

How to make @Query when create a schema having `refPath` field with createUnionType?

@waiphyo285 #728 should give you nice error message from graphql-js instead of failing due to returning undefined from resolveType so you should be able to find the mistake in your code easier.

waiphyo285

comment created time in 4 days

push eventMichalLytek/type-graphql

Michał Lytek

commit sha 30752dfb0cec1bf45ca08061bae94fa5038766b0

fix(interfaces-unions): handle resolveType returning undefined

view details

Michał Lytek

commit sha 5a7579e7b9973750be482382aefaf7f9a39b273e

Merge pull request #731 from MichalLytek/fix-resolve-type fix(interfaces-unions): handle resolveType returning undefined

view details

push time in 4 days

delete branch MichalLytek/type-graphql

delete branch : fix-resolve-type

delete time in 4 days

issue closedMichalLytek/type-graphql

How to make @Query when create a schema having `refPath` field with createUnionType?

Description about the problem I'm using createUnionType on a schema to reference multiple schemas that enable on mongoose. But I am unhappy getting errors Cannot read property 'type' of undefined.

Here is my trying code

export const RefRoomUnion = createUnionType({
  name: 'RefRoomUnion', 
  types: () => [ City, Township, RoomTopic ],
  resolveType: (value: any) => {
    if ('City'  in value) return "City"
    if ('Township' in value) return "Township"
    if ('RoomTopic' in value) return "RoomTopic"
    return undefined;
  }
});

/* ChatRoom Schema */

@ObjectType()
export class ChatRoom {
  @Field(_type => ID)
  _id: String;

  @Field(_type => RefRoomUnion,{ nullable: true })
  @Property({ required: true, refPath: "refRoom" })
  referenceid: Ref<typeof RefRoomUnion>;

  @Field(_type => RefRoomType, { nullable: true })
  @Property({ required: true, enum: Object.values(RefRoomType), index: true })
  refRoom: RefRoomType;
}

export const ChatRoomModel = getModelForClass(ChatRoom);

As above ChatRoom is clearly schema intend to reference multiple schemas. And imported RefRoomType enum and sample query are here.

export enum RefRoomType {
  City = "City",
  Township = "Township",
  RoomTopic = "RoomTopic"
};

registerEnumType(RefRoomType, {
  name: "RefRoomType", // this one is mandatory
  description: "The basic room types", // this one is optional
});

@Query(() => [ChatRoom]) // [ChatRoomModel] return schemas
    async returnAllChatRooms(){
      return await ChatRoomModel.find().populate("referenceid"); // ChatRoomModel
  };

Then I can't go on to make Resolver to query ChatRoom response data. The error I can't solve easily is following.

query {
  	returnAllChatRooms {
    	_id
    	description
        referenceid {
          __typename
          ... on City {
            city
          }
          ... on Township {
            township
          }
          ... on RoomTopic {
            roomtopic
          }
        }
     }
  }

Error response

{
  "errors": [
    {
      "message": "Cannot read property 'type' of undefined",
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "path": [
        "returnAllChatRooms",
        0,
        "referenceid"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "TypeError: Cannot read property 'type' of undefined",
            "    at Function.<anonymous> (C:\\Users\\HP\\Documents\\nwt\\fishadapt_chatroom\\node_modules\\type-graphql\\dist\\schema\\schema-generator.js:427:95)",
            "    at Generator.next (<anonymous>)",
            "    at fulfilled (C:\\Users\\HP\\Documents\\nwt\\fishadapt_chatroom\\node_modules\\tslib\\tslib.js:112:62)",
            "    at processTicksAndRejections (internal/process/task_queues.js:93:5)"
          ]
        }
      }
    },
  ...
}

Can someone help me please. Many thanks for very first creating issue.

Yeah here is environment

OS: Window 10

Node Version: v12.13.1

TSC Version: 3.9.7

Package Version: ^1.0.0

closed time in 4 days

waiphyo285

pull request commentMichalLytek/type-graphql

use optional chaining to get value inside reflectedType

I'm creating a custom decorator that inject a generic find function as field function in the ObjectType class. to achive it i'm using the Args decorator as a function but it throws a error in runtine.

Instead of fixing it from the wrong side, it's better to discuss your use case. My question is: why you do such weird things instead of use the generic types feature?

Registering virtual fields dynamically is against TypeGraphQL goals as your args TS type has no notion about this property hence you can't use it in the resolver.

techo207

comment created time in 4 days

issue closedMichalLytek/type-graphql

POJO

Thanks for the great library. I would like to declare my types in simple POJOs with no decorators and define my schema separately in a strongly typed manner.

In the ORM world with TypeOrm this is called "Entity Schema" as described here: https://github.com/typeorm/typeorm/blob/master/docs/separating-entity-definition.md

@MichalLytek, you mentioned that it might be possible to achieve it with TypeGraphQL here: https://medium.com/@MichalLytek/i-would-like-to-correct-one-thing-dd4b9ad3222f

Could you elaborate and provide a sample implementation? Also, would I incur a performance penalty if I use Field resolver?

If it can be done, it would allow me to keep my "Domain layer" free of library specific packages. Thanks

closed time in 5 days

Fabyao

issue commentMichalLytek/type-graphql

POJO

Simple POJO in that context means a class with only properties and decorators. Then you add field resolvers by @FieldResolver as a method of @Resolver class.

Having classes without decorators and then some config or typedefs in separate file is clearly of out scope of this library.

You can use standard apollo typedefs and resolvers and add graphql-code-generator to make them typesafe.

Fabyao

comment created time in 5 days

issue openedborremosch/eslint-plugin-type-graphql

Auto fixing

It would be super nice to have auto fix command that would change e.g.:

@Query()
userName(): string | null{ 
  return null;
}

into

@Query(() => String, { nullable: true })
userName(): string | null {
  return null;
}

The same goes to common cases like arrays and promises.

created time in 5 days

issue openedborremosch/eslint-plugin-type-graphql

Wrong invalid-decorator-type rule

The docs says:

Examples of correct code for this rule:

@Field(() => Int, { nullable: 'items' })
timestamps?: Array<number | null>;

However type-graphql@1.0.0 had a breaking change: "remove legacy array inference - now explicit array syntax ([Item]) is required"

created time in 5 days

startedborremosch/eslint-plugin-type-graphql

started time in 5 days

issue commentMichalLytek/type-graphql

TypeGraphQL ESLint plugin

The idea sounds great! I have no experience with eslint plugins development so I can't help with that for now.

While #296 can solve the nullability or missing explicit type issues, there's still a few cases where linter can warn or help during development, not only in runtime.

A developer creates a number, supposed to contain an integer, but does not add a type function to the TypeGraphQL decorator, essentially making it a float over the GraphQL connection.

How the eslint plugin would know, where the number property should be int and when should be float? 😕 Maybe your team should use decorator aliases like @IntField to prevent such hard to spot mistakes 😕

borremosch

comment created time in 5 days

push eventMichalLytek/type-graphql

Michał Lytek

commit sha 30752dfb0cec1bf45ca08061bae94fa5038766b0

fix(interfaces-unions): handle resolveType returning undefined

view details

push time in 5 days

PR opened MichalLytek/type-graphql

fix(interfaces-unions): handle resolveType returning undefined Bugfix :bug: :hammer:

Closes #728

+86 -4

0 comment

4 changed files

pr created time in 5 days

create barnchMichalLytek/type-graphql

branch : fix-resolve-type

created branch time in 5 days

issue commentMichalLytek/typegraphql-prisma

Empty Input Type

Looks like your model does not have any updateble fields, only pks and fks 😕 Can you share the Sgp_ch_turnos_agente model from prisma schema?

BTW, you should map the table name to more readable model name 😝

rossinicolas

comment created time in 5 days

issue commentMichalLytek/type-graphql

Add dark mode option to Type graphql homepage

@EdTosoy Docs site is based on Docusaurus 1. If you find a way to have a theme switcher there, feel free to open a PR 😉

EdTosoy

comment created time in 6 days

issue commentMichalLytek/type-graphql

How to make @Query when create a schema having `refPath` field with createUnionType?

  • if it's a question or need for help about integration with mongoose, please go on stackoverflow or gitter
  • if it's a bug report, please fill the poper issue template with all required info (like library version) and a simple reproduction
waiphyo285

comment created time in 7 days

starteddevoxa/prisma-relay-cursor-connection

started time in 8 days

issue commentMichalLytek/type-graphql

Interface implementations are missing

The docs says:

By default, if the interface type is explicitly used in schema definition (used as a return type of a query/mutation or as some field type), all object types that implement that interface will be emitted in schema, so we don't need to do anything.

So it looks like a bug, I'll have to cover your case by tests. In the meantime you can use orphanedTypes as a workaround for now.

HitkoDev

comment created time in 8 days

issue commentMichalLytek/typegraphql-prisma

Relay-compliant GraphQL schema

It comes from Prisma 2. For now TypeGraphQL uses schema and operations definitions directly from Prisma, there's not transform or translation layer.

However adding Node resolver and others would be a nice to have feature 👍

FluorescentHallucinogen

comment created time in 8 days

issue commentMichalLytek/type-graphql

Feature: Data loader integration

No, TypeGraphQL is orm-lib agnostic. Why would you want to do that?

MichalLytek

comment created time in 8 days

issue commentMichalLytek/typegraphql-prisma

Compatibility issues between typegraphql and prisma enum types

@jsefiani Use search - you can find #16

MichalLytek

comment created time in 8 days

issue closedMichalLytek/type-graphql

Need a way to return a response right after when there's a new subscription request.

I'm using the Subscription feature to track the progress of a task. But sometimes when the task is completed while a client is sending a request to subscribe progress, it can't receive any events from the server because on the server, the task is already completed and there would be no events anymore. Therefore, the client just stays on the incomplete state without knowing that the task is already completed.

Describe the solution you'd like If the server can send an immediate response to the client right after receiving a subscription request, it would be able to send a response that the task is already completed.

closed time in 8 days

rkdrnf

issue commentMichalLytek/type-graphql

Need a way to return a response right after when there's a new subscription request.

Please open a feature request in graphql-subscriptions repo: https://github.com/apollographql/graphql-subscriptions

TypeGraphQL is only a wrapper around that and graphql-js so it's limited to their capabilities.

rkdrnf

comment created time in 8 days

release MichalLytek/typegraphql-prisma

v0.8.2

released time in 9 days

issue closedMichalLytek/typegraphql-prisma

Error: Cannot find module '../../package.json'

After updating to version v0.8.1 I'm getting errors when trying to generate the graphql types. Looks that the path to the package.json path is incorrect.

Capture

closed time in 9 days

PHILLIPS71

issue commentMichalLytek/typegraphql-prisma

Error: Cannot find module '../../package.json'

Checked in 1-basic example and it works well with v0.8.2.

PHILLIPS71

comment created time in 9 days

push eventMichalLytek/typegraphql-prisma

Michał Lytek

commit sha 3b05c221233e6f14825a99a2d1273084fff6d899

Update basic example to newest prisma and deps

view details

push time in 9 days

created tagMichalLytek/typegraphql-prisma

tagv0.8.2

Prisma 2 generator to emit TypeGraphQL types and CRUD resolvers from your Prisma 2 schema

created time in 9 days

push eventMichalLytek/typegraphql-prisma

Michał Lytek

commit sha efcd76dafea2da3b8813b1887ade6cf2b1492233

Fix package json require path due to wrong npm package layout

view details

Michał Lytek

commit sha 29ed45c1a65c77bf99b9d2018e0a04398648197d

release: 0.8.2

view details

push time in 9 days

issue commentMichalLytek/typegraphql-prisma

Error: Cannot find module '../../package.json'

Please try with 0.8.2 😉

PHILLIPS71

comment created time in 9 days

push eventMichalLytek/type-graphql

Travis CI User

commit sha d3936eb32b1f3f2cbc86804fc0f88611c96e17fb

Deploy website Deploy website version based on cd908565961b3325d798348690a454cb6d00932f

view details

push time in 9 days

release MichalLytek/type-graphql

v1.1.0

released time in 9 days

created tagMichalLytek/type-graphql

tagv1.1.0

Create GraphQL schema and resolvers with TypeScript, using classes and decorators!

created time in 9 days

push eventMichalLytek/type-graphql

Michał Lytek

commit sha cd908565961b3325d798348690a454cb6d00932f

release: 1.1.0

view details

push time in 9 days

issue commentMichalLytek/type-graphql

Custom npm package for object validation?

Closing this one via 3c767e6 🔒

@wolfiton you can now use provide your own validate function implementation that will call forgJS.

wolfiton

comment created time in 9 days

push eventMichalLytek/type-graphql

Michał Lytek

commit sha 02bd87faa167605737f4d178c29bfddb6b6ce320

feat(enums): add support for defining description and deprecation reason

view details

Michał Lytek

commit sha d336dc994ab632beb4f96f5f1e85c36626afa5c4

tests(enums): add test cases for advanced enums

view details

Michał Lytek

commit sha 914d3184adcb3bf2d99240e6c9aca6b83499f414

refactor(enums): rename fieldsConfig to valuesConfig

view details

Michał Lytek

commit sha 28cab3bf07b67f5f39fb97e87bab54dd74e0afe9

docs(enums): add info about advanced enums configuration

view details

Michał Lytek

commit sha 79a3c849689beed682d9702acc4be376fbda6079

Merge pull request #714 from MichalLytek/advanced-enums

view details

push time in 9 days

push eventMichalLytek/type-graphql

Travis CI User

commit sha 9518995552839218e413433aced2bd5f4d4fa4b5

Deploy website Deploy website version based on 3df214916af9e90c181509578eadf375672d87b0

view details

push time in 9 days

issue commentMichalLytek/type-graphql

Advanced enum support

This feature is implemented by #714.

Maybe in v2.0 there will be support for more declarative, class-based approach of defining enums with description and deprecation reasons, like in the first post.

MichalLytek

comment created time in 9 days

delete branch MichalLytek/type-graphql

delete branch : advanced-enums

delete time in 9 days

push eventMichalLytek/type-graphql

Michał Lytek

commit sha fcdea2178b1164eadc6c6ac65832fe49ed538199

feat(enums): add support for defining description and deprecation reason

view details

Michał Lytek

commit sha c1dd0c6709d5f3b8cb73efafc3b777fd7d9e077e

tests(enums): add test cases for advanced enums

view details

Michał Lytek

commit sha a72de57677e259e12cb93dbd1b92155e6ed5274e

refactor(enums): rename fieldsConfig to valuesConfig

view details

Michał Lytek

commit sha 3df214916af9e90c181509578eadf375672d87b0

docs(enums): add info about advanced enums configuration

view details

push time in 9 days

PR merged MichalLytek/type-graphql

Support for enums with descriptions and depreciations Enhancement :new:

Closes #39 🔒

+102 -3

1 comment

7 changed files

MichalLytek

pr closed time in 9 days

issue closedMichalLytek/type-graphql

Advanced enum support

Support for enums with descriptions and depreciations.

API Draft

@EnumType({ description: "All posible directions of moves the on grid" })
class DirectionEnumType {
  @EnumValue({ description: "Up to the sky!" })
  Up: string;

  @EnumValue()
  Down: string;

  @EnumValue({ deprecationReason: "Use `Down` instead" })
  Bottom = this.Down;

  @EnumValue() 
  Left: string;

  @EnumValue() 
  Right: string;
}

// we don't use `DirectionEnumType` class on runtime, so only export "real" enum `Direction`
export const Direction = createEnum(DirectionEnumType);


// usage in definitions
@ObjectType()
class Movement {
  @Field(type => Direction)
  direction: Enum<typeof Direction>;
}

// usage in resolvers
const mov = new Movement();
mov.direction = Direction.Right;
mov.direction = "Left";

switch (mov.direction) {
  case Direction.Right:
    console.log("right!");
    break;
  case Direction.Left:
    console.log("left!");
    break;
  // etc.
}

closed time in 9 days

MichalLytek

push eventMichalLytek/type-graphql

Michał Lytek

commit sha d7ccda40251de0c4b7a85e43f94cef4b65b05547

docs(prisma): update docs repo link

view details

Pelle Jacobs

commit sha 4884576d5a93a1dabb3b1fdc794dd60894e528c6

chore(github): fix bug report typo (#717)

view details

Michał Lytek

commit sha 02bd87faa167605737f4d178c29bfddb6b6ce320

feat(enums): add support for defining description and deprecation reason

view details

Michał Lytek

commit sha d336dc994ab632beb4f96f5f1e85c36626afa5c4

tests(enums): add test cases for advanced enums

view details

Michał Lytek

commit sha 914d3184adcb3bf2d99240e6c9aca6b83499f414

refactor(enums): rename fieldsConfig to valuesConfig

view details

Michał Lytek

commit sha 28cab3bf07b67f5f39fb97e87bab54dd74e0afe9

docs(enums): add info about advanced enums configuration

view details

push time in 9 days

issue commentMichalLytek/typegraphql-prisma

Discussion about Prisma 2 integration

I've just released the v0.8.1 release 🚀 Changelog available in github release notes: https://github.com/MichalLytek/typegraphql-prisma/releases/tag/v0.8.1

I won't publish notifications here anymore, so if you want to keep informed, please enable watching this repository releases:

image

MichalLytek

comment created time in 9 days

release MichalLytek/typegraphql-prisma

v0.8.1

released time in 9 days

issue closedMichalLytek/typegraphql-prisma

Use Typegraphql's useMiddleware() function?

How can I implement authorization scope for different users? In plain typegraphql a simple useMiddleware function could solve it but is there a way to implement the same using typegraphql-prisma while still having the same query/mutation structure?

closed time in 9 days

sandipndev

issue commentMichalLytek/typegraphql-prisma

Use Typegraphql's useMiddleware() function?

Duplicate of #11

sandipndev

comment created time in 9 days

created tagMichalLytek/typegraphql-prisma

tagv0.8.1

Prisma 2 generator to emit TypeGraphQL types and CRUD resolvers from your Prisma 2 schema

created time in 9 days

push eventMichalLytek/typegraphql-prisma

Michał Lytek

commit sha d793ce856745878777530d845c169caf247760ed

Add simple resolvers support

view details

Michał Lytek

commit sha 3698ae917e639072ada3e4820d1d0bb2d3706766

Remove `OutputType` suffix from aggregate subtypes

view details

Michał Lytek

commit sha 05b279c6985c9048c6531e7a1795f6a54995a4a7

release: 0.8.1

view details

push time in 9 days

issue commentMichalLytek/typegraphql-prisma

Union Resolvers feature idea

@wSedlacek Could you prepare the design of the expected generated code? I'm not sure which prisma operations the union resolver should support and what would be the signature of args as the object types can have no common fields.

MichalLytek

comment created time in 10 days

issue commentMichalLytek/typegraphql-prisma

Tackle the circular imports without needing to use `commonjs`

I think a way to support that would be a generator option emitSingleFile. Then we could just easily change default tsconfig setting and generate one big transipiled file instead of tons of files.

However I'm not sure if it fixes the circular imports issues then. While TypeGraphQL decorators are lazy and can handle that, Typescript reflection could break in that situation because of referencing not existing yet values.

I need to check that idea first on two simple TypeGraphQL classes before digging more into it.

MichalLytek

comment created time in 10 days

issue commentMichalLytek/typegraphql-prisma

Complexity plugin support

@wsedlacek

How would you want to use the complexity plugin? In normal TypeGraphQL you manually annotate every field or input/object/args type with the @Complexity decorator.

Do you use some more model-based approach? Like annotate only model field and then use the same value for every field-related things like sort args, etc.?

MichalLytek

comment created time in 10 days

issue openedMichalLytek/typegraphql-prisma

Complexity plugin support

@MichalLytek I have been playing around with the code base and have been testing two new features that might be nice in typegraphql-prisma.

  • Complexity plugin support
  • Default value for take (required to properly determine complexity)

Together these can prevent memory overflow high CPU utilization by limiting how complex queries can be which is extremely useful when you have large databases.

Originally posted by @wSedlacek in https://github.com/MichalLytek/typegraphql-prisma/issues/1#issuecomment-672975188

created time in 10 days

issue openedMichalLytek/typegraphql-prisma

Tackle the circular imports without needing to use `commonjs`

Fantastic work on transpiling @MichalLytek. I was thinking about how we could tackle the circular imports without needing to use commonjs on everything. I was wondering if bundling all the transpiled code into a single file would be possible 🤔
Bundling would also reduce the size if only by removing all the import statements which in turn may reduce write time to disk as there is less to write and it is all in only a few files rather then what could be up to hundreds.

If we can reduce generation times that would be great as then we could also improve testing speed.

Originally posted by @wSedlacek in https://github.com/MichalLytek/typegraphql-prisma/issues/1#issuecomment-685188342

created time in 10 days

issue openedMichalLytek/typegraphql-prisma

Union Resolvers feature idea

I had an idea for another possible feature. Union Resolvers. Adding /// @TypeGraphql.Union = result to two models will generate an additional set of findOne/findMany revolvers of a union type of each model that is in that union.

An example may look like this.

/// @TypeGraphql.Union = product
model Movie {
  id        Int     @id @default(autoincrement())
  title     String
  length    Int
  actors    Actor[]
}

/// @TypeGraphql.Union = product
model Book {
  id        Int     @id @default(autoincrement())
  title     String
  pages     Int   
}

model Actor {
  id        Int     @id @default(autoincrement())
  name      String
}

Which would generate this type and the resolvers for it.

export const Product = createUnionType({
  name: 'Product',
  types: () => [Movie, Book],
});

The Prisma code for this may look something like this.

const movies = await prisma.movies.findMany(args).then((movies: Movie[]) => plainToClass(Movie, movies));
const books = await prisma.books.findMany(args).then((books: Book[]) => plainToClass(Book, books));
return [...movies, ...books].sort(byArgs(args));

The difficult part would be defining the orderBy and where arguments as you would need to determine what fields were shared between the two (or more) models and use those to generate the arguments. Additionally sorting will likely have some additional overhead but it would be cool to be able to do something like this.

{
  products {
    ... on Book {
      title
      pages
    }
    ... on Movie {
      title
      length
    }
  }
}

Originally posted by @wSedlacek in https://github.com/MichalLytek/typegraphql-prisma/issues/1#issuecomment-674492557

created time in 10 days

issue commentMichalLytek/typegraphql-prisma

Add custom decorators on top of prisma schema resolvers

@reflash My proposed solutions is using a config file, similar to https://github.com/maticzav/graphql-shield.

It would allow to apply decorators in a type-safe manner and it could looks something like this:

import { ResolversEnhanceMap } from "@generated/typegraphql-prisma"`;

const enhanceMap: ResolversEnhanceMap = {
  Query: {
    findManyUsers: [LoggerMiddlware("findManyUsers accessed")],
  },
  Mutation: {
    createUser: [Authorized(Role.ADMIN)],
  },
};

export default enhanceMap;

The config object would be imported by generated typegraphql-prisma index.ts file and would call the decorators from array manually, like: enhanceMap.findManyUsers.forEach(it => it(UserCrudResolver.prototype, "findManyUsers"));

That would register the decorator on top of a proper class and method, so it will work from TypeGraphQL side like a normal decorator put in the generated class file.

Doing this by runtime file allows to use imports and other language constructs that static prisma attributes (schema docs) are not capable of.

MichalLytek

comment created time in 10 days

issue openedMichalLytek/typegraphql-prisma

Add custom decorators on top of prisma schema resolvers

Is there a way to add custom decorators on top of prisma schema resolvers? e.g. I want for some crud operations to be available to certain roles of users. What is the approach I should use?

Originally posted by @reflash in https://github.com/MichalLytek/typegraphql-prisma/issues/1#issuecomment-703247069

created time in 10 days

IssuesEvent

issue commentMichalLytek/typegraphql-prisma

Problem with type conflicts when using doc lines to change field names

Reopening for tracking the additional getters issue.

The design goal of typegraphql-prisma is that Prisma results are accepted as TypeGraphQL object type class type and TypeGraphQL input type class is accepted as Prisma args/input.

jejacobsendev

comment created time in 10 days

issue commentMichalLytek/typegraphql-prisma

typegraphql-prisma is ahead of latest stable prisma release

Support for release 2.8.1 has been added in 8d92288.

Please watch the repo releases to be notified about publishing the patch release containing the fix.

AviBueno

comment created time in 10 days

issue closedMichalLytek/typegraphql-prisma

Compatibility issues between typegraphql and prisma enum types

I have a property status (ENUM) which seems to cause compatibility issues, so I'm required to use Prisma Client's model instead of the one generated by type-graphql. Do you know what this might be?

image

If I use the CatalogModel then it works fine, but when I use the one generated by type-graphql, I get the above issue. image

Originally posted by @jsefiani in https://github.com/MichalLytek/typegraphql-prisma/issues/1#issuecomment-702989587

closed time in 10 days

MichalLytek
more