node package manager
We need your input. Help make JavaScript better: Take the 2017 JavaScript Ecosystem survey »

graph-type-orm

GraphTypeORM

Library to GraphQL and TypeORM.

WARNING: This is draft version in beta!!

Usage

Example in NestJS:

import { findOne, findMany } from 'graph-type-orm';
 
@Resolver('Brand')
class BrandResolver {
    
    constructor(@Inject('BrandRepository') private readonly brandRepository: BrandRepository) {
    }
    
    @Query('allBrands')
    public async allBrands(source, args, context, info): Promise<Brand[]> {
        return await findMany<Brand>(this.brandRepository)(source, args, context, info);
    }
    
    @Query('Brand')
    public async brand(source, args, context, info): Promise<Brand | never> {
        const brand: Brand = await findOne<Brand>(this.brandRepository)(source, args, context, info);
        
        if (!brand) {
            throw new BrandNotFoundException();
        }
        
        return brand;
    }
      
}

Brand is Entity (TypeORM).

Of course, you should add to Graph schema specify inputs for allBrands and Brand query.

Features

...

People

License

MIT