|
1 | 1 | import { a, ClientSchema } from '@aws-amplify/data-schema'; |
2 | | -import { __modelMeta__ } from '@aws-amplify/data-schema-types'; |
3 | | -import { configure } from '@aws-amplify/data-schema/internals'; |
| 2 | +import { __modelMeta__, Prettify } from '@aws-amplify/data-schema-types'; |
| 3 | +import { GraphQLFormattedError } from '@aws-amplify/data-schema/runtime'; |
4 | 4 |
|
5 | | -const schema = configure({ |
6 | | - database: { engine: 'mysql', connectionUri: {} as any }, |
7 | | -}).schema({ |
8 | | - Post: a.model({ |
9 | | - title: a.string().required(), |
10 | | - description: a.string(), |
11 | | - location: a.ref('Location').required(), |
12 | | - }), |
| 5 | +const masterType = { |
| 6 | + id: a.id().required(), |
| 7 | + name: a.string().required(), |
| 8 | + type: a.string().required(), |
| 9 | + sort: a.integer().required(), |
| 10 | +}; |
13 | 11 |
|
14 | | - Location: a.customType({ |
15 | | - lat: a.float(), |
16 | | - long: a.float(), |
17 | | - }), |
18 | | -}); |
| 12 | +const schema = a |
| 13 | + .schema({ |
| 14 | + Network: a |
| 15 | + .model({ |
| 16 | + ...masterType, |
| 17 | + articles: a.hasMany('Article', 'networkId'), |
| 18 | + }) |
| 19 | + .secondaryIndexes((index) => [ |
| 20 | + index('type').sortKeys(['sort']).queryField('networkListByTypeAndId'), |
| 21 | + ]), |
| 22 | + Category: a |
| 23 | + .model({ |
| 24 | + ...masterType, |
| 25 | + articles: a.hasMany('Article', 'categoryId'), |
| 26 | + }) |
| 27 | + .secondaryIndexes((index) => [ |
| 28 | + index('type').sortKeys(['sort']).queryField('categoryListByTypeAndId'), |
| 29 | + ]), |
| 30 | + Season: a |
| 31 | + .model({ |
| 32 | + ...masterType, |
| 33 | + articles: a.hasMany('Article', 'seasonId'), |
| 34 | + }) |
| 35 | + .secondaryIndexes((index) => [ |
| 36 | + index('type').sortKeys(['sort']).queryField('seasonListByTypeAndId'), |
| 37 | + ]), |
| 38 | + Person: a |
| 39 | + .model({ |
| 40 | + ...masterType, |
| 41 | + articleCasts: a.hasMany('ArticleCast', 'personId'), |
| 42 | + articleAuthors: a.hasMany('ArticleAuthor', 'personId'), |
| 43 | + articleDirectors: a.hasMany('ArticleDirector', 'personId'), |
| 44 | + articleProducers: a.hasMany('ArticleProducer', 'personId'), |
| 45 | + articleScreenwriters: a.hasMany('ArticleScreenwriter', 'personId'), |
| 46 | + articleOriginalWorks: a.hasMany('ArticleOriginalWork', 'personId'), |
| 47 | + image: a.string(), |
| 48 | + }) |
| 49 | + .secondaryIndexes((index) => [ |
| 50 | + index('type').sortKeys(['sort']).queryField('personListByTypeAndId'), |
| 51 | + ]), |
| 52 | + ArticleVod: a |
| 53 | + .model({ |
| 54 | + articleId: a.id().required(), |
| 55 | + vodId: a.id().required(), |
| 56 | + vod: a.belongsTo('Vod', 'vodId'), |
| 57 | + article: a.belongsTo('Article', 'articleId'), |
| 58 | + }) |
| 59 | + .identifier(['articleId', 'vodId']), |
| 60 | + Vod: a |
| 61 | + .model({ |
| 62 | + ...masterType, |
| 63 | + articles: a.hasMany('ArticleVod', 'vodId'), |
| 64 | + microcopy: a.string(), |
| 65 | + url: a.string(), |
| 66 | + }) |
| 67 | + .secondaryIndexes((index) => [ |
| 68 | + index('type').sortKeys(['sort']).queryField('vodListByTypeAndId'), |
| 69 | + ]), |
| 70 | + ArticleCast: a |
| 71 | + .model({ |
| 72 | + articleId: a.id().required(), |
| 73 | + personId: a.id().required(), |
| 74 | + roleName: a.string().required(), |
| 75 | + person: a.belongsTo('Person', 'personId'), |
| 76 | + article: a.belongsTo('Article', 'articleId'), |
| 77 | + }) |
| 78 | + .identifier(['articleId', 'personId']), |
| 79 | + ArticleAuthor: a |
| 80 | + .model({ |
| 81 | + articleId: a.id().required(), |
| 82 | + personId: a.id().required(), |
| 83 | + person: a.belongsTo('Person', 'personId'), |
| 84 | + article: a.belongsTo('Article', 'articleId'), |
| 85 | + }) |
| 86 | + .identifier(['articleId', 'personId']), |
| 87 | + ArticleDirector: a |
| 88 | + .model({ |
| 89 | + articleId: a.id().required(), |
| 90 | + personId: a.id().required(), |
| 91 | + person: a.belongsTo('Person', 'personId'), |
| 92 | + article: a.belongsTo('Article', 'articleId'), |
| 93 | + }) |
| 94 | + .identifier(['articleId', 'personId']), |
| 95 | + ArticleProducer: a |
| 96 | + .model({ |
| 97 | + articleId: a.id().required(), |
| 98 | + personId: a.id().required(), |
| 99 | + person: a.belongsTo('Person', 'personId'), |
| 100 | + article: a.belongsTo('Article', 'articleId'), |
| 101 | + }) |
| 102 | + .identifier(['articleId', 'personId']), |
| 103 | + ArticleScreenwriter: a |
| 104 | + .model({ |
| 105 | + articleId: a.id().required(), |
| 106 | + personId: a.id().required(), |
| 107 | + person: a.belongsTo('Person', 'personId'), |
| 108 | + article: a.belongsTo('Article', 'articleId'), |
| 109 | + }) |
| 110 | + .identifier(['articleId', 'personId']), |
| 111 | + ArticleOriginalWork: a |
| 112 | + .model({ |
| 113 | + articleId: a.id().required(), |
| 114 | + personId: a.id().required(), |
| 115 | + person: a.belongsTo('Person', 'personId'), |
| 116 | + article: a.belongsTo('Article', 'articleId'), |
| 117 | + }) |
| 118 | + .identifier(['articleId', 'personId']), |
| 119 | + ArticleMusic: a |
| 120 | + .model({ |
| 121 | + type: a.string().required(), |
| 122 | + articleId: a.id().required(), |
| 123 | + article: a.belongsTo('Article', 'articleId'), |
| 124 | + course: a.integer().required(), |
| 125 | + opArtist: a.string(), |
| 126 | + opSong: a.string(), |
| 127 | + edArtist: a.string(), |
| 128 | + edSong: a.string(), |
| 129 | + otherArtist: a.string(), |
| 130 | + otherSon: a.string(), |
| 131 | + sort: a.integer().required(), // articleId |
| 132 | + }) |
| 133 | + .identifier(['articleId', 'course']) |
| 134 | + .secondaryIndexes((index) => [ |
| 135 | + index('type') |
| 136 | + .sortKeys(['sort', 'course']) |
| 137 | + .queryField('musicListByTypeAndSortCourse'), |
| 138 | + ]), |
| 139 | + PageSetting: a |
| 140 | + .model({ |
| 141 | + articleId: a.id().required(), |
| 142 | + type: a.string().required(), // eg: anime-CAROUSEL / anime-SPOTLIGHT |
| 143 | + article: a.belongsTo('Article', 'articleId'), |
| 144 | + sort: a.integer().required(), |
| 145 | + }) |
| 146 | + .identifier(['articleId', 'type']) |
| 147 | + .secondaryIndexes((index) => [ |
| 148 | + index('type').sortKeys(['sort']).queryField('settingListByTypeAndSort'), |
| 149 | + ]), |
| 150 | + Article: a |
| 151 | + .model({ |
| 152 | + id: a.id().required(), |
| 153 | + genreType: a.enum(['movie', 'drama', 'variety', 'anime']), |
| 154 | + tagType: a.enum(['root', 'series', 'episode']), |
| 155 | + pathName: a.string().required(), // eg: spy_family | spy_family/season1 | spy_family/season1/episode1 |
| 156 | + parentId: a.id(), |
| 157 | + childs: a.hasMany('Article', 'parentId'), |
| 158 | + parent: a.belongsTo('Article', 'parentId'), |
| 159 | + pageSetting: a.hasMany('PageSetting', 'articleId'), |
| 160 | + title: a.string().required(), |
| 161 | + titleMeta: a.string(), |
| 162 | + descriptionMeta: a.string(), |
| 163 | + networkId: a.id().required(), |
| 164 | + network: a.belongsTo('Network', 'networkId'), |
| 165 | + seasonId: a.id(), |
| 166 | + season: a.belongsTo('Season', 'seasonId'), |
| 167 | + thumbnail: a.string(), |
| 168 | + vods: a.hasMany('ArticleVod', 'articleId'), |
| 169 | + categoryId: a.id().required(), |
| 170 | + category: a.belongsTo('Category', 'categoryId'), |
| 171 | + summary: a.customType({ |
| 172 | + title: a.string(), |
| 173 | + text: a.string(), |
| 174 | + }), |
| 175 | + authors: a.hasMany('ArticleAuthor', 'articleId'), |
| 176 | + authorOrganiation: a.string(), |
| 177 | + directors: a.hasMany('ArticleDirector', 'articleId'), |
| 178 | + producers: a.hasMany('ArticleProducer', 'articleId'), |
| 179 | + screenwriters: a.hasMany('ArticleScreenwriter', 'articleId'), |
| 180 | + staff: a.string(), |
| 181 | + production: a.string().array(), |
| 182 | + casts: a.hasMany('ArticleCast', 'articleId'), |
| 183 | + sns: a.url().array(), |
| 184 | + durationTime: a.string(), |
| 185 | + seriesNumber: a.string(), |
| 186 | + publisher: a.string(), |
| 187 | + otherPublisher: a.string(), |
| 188 | + website: a.url(), |
| 189 | + articleOriginalWorks: a.hasMany('ArticleOriginalWork', 'articleId'), |
| 190 | + originalWorkOrganization: a.string(), |
| 191 | + label: a.string(), |
| 192 | + durationPeriod: a.string(), |
| 193 | + volume: a.string(), |
| 194 | + content: a.customType({ |
| 195 | + genre: a.string(), |
| 196 | + subgenre: a.string(), |
| 197 | + }), |
| 198 | + distributor: a.string(), |
| 199 | + distributorOverseas: a.string(), |
| 200 | + copyright: a.string(), |
| 201 | + productionYear: a.string(), |
| 202 | + musics: a.hasMany('ArticleMusic', 'articleId'), |
| 203 | + video: a.customType({ |
| 204 | + text: a.string(), |
| 205 | + url: a.url(), |
| 206 | + }), |
| 207 | + sort: a.integer().required(), |
| 208 | + }) |
| 209 | + .secondaryIndexes((index) => [ |
| 210 | + index('genreType') |
| 211 | + .sortKeys(['sort']) |
| 212 | + .queryField('listByGenreTypeAndSort'), |
| 213 | + index('parentId') |
| 214 | + .sortKeys(['sort']) |
| 215 | + .queryField('listByParentIdAndSort'), |
| 216 | + index('seasonId') |
| 217 | + .sortKeys(['genreType', 'tagType', 'sort']) |
| 218 | + .queryField('listBySeasonIdAndTypeSort'), |
| 219 | + index('categoryId') |
| 220 | + .sortKeys(['genreType', 'tagType', 'sort']) |
| 221 | + .queryField('listByCategoryIdAndTypeSort'), |
| 222 | + index('pathName').queryField('listByPathName'), |
| 223 | + ]), |
| 224 | + }) |
| 225 | + .authorization((allow) => [allow.publicApiKey()]); |
19 | 226 |
|
20 | | -const s2 = schema.addMutations({ |
21 | | - myMutation: a.mutation().returns(a.ref('Post')), |
22 | | -}); |
| 227 | +export type Schema = ClientSchema<typeof schema>; |
23 | 228 |
|
24 | | -export type Schema = ClientSchema<typeof s2>; |
| 229 | +type TN = Prettify<Schema['Network']['type']>; |
| 230 | +type TNF = Prettify<Schema['Network']['__meta']['flatModel']>; |
0 commit comments