Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
robak86 committed Jan 12, 2018
1 parent 75029b8 commit f81e965
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 29 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@
## 0.5.1
- add @defaultValue decorator


## 0.5.5
- add support for inheritance

49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,52 @@ type AudioAsset implements Asset {
length: Int
}
```

### Inheritance

```typescript
import {field, id, interfaceType, nonNull, type} from "gql-schema";
import {GraphQLInt, GraphQLString} from "graphql";

@type()
class PersistedObject {
@id() @nonNull()
id:string;

@field(GraphQLInt)
createdAt:number; //for simplification store as integer timestamp

@field(GraphQLInt)
updatedAt:number; //for simplification store as integer timestamp
}

@type()
class User extends PersistedObject {
@field(GraphQLString)
email:string
}

@type()
class Product extends PersistedObject {
@field(GraphQLString)
productName:string
}
```

Given annotated classes will produce

```graphql
type User {
id: ID!
createdAt: Int
updatedAt: Int
email: String
}

type Product {
id: ID!
createdAt: Int
updatedAt: Int
productName: String
}
```
30 changes: 1 addition & 29 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,5 @@
# ROADMAP

### Add support for inheritance
- investigate possible pitfalls

```typescript
class PersistedObject {
@id()
id:string

@field(CustomGraphQLDateScalar)
createdAt:Date

@field(CustomGraphQLDateScalar)
updatedAt:Date
}

@type()
class User extends PersistedObject {}
```

should generate:

```graphql
type User {
id: ID
createdAt: CustomGraphQLDateScalar
updateAt: CustomGraphQLDateScalar
}
```

### Reorganize, rewrite specs

### Infer basic types from ts metadata
Expand All @@ -39,6 +10,7 @@ type User {
- add validation of field configuration
- add more descriptive logs for all errors thrown from Metadata classes during native object creation
- assert one metadata object is attached to class
- print warnings if some @decarotors are skipped (for example @defaultValue for types other than input)

### Refactoring
- use one convention for private fields
Expand Down

0 comments on commit f81e965

Please sign in to comment.