1.0.6 • Published 2 years ago

@pequehq/graphql v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Peque GraphQL

CI coverage

Peque GraphQL is an OOP transposition for Apollo Server Resolver.

Install

npm install @pequehq/graphql reflect-metadata

Note: tsconfig's compilerOptions must have both experimentalDecorators and emitDecoratorMetadata set to true.

Example

import { Resolver, ResolverService } from '@pequehq/graphql';

@Resolver()
class ResolverExample {
  @Query()
  countries(@Args('continent') continent: string): unknown {
    return [
      { id: 1, name: 'italy', continent: 'europe' },
      { id: 2, name: 'spain', continent: 'europe' },
      { id: 3, name: 'china', continent: 'asia' },
    ].filter((country) => country.continent === continent);
  }
}

const resolverService = new ResolverService();

const resolvers = resolverService.get([new ResolverExample()]);

// Add resolvers to your Apollo Server integration.