0.5.8 • Published 4 months ago

@madxnl/madhatter-cli v0.5.8

Weekly downloads
-
License
-
Repository
-
Last release
4 months ago

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-cli

Run

npm madhatter generate

Before 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 OneToOne or ManyToMany (@OneToOne and @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 --tags

Usage 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.graphql

Convert 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.graphql
0.5.8

4 months ago

0.5.7

5 months ago

0.5.6

5 months ago

0.5.5

5 months ago

0.5.4

11 months ago

0.5.3

11 months ago

0.5.2

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.5.0-beta.16

3 years ago

0.5.0-beta.15

3 years ago

0.3.0-beta.2

3 years ago

0.3.0-beta.1

3 years ago

0.2.0

3 years ago

0.2.0-beta.2

3 years ago