https://github.com/aerographql/aerographql
A small and opinionated Typescript toolkit to create GraphQL server using a declarative approach
https://github.com/aerographql/aerographql
graphql nodejs server typescript
Last synced: 3 months ago
JSON representation
A small and opinionated Typescript toolkit to create GraphQL server using a declarative approach
- Host: GitHub
- URL: https://github.com/aerographql/aerographql
- Owner: aerographql
- Created: 2018-02-09T11:07:48.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-11T10:08:30.000Z (about 8 years ago)
- Last Synced: 2025-10-06T12:49:40.154Z (6 months ago)
- Topics: graphql, nodejs, server, typescript
- Language: TypeScript
- Homepage: https://aerographql.github.io/documentation/
- Size: 367 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome - aerographql/aerographql - A small and opinionated Typescript toolkit to create GraphQL server using a declarative approach (<a name="TypeScript"></a>TypeScript)
README
[](https://travis-ci.org/aerographql/aerographql)
[](https://coveralls.io/github/aerographql/aerographql?branch=master)
[](https://badge.fury.io/js/aerographql)
[](https://opensource.org/licenses/MIT)
**[AeroGraphQL](https://aerographql.github.io/documentation/)** is a small and opinionated [Typescript](https://www.typescriptlang.org/index.html) toolkit to create [GraphQL](http://graphql.org/learn/) 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
```typescript
@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 {
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](https://www.apollographql.com/docs/apollo-server/) with [Express](http://expressjs.com/fr/) in this case:
```typescript
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](https://aerographql.github.io/documentation/)** and explore **[basic examples](https://github.com/aerographql/examples)**.
# License
AeroGraphQL is freely distributable under the terms of the MIT license.