@madxnl/madhatter-cli v0.3.0-beta.2
madhatter-cli
BUGS:
- (Maybe) we want to return not the Schema but the Model itself.
extended-service.ts.hbs:14 ({{tsResolverReturnType fn}})
TODO: - Required relations
- Make sure that Query is also supported
- Named relations
- bag.activeWorkout
- bag.workouts
- workout.bag
Long term TODO's - ValidationRules based on InputSchema - optional enums
How to use
Install
npm install @madxnl/madhatter-cliRun
npm madhatter generateBefore running it you need to create a config file in the root of your project.
Example config file:
modules:
- name: User
models:
- name: User
fields:
- "firstName: string"
- "lastName?: string"
- "email: @unique string"
- "lastLoggedIn?: Date"
- "emailVerified: boolean: false"
- "icon?: ~File"
- "teams: *Team[]"The above example would generate a User module, with a user.models.ts, user.service.ts, and user.resolver.ts file.
The User model would be defined as such:
@Entity()
export class User extends BaseModel {
_modelName = 'user'
@Column()
firstName: string
@Column({ nullable: true })
lastName: string
@Column({ unique: true })
email: string
@Column({ nullable: true })
lastLoggedIn: Date
@Column({ default: false })
emailVerified: boolean
@OneToOne(() => File, { nullable: true })
@JoinColumn()
icon: File
@ManyToMany(() => Team, o => o.users)
@JoinTable()
teams: Team[]
}The above example demonstrates how to:
- Distinguish between required and optional fields (
?sign) - Define a field as unique (
@unique) - Define a field with default value (
: false) - Define a relation explicitly as
OneToOneorManyToMany(@OneToOneand@ManyToMany)
In every other case the CLI will infer the type of relation (@OneToMany or @ManyToOne).
New version
npm version <nummer>
git push && git push --tagsUsage permission flow.
Convert .ts or .dart files to .graphql files:
#.ts
yarn run cli file-to-graphql example.ts
#.dart
yarn run cli file-to-graphql example.dart output/all.graphqlConvert directory of GraphQL, ts, and/or .dart files to a single GraphQL file:
yarn run cli folder-to-graphql ../goose-windows-app/GraphQLClient/ ./output/windows.graphql [graphql,ts,dart]Convert directory of GraphQL files to a single GraphQL file:
yarn run cli folder-to-graphql ../goose-windows-app/GraphQLClient/ ./output/windows.graphql [graphql]Convert Graphql to node permission list:
yarn run cli graphql-to-permissions output/all.graphql1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago