Skip to content

Commit c0f53f9

Browse files
committed
nmerge three exmaples into one
1 parent d8d6cbe commit c0f53f9

15 files changed

+23
-170
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,15 @@ class Product {
174174

175175
## Compared to type-graphql
176176

177-
There is a much more popular [library](https://github.com/19majkel94/type-graphql) with the same goals-so what makes decapi different? Decapi has smaller API surface-it only has hooks on top of the basic decorators for constructing schemas.
178-
Whereas type-graphql has authorization, middleware, guards.
179-
Also decapi supports graphql v16. Typegraphql is still only supporting Graphql v15
177+
There is a much more popular [library](https://github.com/19majkel94/type-graphql) with the same goals-so what makes decapi different?
178+
179+
1. decapi does reflection through typescript-rtti, so it can infer 99% directly from typescript types without having to write them twice
180+
2. Decapi has smaller API surface-it only has hooks on top of the basic decorators for constructing schemas. Whereas type-graphql has authorization, middleware, guards.
181+
3. Also decapi supports graphql v16. Typegraphql is still only supporting Graphql v15
180182

181183
## Why forking?
182184

183-
I wanted to contribute to [typegql](https://github.com/prismake/typegql) and work on it together with @pie6k, but it soon became obvious that we both have something different in mind. Just to briefly summarise the differences:
185+
Initially I wanted to contribute to [typegql](https://github.com/prismake/typegql) and work on it together with @pie6k, but it soon became obvious that we both have something different in mind. Just to briefly summarize the differences:
184186

185187
- decapi has `@DuplexObjectType` and `@DuplexField`
186188
- decapi supports interfaces and mixins
@@ -189,9 +191,10 @@ I wanted to contribute to [typegql](https://github.com/prismake/typegql) and wor
189191
- InputObjectType argument passed to Field/Query method is not just a plain object, but an instance of it's class.
190192
- decapi allows you to have an empty object type-you can populate it with fields at runtime
191193

192-
## Before `1.0.0`
194+
## Upgrading from 1.0.0 to 2.0.0
193195

194-
Before version `1.0.0` consider APIs of `decapi` to be subject to change. We encourage you to try this library out and provide us feedback so we can polish it to be as usable and efficent as possible.
196+
This major was a complete rewrite of the reflection of types. From 2.0.0 decapi uses typescript-rtti to infer graphql types from typescript. This works for 99% of TS types.
197+
This means you should always have your decorators without explicit `type` property.
195198

196199
## TC39 decorators proposal
197200

examples/basic-express-server/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/basic-express-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dependencies": {
77
"apollo-server-core": "^3.6.7",
88
"apollo-server-express": "^3.6.7",
9-
"decapi": "^2.0.0-beta.1",
9+
"decapi": "^2.0.0-beta.2",
1010
"express": "^4.17.3",
1111
"graphql": "^16.3.0",
1212
"ts-node": "^10.7.0",

examples/basic-express-server/schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { SchemaRoot, Query, compileSchema } from 'decapi'
2+
import { MySchemaCustomDecorators } from './schemaWithCustomDecorators'
23

34
@SchemaRoot()
45
class MySchema {
@@ -8,4 +9,4 @@ class MySchema {
89
}
910
}
1011

11-
export const schema = compileSchema(MySchema)
12+
export const schema = compileSchema([MySchema, MySchemaCustomDecorators])

examples/custom-decorators/schema.ts renamed to examples/basic-express-server/schemaWithCustomDecorators.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CustomObject {
2323
}
2424

2525
@SchemaRoot()
26-
class MySchema {
26+
export class MySchemaCustomDecorators {
2727
@Query()
2828
getCustomObject(stringValue: string): CustomObject {
2929
const object = new CustomObject()
@@ -32,4 +32,6 @@ class MySchema {
3232
}
3333
}
3434

35-
export const schema = compileSchema(MySchema)
35+
export const schemaWithCustomDecorators = compileSchema(
36+
MySchemaCustomDecorators
37+
)

examples/custom-decorators/README.md

Lines changed: 0 additions & 35 deletions
This file was deleted.

examples/custom-decorators/index.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

examples/custom-decorators/package.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

examples/custom-decorators/tsconfig.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/merge-schemas/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/merge-schemas/index.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/merge-schemas/package.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

examples/merge-schemas/schemaA.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/merge-schemas/schemaB.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/merge-schemas/tsconfig.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)