Skip to content

Commit 70c8b57

Browse files
committed
fixes examples, bumps version
1 parent 11b0319 commit 70c8b57

File tree

29 files changed

+6862
-106
lines changed

29 files changed

+6862
-106
lines changed

docs/getting-started/setup.mdx

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ order: 2
55

66
# Installation and setup
77

8-
Firstly, add `decapi` to your project
8+
Firstly, add `decapi` and it's peer dependecies to your project
99

1010
```
1111
yarn add decapi graphql reflect-metadata
@@ -15,7 +15,7 @@ yarn add decapi graphql reflect-metadata
1515

1616
Add `import "reflect-metadata";` somewhere in bootstrap (before any `decapi` decorator is used) of your app eg `app/index.ts`.
1717

18-
## Modify `tsconfig.json`
18+
## Configuring `tsconfig.json`
1919

2020
`decapi` will try to infer types of your fields, when possible. To allow this, you'll have to add following to your `tsconfig.json` `compilerOptions` section:
2121

@@ -24,6 +24,9 @@ Add `import "reflect-metadata";` somewhere in bootstrap (before any `decapi` dec
2424
"experimentalDecorators": true,
2525
```
2626

27+
Also you need to target `es6` or newer target in your `compilerOptions`.
28+
**Important!** `es5` target will not work correctly. ObjectTypes type inference only currently works for es6 or newr targets.
29+
2730
## Does `decapi` work without typescript?
2831

2932
It absolutely does. Keep in mind, however - without typescript all types will have to be defined explicitly.

examples/basic-express-server/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"main": "index.js",
55
"license": "MIT",
66
"dependencies": {
7-
"express": "^4.16.3",
8-
"express-graphql": "^0.6.12",
9-
"ts-node": "^6.0.0",
10-
"decapi": "^0.4.0",
11-
"typescript": "^2.8.1"
7+
"express": "^4.16.4",
8+
"express-graphql": "^0.7.1",
9+
"ts-node": "^8.0.2",
10+
"decapi": "^0.7.19",
11+
"typescript": "^3.3.3333"
1212
},
1313
"scripts": {
1414
"start": "ts-node index.ts"

examples/basic-express-server/schema.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Schema, Query, compileSchema } from 'decapi'
1+
import { SchemaRoot, Query, compileSchema } from 'decapi'
22

3-
@Schema()
3+
@SchemaRoot()
44
class MySchema {
55
@Query()
66
hello(name: string): string {

examples/custom-decorators/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"main": "index.js",
55
"license": "MIT",
66
"dependencies": {
7-
"express": "^4.16.3",
8-
"express-graphql": "^0.6.12",
9-
"ts-node": "^6.0.0",
10-
"decapi": "^0.4.0",
11-
"typescript": "^2.8.1"
7+
"express": "^4.16.4",
8+
"express-graphql": "^0.7.1",
9+
"ts-node": "^8.0.2",
10+
"decapi": "^0.7.19",
11+
"typescript": "^3.3.3333"
1212
},
1313
"scripts": {
1414
"start": "ts-node index.ts"

examples/custom-decorators/schema.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Schema, Query, Field, ObjectType, compileSchema } from 'decapi'
1+
import { SchemaRoot, Query, Field, ObjectType, compileSchema } from 'decapi'
22

33
function StringWithDescription(additionalDescription: string) {
44
return Field({
@@ -22,7 +22,7 @@ class CustomObject {
2222
stringValue: string
2323
}
2424

25-
@Schema()
25+
@SchemaRoot()
2626
class MySchema {
2727
@Query()
2828
getCustomObject(stringValue: string): CustomObject {

examples/forward-resolution/index.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import express from 'express'
22
import { GraphQLResolveInfo } from 'graphql'
33
import getFieldNames from 'graphql-list-fields'
4-
import { Schema, Query, ObjectType, Field, Inject, compileSchema } from 'decapi'
4+
import {
5+
SchemaRoot,
6+
Query,
7+
ObjectType,
8+
Field,
9+
Inject,
10+
compileSchema
11+
} from 'decapi'
512
import graphqlHTTP from 'express-graphql'
613

714
function NeededFields(filter: string[] = []) {
@@ -44,7 +51,7 @@ class LazyObject {
4451
}
4552
}
4653

47-
@Schema()
54+
@SchemaRoot()
4855
class SuperSchema {
4956
@Query()
5057
foo(

examples/forward-resolution/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"main": "index.js",
55
"license": "MIT",
66
"dependencies": {
7-
"express": "^4.16.3",
8-
"express-graphql": "^0.6.12",
7+
"express": "^4.16.4",
8+
"express-graphql": "^0.7.1",
99
"graphql-list-fields": "^2.0.2",
10-
"ts-node": "^6.0.0",
11-
"decapi": "^0.4.0",
12-
"typescript": "^2.8.1"
10+
"ts-node": "^8.0.2",
11+
"decapi": "^0.7.19",
12+
"typescript": "^3.3.3333"
1313
},
1414
"scripts": {
1515
"start": "ts-node index.ts"
File renamed without changes.

examples/merge-schemas/package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"main": "index.js",
55
"license": "MIT",
66
"dependencies": {
7-
"express": "^4.16.3",
8-
"express-graphql": "^0.6.12",
9-
"graphql-tools": "^2.24.0",
10-
"ts-node": "^6.0.0",
11-
"decapi": "^0.4.0",
12-
"typescript": "^2.8.1"
7+
"express": "^4.16.4",
8+
"express-graphql": "^0.7.1",
9+
"graphql-tools": "^4.0.4",
10+
"ts-node": "^8.0.2",
11+
"decapi": "^0.7.19",
12+
"typescript": "^3.3.3333"
1313
},
1414
"scripts": {
1515
"start": "ts-node index.ts"

examples/merge-schemas/schemaA.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Schema, Query, compileSchema } from 'decapi'
1+
import { SchemaRoot, Query, compileSchema } from 'decapi'
22

3-
@Schema()
3+
@SchemaRoot()
44
class SchemaA {
55
@Query()
66
foo(name: string): string {

examples/merge-schemas/schemaB.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Schema, Query, compileSchema } from 'decapi'
1+
import { SchemaRoot, Query, compileSchema } from 'decapi'
22

3-
@Schema()
3+
@SchemaRoot()
44
class SchemaB {
55
@Query()
66
hello(name: string): string {

examples/nested-mutation-or-query/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"main": "index.js",
55
"license": "MIT",
66
"dependencies": {
7-
"class-transformer": "^0.1.10",
8-
"decapi": "^0.6.10",
7+
"class-transformer": "^0.2.0",
8+
"decapi": "^0.7.19",
99
"express": "^4.16.4",
1010
"express-graphql": "^0.7.1",
11-
"ts-node": "^7.0.1",
12-
"typescript": "^3.1.3"
11+
"ts-node": "^8.0.2",
12+
"typescript": "^3.3.3333"
1313
},
1414
"scripts": {
1515
"start": "ts-node index.ts"
File renamed without changes.

examples/serverless/handler.ts

+7-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Schema, Query, compileSchema } from 'decapi'
2-
import { graphqlLambda, graphiqlLambda } from 'apollo-server-lambda'
1+
import { SchemaRoot, Query, compileSchema } from 'decapi'
2+
import { ApolloServer } from 'apollo-server-lambda'
33

4-
@Schema()
4+
@SchemaRoot()
55
class MySchema {
66
@Query()
77
hello(name: string): string {
@@ -10,14 +10,8 @@ class MySchema {
1010
}
1111

1212
const schema = compileSchema(MySchema)
13+
const server = new ApolloServer({ schema, tracing: true })
14+
const handler = server.createHandler()
1315

14-
export function graphqlHandler(event, context, callback) {
15-
function callbackFilter(error, output) {
16-
output.headers['Access-Control-Allow-Origin'] = '*'
17-
callback(error, output)
18-
}
19-
const handler = graphqlLambda({ schema, tracing: true })
20-
return handler(event, context, callbackFilter)
21-
}
22-
23-
export const graphiqlHandler = graphiqlLambda({ endpointURL: '/graphql' })
16+
export const graphiqlHandler = handler
17+
export const graphqlHandler = handler

0 commit comments

Comments
 (0)