From 9ea32eff1de73780ba20f7592e156ceccbc6eca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20My=C5=9Bliwiec?= Date: Sun, 23 Aug 2020 17:07:45 +0200 Subject: [PATCH] fix(): minor fixes to the resource (gql) schematic --- src/lib/resource/files/ts/__name__.graphql | 12 +++++++++--- .../files/ts/dto/create-__name@singular__.input.ts | 7 +++++-- .../files/ts/entities/__name@singular__.entity.ts | 7 +++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/lib/resource/files/ts/__name__.graphql b/src/lib/resource/files/ts/__name__.graphql index c7610a3b8..ff7efe945 100644 --- a/src/lib/resource/files/ts/__name__.graphql +++ b/src/lib/resource/files/ts/__name__.graphql @@ -1,8 +1,14 @@ -type <%= singular(classify(name)) %> {} +type <%= singular(classify(name)) %> { + # Example field (placeholder) + exampleField: Int +} -type Create<%= singular(classify(name)) %>Input {} +input Create<%= singular(classify(name)) %>Input { + # Example field (placeholder) + exampleField: Int +} -type Update<%= singular(classify(name)) %>Input { +input Update<%= singular(classify(name)) %>Input { id: Int! } diff --git a/src/lib/resource/files/ts/dto/create-__name@singular__.input.ts b/src/lib/resource/files/ts/dto/create-__name@singular__.input.ts index 7f86acd02..dc946b2ab 100644 --- a/src/lib/resource/files/ts/dto/create-__name@singular__.input.ts +++ b/src/lib/resource/files/ts/dto/create-__name@singular__.input.ts @@ -1,4 +1,7 @@ -<% if (type === 'graphql-code-first') { %>import { InputType } from '@nestjs/graphql'; +<% if (type === 'graphql-code-first') { %>import { InputType, Int, Field } from '@nestjs/graphql'; @InputType() -export class Create<%= singular(classify(name)) %>Input {}<% } else { %>export class Create<%= singular(classify(name)) %>Input {}<% } %> \ No newline at end of file +export class Create<%= singular(classify(name)) %>Input { + @Field(() => Int, { description: 'Example field (placeholder)' }) + exampleField: number; +}<% } else { %>export class Create<%= singular(classify(name)) %>Input {}<% } %> \ No newline at end of file diff --git a/src/lib/resource/files/ts/entities/__name@singular__.entity.ts b/src/lib/resource/files/ts/entities/__name@singular__.entity.ts index 9b042cf13..362e741b4 100644 --- a/src/lib/resource/files/ts/entities/__name@singular__.entity.ts +++ b/src/lib/resource/files/ts/entities/__name@singular__.entity.ts @@ -1,4 +1,7 @@ -<% if (type === 'graphql-code-first') { %>import { ObjectType } from '@nestjs/graphql'; +<% if (type === 'graphql-code-first') { %>import { ObjectType, Field, Int } from '@nestjs/graphql'; @ObjectType() -export class <%= singular(classify(name)) %> {}<% } else { %>export class <%= singular(classify(name)) %> {}<% } %> +export class <%= singular(classify(name)) %> { + @Field(() => Int, { description: 'Example field (placeholder)' }) + exampleField: number; +}<% } else { %>export class <%= singular(classify(name)) %> {}<% } %>