Skip to content

Releases: Adrinalin4ik/Nestjs-Graphql-Tools

Version 0.10.2

05 Nov 05:58
Compare
Choose a tag to compare
  • Fixed issue related to exclusion of filter and sorting. The issue is described here #48
  • Vulnerability fixes. Bumped all the dependencies.

Version 0.10.1

06 Sep 10:53
Compare
Choose a tag to compare
  • Fix queries without filters
  • Vulnerability fixes

Version 0.10.0

13 Aug 08:28
Compare
Choose a tag to compare
  • Added support of nested filters (proposal: #42)
  • Dependencies upgrade

Now is allowed to use nested filters like this

{
  users(where: {
    and: {
      id: {eq: 1}
      or: {
        and: {
          id: {eq: 2}
          email: {like: "123"}
        }
        is_active: { eq: true }
        id: { eq: 3 }
      }
    }
  }) {
    id
    email
  }
}

Version 0.9.1

07 Jun 06:46
Compare
Choose a tag to compare
  • Updated dependencies
  • Added feature presented in the issue #34
  • Added raw filters and sorting

Raw filters

Raw filters allow to get access to the user provided raw value right from the code. This feature allows to build your own filters interpreters.

How to use raw filters:

  1. Add @Filter({ raw: true }) parameter with type of RawFilterArgs<T> where T is your filter type
  2. @Filter() will return raw filter data.
@Query(() => [UserObjectType])
async usersRaw(
  @Filter(() => [UserObjectType, UserFilterInputType], {sqlAlias: 'u', raw: true}) filter: RawFilterArgs<UserObjectType & UserFilterInputType>,
  @Paginator() paginator: PaginatorArgs
) {
  // Your customer filter logic..
  return [];
}

Raw sorting

Raw sorting allows to get access to the user provided raw value right from the code. This feature allows to build your own sorting interpreters.

How to use raw filters:

  1. Add @Sorting({ raw: true }) parameter with type of RawSortingArgs<T> where T is your filter type
  2. @Sorting() will return raw sorting data.
@Query(() => [UserObjectType])
async usersRaw(
  @Sorting(() => [UserObjectType], { sqlAlias: 'u', raw: true}) sorting: RawSortingArgs<UserObjectType>,
  @Paginator() paginator: PaginatorArgs
) {
  // Your customer filter logic..
  return [];
}

Version 0.9.0

26 Dec 10:07
Compare
Choose a tag to compare
  • Fixed enums for custom filters
  • Added simple automated tests
  • Fixed errors related to sqlite3

Migration guide

  • All custom filters should be decorated with @InputType()

Version 0.8.3

06 Oct 04:52
Compare
Choose a tag to compare
  • Fix vulnurabilities

Version 0.8.2

12 Sep 07:50
Compare
Choose a tag to compare
  • Upgrade deps
  • Vulns fixes

Version 0.8.1

12 Sep 07:49
Compare
Choose a tag to compare

Federation support

Basic support of federation already in place. Just add to your method with @ResolveReference() one more decorator @GraphqlLoader()

Example

This examples is the reference to official example https://github.com/nestjs/nest/tree/master/sample/31-graphql-federation-code-first. Clone https://github.com/nestjs/nest/tree/master/sample/31-graphql-federation-code-first (download specific directory with https://download-directory.github.io/ or with chrome extention https://chrome.google.com/webstore/detail/gitzip-for-github/ffabmkklhbepgcgfonabamgnfafbdlkn)

  1. Annotate method resolveReference of users-application/src/users/users.resolver.ts
// users-application/src/users/users.resolver.ts
@ResolveReference()
@GraphqlLoader()
async resolveReference(
   @Loader() loader: LoaderData<User, number>,
) {
 const ids = loader.ids;
 const users = this.usersService.findByIds(ids);
 return loader.helpers.mapManyToOneRelation(users, loader.ids, 'id')
}
  1. Add method findByIds to users-application/src/users/users.service.ts
// users-application/src/users/users.service.ts
@Injectable()
export class UsersService {
  private users: User[] = [
    { id: 1, name: 'John Doe' },
    { id: 2, name: 'Richard Roe' },
  ];

  findByIds(idsList: number[]): User[] {
    return this.users.filter((user) => idsList.some(id => Number(id) === user.id));
  }
}
  1. Install dependencies of 3 projects : npm ci in gateway, posts-application, users-application.

  2. Run all projects in order :

    • cd users-application && npm run start
    • cd posts-application && npm run start
    • cd gateway && npm run start
  3. Go to localhost:3001/graphql and send graphql request to gateway

{
  posts {
    id
    title
    authorId
    user {
      id
      name
    }
  }
}

Version 0.8.0

04 Sep 16:34
Compare
Choose a tag to compare
  • Updated deps
  • @GraphqlFilter and @GraphqlSorting method decorators are no longer required and marked as deprecated. These decorators will be removed soon.
  • @filter decorator now has it's own type FilterArgs. It should be used insted of Brackets in all the cases.
  • Fixed problem related to global pipes like ValidationPipe. This problem happened because pipe created dummy model based on types provided for the @filter decorator (it was typeorm Brakets). Please use FilterArgs type insted of Brackets to avoid this bug.

Version 0.7.21

22 Aug 05:42
Compare
Choose a tag to compare
  • Vulnurabilities fixes
  • Upgraded all the dev deps to be the latest
  • Npm replaced with yarn