with-provider.ts 761 B

12345678910111213141516171819202122232425262728293031323334
  1. import { Injectable } from '@nestjs/common';
  2. import { Query, Resolver } from '@nestjs/graphql';
  3. import { VendurePlugin } from '@vendure/core';
  4. import gql from 'graphql-tag';
  5. @Injectable()
  6. export class NameService {
  7. getNames(): string[] {
  8. return ['seon', 'linda', 'hong'];
  9. }
  10. }
  11. @Resolver()
  12. export class TestResolverWithInjection {
  13. constructor(private nameService: NameService) {}
  14. @Query()
  15. names() {
  16. return this.nameService.getNames();
  17. }
  18. }
  19. @VendurePlugin({
  20. providers: [NameService],
  21. shopApiExtensions: {
  22. resolvers: [TestResolverWithInjection],
  23. schema: gql`
  24. extend type Query {
  25. names: [String]!
  26. }
  27. `,
  28. },
  29. })
  30. export class TestPluginWithProvider {}