Last active
June 12, 2017 11:27
-
-
Save wmertens/a9eb173c4ee34147506ed31089079295 to your computer and use it in GitHub Desktop.
Imagining what a graphql schema would look like that allows auto-creating lists and detail view/editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum PostStates { DRAFT, PUBLISHED, ARCHIVED } | |
scalar Date | |
scalar Html | |
directive @buildIndex on field | |
directive @defaultFirst on field | |
#...etc | |
type PostContent { | |
brief: Html @editor(height: 150, wysiwyg: true) | |
extended: Html @editor(height: 400, wysiwyg: true) | |
full: Html @virtual @editor(hide: true) | |
} | |
input PostContentInput { | |
brief: Html | |
extended: Html | |
} | |
type Post @trackChanges @list(enabled: true, columns: "name, state|20%, author|20%, publishedDate|20%") { | |
key: ID! @autoKey(from: "name") @unique | |
name: String! | |
state: PostStates! @buildIndex @defaultFirst | |
author: ID! @relation(type: "User") @buildIndex | |
publishedDate: Date | |
image: CloudinaryImage | |
content: PostContent | |
categories: [ID!] @relation(type: "PostCategory") | |
comments: [ID!] @relation(type: "PostComment") @virtual | |
} | |
input PostInput { | |
key: ID | |
name: String! | |
state: PostStates! | |
author: ID! | |
publishedDate: Date | |
image: CloudinaryImage | |
content: PostContentInput | |
categories: [ID!] | |
} | |
type Query { | |
post(key: ID, name: String): Post | |
filterPosts(state: PostStates, author: ID, category: ID): [Post]! | |
} | |
type Mutation { | |
savePost(post: PostInput): Post | |
} | |
schema { | |
query: Query | |
mutation: Mutation | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Same for the DB I suppose. It is not that much work to maintain 3 kinds of schemas, each similar but with their own subtleties…