Skip to content

Releases: Adrinalin4ik/Nestjs-Graphql-Tools

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

Version 0.7.20

03 Jul 05:55
Compare
Choose a tag to compare
  • Bump deps

Version 0.7.(18 - 19)

13 Jun 05:32
Compare
Choose a tag to compare
  • Vulnurability fixes

Version 0.7.17

05 May 11:59
Compare
Choose a tag to compare
  • Added ability to override decorators' values. This might be useful for unit tests.

Version 0.7.16

18 Apr 14:23
Compare
Choose a tag to compare
  • Removed the necessity of having the second argument in the FilterField decorator.
  • Typeform bumped.