Art Module
Generating the art module
This creates a new codegen module
pnx g @logosphere/sdk:module --name art
Take a look at the project structure under
libs/art-gen/src
In this step, similar to the music module, we will create a simple model for the art domain, consisting of Artist and Artwork entities.
Modify
libs/art-gen/src/art.model.ts
file:/* eslint-disable @typescript-eslint/no-unused-vars */
import { Entity, Prop } from '@logosphere/decorators';
@Ent('artist')
export class Artist {
@Prop({
examples: ['Beeple', '3LAU', 'WhisBe'],
})
name: string;
}
@Ent('artwork')
export class Artwork {
@Prop({
examples: ['The First 5000 Days', 'All Night Long', 'Gold Gummy Bear'],
})
title: string;
@Prop({
examples: ['Most famous Beeples work', 'Best work', 'It is about a gold gummy bear'],
})
description: string;
@Prop({ type: () => Artist, index: false })
author: Artist;
}
pnx affected:build
pnx g @logosphere/sdk:api --module art
pnx affected:build
pnx affected:test
To add Art application to existing stack, docker-compose generator need to be called again.
pnx g @logosphere/sdk:docker-compose
Existing
.env
and docker-compose.yaml
will be overridden. If you made some changes in previous set you have to configure it againSimilar like before the service can be run as part of stack
docker-compose up
Or can be serve as standalone container
pnx docker art --port=4001
Check schema that it matches the art module
Mutation:
mutation artworkCreate($artwork: ArtworkInput!) {
artworkSave(artwork: $artwork) {
id
subjectId
title
description
createdAt
updatedAt
}
}
Variables:
{
"artwork": {
"title": "The first 5000 days",
"description": "Most famous Beeple work",
"author": {
"name": "Beeple"
}
}
}
Output:
{
"data": {
"artworkSave": {
"id": "c12d4725ee5dc9870e23f51cf06d09260aebfa9c17c3a1111cd96a2a9406752a",
"subjectId": "369435906932736",
"title": "The first 5000 days",
"description": "Most famous Beeple work",
"createdAt": "2022-07-21T04:48:33.374Z",
"updatedAt": "2022-07-21T04:48:33.374Z"
}
}
}
Last modified 6mo ago