2.0.0 • Published 6 years ago
generator-graphql-typescript v2.0.0
generator-graphql-typescript

Create a Graphql API in typescript with type-graphql and Typeorm

Installation
First, install Yeoman and generator-rest-express-typescript using npm (we assume you have pre-installed node.js).
npm install -g yo
npm install -g generator-graphql-typescriptThen generate your new project:
yo graphql-typescript myappGetting Started
- Run
npm startto preview and watch for changes - Run
npm run buildto create the production version - Run
npm run testto lauch jest test
Queries
Login
query login(
input: $input
) {
... on LoginType {
__typename
token
}
... on UserError {
__typename
message
}
}
}Get projects
You need to put the token you get from the login query to perform this query. Prefix the authorization header with bearer.
{
"Authorization": "bearer thetoken"
}query {
projects {
name,
owner { email }
}
} Mutations
Register
mutation {
register(
input: $input
) {
... on User {
__typename
username
email
}
... on UserError {
__typename
message
}
}
}Add project
You need to put the token you get from the login query to perform this query. Prefix the authorization header with bearer.
{
"Authorization": "bearer thetoken"
}mutation {
createProject(
input: $input
) {
__typename
... on Project {
name
}
... on UserError {
message
}
}
}TODO 🚧
- Add subcommand to create a new resolver
Contribute
See the contributing docs.
License
MIT © Clément Lafont