0.19.44 • Published 4 months ago

sasat v0.19.44

Weekly downloads
3
License
MIT
Repository
github
Last release
4 months ago

Sasat

rdb migration based graphql source code generator. resolve relations without N + 1.

getting stared

$ npm i sasat
$ npm run sasat init

commands

# make migration file
$ npm sasat migration:create ${migration name}

# generate file
$ npm sasat generate

# migrate
$ npm sasat migrate

config file

projectroot/sasat.yml

migration:
  dir:   # migration file dir
  table: # migration table name
  out:   # generate file output dir
generator:
  addJsExtToImportStatement: # add `.js` ext to import statement when this value is true
db:
  host: # if value starts with `$` read from environment variable. (e.g. $DB_HOST => process.env.DB_HOST)
  port:
  user:
  password:
  database:

migration

  • 1_ create migration file `$npm sasat migration:create ${migration name}
  • 2_ edit migration file
// sample migraiton
import {
  Queries,
  SasatMigration,
  MigrationStore,
  Conditions,
  Mutations,
} from '../../src/index.js';

export default class CreateUser implements SasatMigration {
  up: (store: MigrationStore) => void = store => {
    return store.createTable('user' /* tableName */, table => {
      table.autoIncrementHashId('userId'); // create userId column primary key
      table
        .column('name')
        .varchar(20)
        .default('no name')
        .notNull();
      table
        .column('nickName')
        .varchar(20)
        .nullable()
        .unique();
      table.createdAt().updatedAt();
      table.enableGQL(); // enable Graphql
      table.addGQLQuery(
        Queries.primary(), // add query
      );
      table.addGQLMutation(
        Mutations.create(), // add create mutation
      );
    });
  };
  down: (store: MigrationStore) => void = store => {
    store.dropTable('user');
  };
}
  • 3_ run $ npm run sasat migrate -g
  • 4_ add server file
import { ApolloServer } from '@apollo/server';
import { resolvers } from './out/__generated__/resolver.js';
import { inputs, typeDefs } from './out/__generated__/typeDefs.js';
import { createTypeDef } from 'sasat';
import { startStandaloneServer } from '@apollo/server/standalone';

const server = new ApolloServer<Context>({
  typeDefs: createTypeDef(typeDefs, inputs),
  resolvers,
});

const { url } = await startStandaloneServer(server, { listen: { port: 4000 } });
console.log(`🚀 Server ready at ${url}`);
  • 5_ run server!
0.19.44

4 months ago

0.19.40

4 months ago

0.19.41

4 months ago

0.19.42

4 months ago

0.19.43

4 months ago

0.19.37

6 months ago

0.19.38

6 months ago

0.19.39

6 months ago

0.19.22

10 months ago

0.19.23

10 months ago

0.19.24

10 months ago

0.19.25

9 months ago

0.19.27

9 months ago

0.19.28

9 months ago

0.19.29

9 months ago

0.19.20

11 months ago

0.19.21

10 months ago

0.19.33

8 months ago

0.19.34

8 months ago

0.19.35

8 months ago

0.19.36

8 months ago

0.19.30

8 months ago

0.19.31

8 months ago

0.19.32

8 months ago

0.19.17

11 months ago

0.19.18

11 months ago

0.19.19

11 months ago

0.19.12

1 year ago

0.19.13

1 year ago

0.19.14

1 year ago

0.19.15

1 year ago

0.19.16

1 year ago

0.17.2

1 year ago

0.17.3

1 year ago

0.17.4

1 year ago

0.17.5

1 year ago

0.17.0

1 year ago

0.17.1

1 year ago

0.18.1

1 year ago

0.18.2

1 year ago

0.18.3

1 year ago

0.18.4

1 year ago

0.18.5

1 year ago

0.18.0

1 year ago

0.19.8

1 year ago

0.19.9

1 year ago

0.19.0

1 year ago

0.19.1

1 year ago

0.19.2

1 year ago

0.19.3

1 year ago

0.19.4

1 year ago

0.19.5

1 year ago

0.19.6

1 year ago

0.19.7

1 year ago

0.16.3

1 year ago

0.16.0

1 year ago

0.16.1

1 year ago

0.16.2

1 year ago

0.19.11

1 year ago

0.19.10

1 year ago

0.14.13

2 years ago

0.14.12

2 years ago

0.14.14

2 years ago

0.15.0

2 years ago

0.15.1

2 years ago

0.15.2

2 years ago

0.14.11

2 years ago

0.14.10

2 years ago

0.14.8

2 years ago

0.14.9

2 years ago

0.14.5

2 years ago

0.14.6

2 years ago

0.14.7

2 years ago

0.14.0

2 years ago

0.14.1

2 years ago

0.14.2

2 years ago

0.14.3

2 years ago

0.14.4

2 years ago

0.13.7

4 years ago

0.13.6

4 years ago

0.13.5

4 years ago

0.12.4

4 years ago

0.13.1

4 years ago

0.13.2

4 years ago

0.13.3

4 years ago

0.13.4

4 years ago

0.13.0

4 years ago

0.12.2

4 years ago

0.12.3

4 years ago

0.12.0

4 years ago

0.12.1

4 years ago

0.11.1

4 years ago

0.11.0

4 years ago

0.10.0

4 years ago

0.9.0

4 years ago

0.8.4

4 years ago

0.8.3

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.8.2

4 years ago

0.7.6

4 years ago

0.7.5

4 years ago

0.7.4

4 years ago

0.7.3

4 years ago

0.7.2

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.4

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.9

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago