Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit fa62e1a

Browse files
author
Enda
authored
feat: se parseMetadata syntax for annotations
BREAKING
1 parent 6dc1c42 commit fa62e1a

File tree

42 files changed

+264
-269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+264
-269
lines changed

docs/db/migrations.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ type Note {
205205
type Note {
206206
id: ID!
207207
"""
208-
@db.type: 'string'
209-
@db.length: 100
208+
@db(type: 'string', length: 100)
210209
"""
211210
title: String!
212211
}

docs/metadata.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,16 @@ type Comment {
114114

115115
| Argument | Description | Example |
116116
|-|-|-|
117-
|`field`| Specifies the name of resolver field on the foreign object. **Required**. Accepts a string value | `@oneToMany field: 'user'`|
118-
|`key`| Optionally specifies the name of foreign key field on the foreign object. Accepts a string value. Defaults to `<typeName>Id` | `@oneToMany field: 'user' key: 'user_key'`|
117+
|`field`| Specifies the name of resolver field on the foreign object. **Required**. Accepts a string value | `@oneToMany(field: 'user'`)|
118+
|`key`| Optionally specifies the name of foreign key field on the foreign object. Accepts a string value. Defaults to `<typeName>Id` | `@oneToMany(field: 'user', key: 'user_key')`|
119119

120120
#### Example
121121

122122
```graphql
123123
"""mode"""
124124
type User {
125125
id:ID!
126-
"""@oneToMany field: author"""
126+
"""@oneToMany(field: 'author')"""
127127
posts: [Post]
128128
}
129129
"""@model"""
@@ -151,7 +151,7 @@ type Post {
151151

152152
| Argument | Description | Example |
153153
|-|-|-|
154-
|`key`| Optionally specifies the name of foreign key field on the foreign object. Accepts a string value. Defaults to `<typeName>Id` | `@oneToMany field: 'user' key: 'user_key'`|
154+
|`key`| Optionally specifies the name of foreign key field on the foreign object. Accepts a string value. Defaults to `<typeName>Id` | `@oneToMany(field: 'user', key: 'user_key')`|
155155

156156
#### Example
157157

integration/mock.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ type Note {
44
title: String!
55
description: String
66
"""
7-
@oneToMany field: 'note'
7+
@oneToMany(field: 'note')
88
"""
99
comments: [Comment]!
1010
}

integration/tests/runtime-workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type Note {
2929
title: String!
3030
description: String
3131
"""
32-
@oneToMany field: 'note'
32+
@oneToMany(field: 'note')
3333
"""
3434
comments: [Comment]!
3535
}
Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11

2-
# """ @model """
3-
# type Note {
4-
# id: ID!
5-
# title: String!
6-
# description: String!
7-
# ## Relationship
8-
# comment: [Comment]!
9-
# }
2+
""" @model """
3+
type Note {
4+
id: ID!
5+
title: String!
6+
description: String!
7+
## Relationship
8+
"""
9+
@oneToMany(field: 'note')
10+
"""
11+
comment: [Comment]!
12+
}
1013

11-
# """ @model """
12-
# type Comment {
13-
# id: ID!
14-
# title: String!
15-
# description: String!
16-
# }
14+
""" @model """
15+
type Comment {
16+
id: ID!
17+
title: String!
18+
description: String!
19+
}

packages/graphback-cli/src/templates/resources/models/Note.graphql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ type Note {
33
id: ID!
44
title: String!
55
description: String!
6+
"""
7+
@oneToMany(field: 'note')
8+
"""
69
comments: [Comment]!
710
}
811

912
""" @model """
1013
type Comment {
1114
id: ID!
1215
text: String!
13-
}
16+
}

packages/graphback-cli/src/templates/resources/models/Shop.graphql

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@ type Shop {
33
id: ID!
44
name: String!
55
## Relationship
6+
"""
7+
@oneToMany(field: 'shops')
8+
"""
69
products: [Product]!
10+
"""
11+
@oneToMany(field: 'shops')
12+
"""
713
customers: [Person]!
14+
"""
15+
@oneToOne
16+
"""
817
owner: Person!
918
}
1019

@@ -19,4 +28,4 @@ type Product {
1928
id: ID!
2029
name: String!
2130
quantity: Int!
22-
}
31+
}

packages/graphback-cli/src/templates/resources/models/Tasks.graphql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ type Task {
66
description: String!
77
status: String!
88
creationMetadata: CreationMetadata
9+
"""
10+
@oneToOne
11+
"""
912
assignedTo: User
1013
}
1114

packages/graphback-codegen-client/tests/mock.graphql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ type Note {
44
title: String!
55
description: String!
66
"""
7-
@oneToMany field: 'noteComment', key: 'noteId'
7+
@oneToMany(field: 'noteComment', key: 'noteId')
88
"""
99
comments: [Comment]!
1010
}
@@ -15,7 +15,7 @@ type Comment {
1515
title: String!
1616
description: String!
1717
"""
18-
@manyToOne field: 'comments', key: 'noteId'
18+
@manyToOne(field: 'comments', key: 'noteId')
1919
"""
2020
noteComment: Note!
2121
}

packages/graphback-codegen-offix/tests/__snapshots__/OffixPluginTest.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type Comment {
77
title: String!
88
description: String!
99
10-
\\"\\"\\"@manyToOne field: 'comments', key: 'noteId'\\"\\"\\"
10+
\\"\\"\\"@manyToOne(field: 'comments', key: 'noteId')\\"\\"\\"
1111
noteComment: Note!
1212
version: Int
1313
}
@@ -22,7 +22,7 @@ type Note {
2222
title: String!
2323
description: String!
2424
25-
\\"\\"\\"@oneToMany field: 'noteComment', key: 'noteId'\\"\\"\\"
25+
\\"\\"\\"@oneToMany(field: 'noteComment', key: 'noteId')\\"\\"\\"
2626
comments: [Comment]!
2727
version: Int
2828
}

0 commit comments

Comments
 (0)