Create an awesome GraphQL API with typescript
Create a Graphql API in typescript with type-graphql and Typeorm
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-typescript
Then generate your new project:
yo graphql-typescript myapp
npm start
to preview and watch for changesnpm run build
to create the production versionnpm run test
to lauch jest testquery login(
input: $input
) {
... on LoginType {
__typename
token
}
... on UserError {
__typename
message
}
}
}
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 }
}
}
mutation {
register(
input: $input
) {
... on User {
__typename
username
email
}
... on UserError {
__typename
message
}
}
}
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
}
}
}
See the contributing docs.
MIT Clment Lafont