1.4.12 • Published 4 years ago

graphql-shortcake v1.4.12

Weekly downloads
35
License
MIT
Repository
github
Last release
4 years ago

GraphQL Shortcake

Class

  • Model
  • GlobalModel
  • Client
  • Row
  • buildDataSources

Preset Method

  • witholumn
  • withBuilder
  • withLoader
  • withFetcher
  • withMutator
  • withBatch
  • withDefaultValues
  • withGlobalId
  • withDataSources

Option Method

  • withSearcher
  • withArrayMutator
  • withJSONMutator
  • withIncrementer

Use Case

Sample Code

const client = new Client({
  host: '127.0.0.1',
  user: 'postgres',
  password: null,
  database: 'graphql_shortcake',
});

class User extends Model {
  static client = client;

  static tableName = 'user';

  static columns = {
    name: { type: String },
  }
}

const user = new User({ name: 'Apple Pie' });
await user.save();

Sample Code with Apollo Schema

const client = new Client({
  host: '127.0.0.1',
  user: 'postgres',
  password: null,
  database: 'graphql_shortcake',
});

class User extends GlobalModel {
  static client = client;

  static tableName = 'user';

  static columns = {
    name: { type: String },
  }
}

class Book extends GlobalModel {
  static client = client;

  static tableName = 'book';

  static columns = {
    name: { type: String },
  }
}

const DataSources = buildDataSources({
  UR: User,
  BK: Book,
});

const server = new ApolloServer(
  dataSources: () => new DataSources(),
});

Use mock

import { mock } from "graphql-shortcake";

const client = jest.requireActual("../client").default;

const mockClient = mock(client);

export default mockClient;

Column List

  • String
  • Number
  • Boolean
  • String
  • Hash
  • Model
  • Mixed
  • Expiratoin
  • DateTime.Dater
  • DateTime.Timer
  • DateTime
  • Enum

DataSources

  • const { User } = dataSources;
  const { fetcher } = User;
  fetcher.onFetch = dataSources.mount;
  • const { user } = dataSources;
  const user = new User({}, { dataSources });
  • const user = dataSources.loadUser(id);
  const model = await User.load(id);
  const user = Model.forge(model.previous, { dataSources });
1.4.12

4 years ago

1.4.11

4 years ago

1.4.10

4 years ago

1.4.9

4 years ago

1.6.0

4 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.8

5 years ago

1.4.7

5 years ago

1.4.6

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.1

5 years ago

1.3.0

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago