Peque GraphQL allows you to code your Apollo resolvers following an OOP/AOP flavor to better fit enterprise-level paradigms and patterns.
npm install @pequehq/graphql reflect-metadata
Note: tsconfig's compilerOptions
must have both experimentalDecorators
and emitDecoratorMetadata
set to true.
import { mergeResolvers } from '@graphql-tools/merge';
import { PequeGraphQL, Args, Query, Resolver } from '@pequehq/graphql';
@Resolver()
class ResolverExample {
@Query()
countries(@Args('continent') continent: string) {
return [
{ name: 'italy', continent: 'europe' },
{ name: 'spain', continent: 'europe' },
{ name: 'china', continent: 'asia' },
].filter((country) => country.continent === continent);
}
}
const resolvers = PequeGraphQL.build([new ResolverExample()]);
// Add resolvers to your Apollo Server config.
const apolloServer = new ApolloServer({
typeDefs,
resolvers: mergeResolvers(resolvers),
});
Please check out the documentation website.