Skip to content

Releases: mizdra/graphql-codegen-typescript-fabbrica

v0.5.0

23 Mar 10:18
v0.5.0
7799678
Compare
Choose a tag to compare

Breaking Changes

New way to define transient fields

The way to define transient fields has been changed. defineXxxFactoryInternal is not exported now. Use defineXxxFactory.withTransientFields to define Transient Fields.

Before

import {
  defineAuthorFactoryInternal,
  dynamic,
  FieldsResolver,
  Traits,
  AuthorFactoryDefineOptions,
  AuthorFactoryInterface,
} from '../__generated__/fabbrica';
import { Author } from '../__generated__/types';

// Prepare custom `defineAuthorFactory` with transient fields
type AuthorTransientFields = {
  bookCount: number;
};
function defineAuthorFactoryWithTransientFields<
  _DefaultFieldsResolver extends FieldsResolver<Author & AuthorTransientFields>,
  _Traits extends Traits<Author, AuthorTransientFields>,
>(
  options: AuthorFactoryDefineOptions<AuthorTransientFields, _DefaultFieldsResolver, _Traits>,
): AuthorFactoryInterface<AuthorTransientFields, _DefaultFieldsResolver, _Traits> {
  return defineAuthorFactoryInternal(options);
}

// Use custom `defineAuthorFactory`
const AuthorFactory = defineAuthorFactoryWithTransientFields({
  defaultFields: {
    id: dynamic(({ seq }) => `Author-${seq}`),
    name: 'Komata Mikami',
    books: dynamic(async ({ get }) => {
      const bookCount = (await get('bookCount')) ?? 0;
      return BookFactory.buildList(bookCount);
    }),
    bookCount: 0,
  },
});

After

import {
  dynamic,
  FieldsResolver,
  Traits,
  AuthorFactoryDefineOptions,
  AuthorFactoryInterface,
} from '../__generated__/fabbrica';
import { Author } from '../__generated__/types';

const AuthorFactory = defineAuthorFactory.withTransientFields({
  bookCount: 0,
})({
  defaultFields: {
    id: dynamic(({ seq }) => `Author-${seq}`),
    name: 'Komata Mikami',
    books: dynamic(async ({ get }) => {
      const bookCount = (await get('bookCount')) ?? 0;
      return BookFactory.buildList(bookCount);
    }),
  },
});

What's Changed

Added

Changed

Others

  • Refactor transient fields implementation by @mizdra in #76
  • Format generated codes by @mizdra in #77

Full Changelog: v0.4.0...v0.5.0

v0.4.0

16 Mar 16:25
v0.4.0
6042048
Compare
Choose a tag to compare

What's Changed

Added

Fixed

  • Fix problem with interface and union fields not being optional by @mizdra in #70

Others

Full Changelog: v0.3.2...v0.4.0

v0.3.2

23 Jan 10:06
v0.3.2
9ac221a
Compare
Choose a tag to compare

What's Changed

Fixed

  • Fix issue that seq does not increment when using traits by @mizdra in #58

Full Changelog: v0.3.1...v0.3.2

v0.3.1

22 Jan 10:33
v0.3.1
d22839c
Compare
Choose a tag to compare

What's Changed

Fixed

  • Allow missing fields of nested field by @mizdra in #56

Full Changelog: v0.3.0...v0.3.1

v0.3.0

02 Oct 15:47
v0.3.0
3d51008
Compare
Choose a tag to compare

What's Changed

Changed

  • Rename nonOptionalFields to nonOptionalDefaultFields by @mizdra in #47
  • Rename package name from graphql-fabbrica to graphql-codegen-typescript-fabbrica by @mizdra in #49

Others

Full Changelog: v0.2.0...v0.3.0

v0.2.0

27 Sep 16:21
v0.2.0
8aa4d06
Compare
Choose a tag to compare

This release brings input support, Relay support, and improved compatibility with GraphQL Code Generator. In addition, the field passed to defaultFields can now be omitted, and several bugs have been fixed.

What's Changed

Added

  • Support namingConvention option by @mizdra in #35
  • Support typesPrefix option by @mizdra in #35
  • Support typesSuffix option by @mizdra in #35
  • Support input by @mizdra in #37
  • Embed type and field descriptions as comments by @mizdra in #38
  • Support __is<AbstractType> by @mizdra in #43
  • Support nonOptionalFields option by @mizdra in #45
  • Allow omitting fields to be passed to defaultFields by default by @mizdra in #45

Fixed

  • Object-typed custom scalar should not optional by @mizdra in #35
  • Fix problem with type name not changing by @mizdra in #36
  • Fix invalid type of __typename and __isAbstractType by @mizdra in #44
  • Do not treat the arguments of build method as const type by @mizdra in #46

Others

Full Changelog: v0.1.0...v0.2.0

v0.1.0

02 Sep 15:22
v0.1.0
f302d60
Compare
Choose a tag to compare

What's Changed

Added

  • defineTypeFactory, .build() and defaultFields by @mizdra in #2
  • Allow non-functional value and sync function for field resolvers by @mizdra in #3
  • Sequence by @mizdra in #4
  • Use sequence for input field resolvers by @mizdra in #5
  • Dependent Fields (get utility) by @mizdra in #9
  • Transient Fields by @mizdra in #12
  • Traits by @mizdra in #19
  • .buildList() by @mizdra in #22
  • Generate code from GraphQL schema (GraphQL Code Generator Plugin) by @mizdra in #23
  • Add skipTypename option by @mizdra in #27

Changed

Fixed

  • Make the argument of build method optional by @mizdra in #6
  • Fix array fields are correctly typed by @mizdra in #14
  • Accept readonly array as field by @mizdra in #15
  • Fix the return type of get by @mizdra in #18

Others

New Contributors

  • @mizdra made their first contribution in #2

Full Changelog: https://github.com/mizdra/graphql-fabbrica/commits/v0.1.0