Get unlimited public & private packages + team-based management with npm Teams.Learn more »

aerographql

0.0.33 • Public • Published

Build Status Coverage Status npm version License: MIT

AeroGraphQL is a small and opinionated Typescript toolkit to create GraphQL server using a declarative approach.

Overview

Install AeroGraphQL

yarn add aerographql

Note that graphql is a needed peer dependency, you must install it beforehand

Define your schema

@ObjectDefinition( { name: 'User' } )
export class User {
    @Field( { type: 'ID' } ) id: string;
    @Field( ) name: String;
    @Field( { nullable: true }) description: String;
}
 
@ObjectImplementation( { name: 'RootQuery' } )
export class RootQuery {
    constructor( private userService: UserService ) { }
 
    @Resolver( { type: User } )
    user( @Arg() name: string ): User | Promise<User> {
        return this.userService.find( name );
    }
}
 
@Schema( {
    rootQuery: 'RootQuery',
    components: [ RootQuery, User ]
} )
export class MySchema extends BaseSchema {
}

Inject the schema within a GraphQL server

Apollo Server with Express in this case:

let mySchema = new MySchema();
this.app = express();
this.app.use( '/graphql', bodyParser.json(), graphqlExpress( { schema: mySchema.graphQLSchema } );
this.app.listen( config.get( 'server.port' ), () => {
    console.log( 'Up and running !' );
} );

Documentation

Checkout the AeroGraphQL documentation and explore basic examples.

License

AeroGraphQL is freely distributable under the terms of the MIT license.

Install

npm i aerographql

DownloadsWeekly Downloads

0

Version

0.0.33

License

MIT

Unpacked Size

314 kB

Total Files

187

Last publish

Collaborators

  • avatar