Skip to content

Instantly share code, notes, and snippets.

@dearlordylord
Created December 29, 2020 13:05
Show Gist options
  • Save dearlordylord/42c9fd94c738cb463e4d7e7e28de751b to your computer and use it in GitHub Desktop.
Save dearlordylord/42c9fd94c738cb463e4d7e7e28de751b to your computer and use it in GitHub Desktop.
Keystone.js blog graphql with Content field types and Cloudinary image block.
```
directive @cacheControl(
maxAge: Int
scope: CacheControlScope
) on FIELD_DEFINITION | OBJECT | INTERFACE
# A keystone list
type User {
# This virtual field will be resolved in one of the following ways (in this order):
# 1. Execution of 'labelResolver' set on the User List config, or
# 2. As an alias to the field set on 'labelField' in the User List config, or
# 3. As an alias to a 'name' field on the User List (if one exists), or
# 4. As an alias to the 'id' field on the User List.
_label_: String
id: ID!
name: String
email: String
isAdmin: Boolean
password_is_set: Boolean
}
input UserWhereInput {
AND: [UserWhereInput]
OR: [UserWhereInput]
id: ID
id_not: ID
id_in: [ID]
id_not_in: [ID]
name: String
name_not: String
name_contains: String
name_not_contains: String
name_starts_with: String
name_not_starts_with: String
name_ends_with: String
name_not_ends_with: String
name_i: String
name_not_i: String
name_contains_i: String
name_not_contains_i: String
name_starts_with_i: String
name_not_starts_with_i: String
name_ends_with_i: String
name_not_ends_with_i: String
name_in: [String]
name_not_in: [String]
email: String
email_not: String
email_contains: String
email_not_contains: String
email_starts_with: String
email_not_starts_with: String
email_ends_with: String
email_not_ends_with: String
email_i: String
email_not_i: String
email_contains_i: String
email_not_contains_i: String
email_starts_with_i: String
email_not_starts_with_i: String
email_ends_with_i: String
email_not_ends_with_i: String
email_in: [String]
email_not_in: [String]
isAdmin: Boolean
isAdmin_not: Boolean
password_is_set: Boolean
}
input UserWhereUniqueInput {
id: ID!
}
enum SortUsersBy {
id_ASC
id_DESC
name_ASC
name_DESC
email_ASC
email_DESC
isAdmin_ASC
isAdmin_DESC
}
input UserUpdateInput {
name: String
email: String
isAdmin: Boolean
password: String
}
input UsersUpdateInput {
id: ID!
data: UserUpdateInput
}
input UserCreateInput {
name: String
email: String
isAdmin: Boolean
password: String
}
input UsersCreateInput {
data: UserCreateInput
}
# A keystone list
type Product {
# This virtual field will be resolved in one of the following ways (in this order):
# 1. Execution of 'labelResolver' set on the Product List config, or
# 2. As an alias to the field set on 'labelField' in the Product List config, or
# 3. As an alias to a 'name' field on the Product List (if one exists), or
# 4. As an alias to the 'id' field on the Product List.
_label_: String
id: ID!
descriptionHtml: String
thsId: String
}
input ProductWhereInput {
AND: [ProductWhereInput]
OR: [ProductWhereInput]
id: ID
id_not: ID
id_in: [ID]
id_not_in: [ID]
descriptionHtml: String
descriptionHtml_not: String
descriptionHtml_contains: String
descriptionHtml_not_contains: String
descriptionHtml_starts_with: String
descriptionHtml_not_starts_with: String
descriptionHtml_ends_with: String
descriptionHtml_not_ends_with: String
descriptionHtml_i: String
descriptionHtml_not_i: String
descriptionHtml_contains_i: String
descriptionHtml_not_contains_i: String
descriptionHtml_starts_with_i: String
descriptionHtml_not_starts_with_i: String
descriptionHtml_ends_with_i: String
descriptionHtml_not_ends_with_i: String
descriptionHtml_in: [String]
descriptionHtml_not_in: [String]
thsId: String
thsId_not: String
thsId_contains: String
thsId_not_contains: String
thsId_starts_with: String
thsId_not_starts_with: String
thsId_ends_with: String
thsId_not_ends_with: String
thsId_i: String
thsId_not_i: String
thsId_contains_i: String
thsId_not_contains_i: String
thsId_starts_with_i: String
thsId_not_starts_with_i: String
thsId_ends_with_i: String
thsId_not_ends_with_i: String
thsId_in: [String]
thsId_not_in: [String]
}
input ProductWhereUniqueInput {
id: ID!
}
enum SortProductsBy {
id_ASC
id_DESC
descriptionHtml_ASC
descriptionHtml_DESC
thsId_ASC
thsId_DESC
}
input ProductUpdateInput {
descriptionHtml: String
thsId: String
}
input ProductsUpdateInput {
id: ID!
data: ProductUpdateInput
}
input ProductCreateInput {
descriptionHtml: String
thsId: String
}
input ProductsCreateInput {
data: ProductCreateInput
}
input _ContentTypePostContentBriefRelateToOneInput {
create: _ContentTypePostContentBriefCreateInput
connect: _ContentTypePostContentBriefWhereUniqueInput
disconnect: _ContentTypePostContentBriefWhereUniqueInput
disconnectAll: Boolean
}
input PostRelateToOneInput {
create: PostCreateInput
connect: PostWhereUniqueInput
disconnect: PostWhereUniqueInput
disconnectAll: Boolean
}
# A keystone list
type _ContentType_Post_contentBrief {
# This virtual field will be resolved in one of the following ways (in this order):
# 1. Execution of 'labelResolver' set on the _ContentType_Post_contentBrief List config, or
# 2. As an alias to the field set on 'labelField' in the _ContentType_Post_contentBrief List config, or
# 3. As an alias to a 'name' field on the _ContentType_Post_contentBrief List (if one exists), or
# 4. As an alias to the 'id' field on the _ContentType_Post_contentBrief List.
_label_: String
id: ID!
# The serialized Slate.js Document structure
document: String
# A reference back to the item this document belongs to
from: Post
}
input _ContentTypePostContentBriefWhereInput {
AND: [_ContentTypePostContentBriefWhereInput]
OR: [_ContentTypePostContentBriefWhereInput]
id: ID
id_not: ID
id_in: [ID]
id_not_in: [ID]
document: String
document_not: String
document_contains: String
document_not_contains: String
document_starts_with: String
document_not_starts_with: String
document_ends_with: String
document_not_ends_with: String
document_i: String
document_not_i: String
document_contains_i: String
document_not_contains_i: String
document_starts_with_i: String
document_not_starts_with_i: String
document_ends_with_i: String
document_not_ends_with_i: String
document_in: [String]
document_not_in: [String]
from: PostWhereInput
from_is_null: Boolean
}
input _ContentTypePostContentBriefWhereUniqueInput {
id: ID!
}
enum Sort_ContentTypePostContentBriefsBy {
id_ASC
id_DESC
document_ASC
document_DESC
from_ASC
from_DESC
}
input _ContentTypePostContentBriefUpdateInput {
document: String
from: PostRelateToOneInput
}
input _ContentTypePostContentBriefsUpdateInput {
id: ID!
data: _ContentTypePostContentBriefUpdateInput
}
input _ContentTypePostContentBriefCreateInput {
document: String
from: PostRelateToOneInput
}
input _ContentTypePostContentBriefsCreateInput {
data: _ContentTypePostContentBriefCreateInput
}
input _ContentTypePostContentExtendedRelateToOneInput {
create: _ContentTypePostContentExtendedCreateInput
connect: _ContentTypePostContentExtendedWhereUniqueInput
disconnect: _ContentTypePostContentExtendedWhereUniqueInput
disconnectAll: Boolean
}
input _BlockPostCloudinaryImageRelateToManyInput {
create: [_BlockPostCloudinaryImageCreateInput]
connect: [_BlockPostCloudinaryImageWhereUniqueInput]
disconnect: [_BlockPostCloudinaryImageWhereUniqueInput]
disconnectAll: Boolean
}
# A keystone list
type _ContentType_Post_contentExtended {
# This virtual field will be resolved in one of the following ways (in this order):
# 1. Execution of 'labelResolver' set on the _ContentType_Post_contentExtended List config, or
# 2. As an alias to the field set on 'labelField' in the _ContentType_Post_contentExtended List config, or
# 3. As an alias to a 'name' field on the _ContentType_Post_contentExtended List (if one exists), or
# 4. As an alias to the 'id' field on the _ContentType_Post_contentExtended List.
_label_: String
id: ID!
# The serialized Slate.js Document structure
document: String
# A reference back to the item this document belongs to
from: Post
# Images which have been added to the Content field
cloudinaryImages(
where: _BlockPostCloudinaryImageWhereInput
search: String
sortBy: [Sort_BlockPostCloudinaryImagesBy!]
orderBy: String
first: Int
skip: Int
): [_Block_Post_cloudinaryImage!]!
_cloudinaryImagesMeta(
where: _BlockPostCloudinaryImageWhereInput
search: String
sortBy: [Sort_BlockPostCloudinaryImagesBy!]
orderBy: String
first: Int
skip: Int
): _QueryMeta
}
input _ContentTypePostContentExtendedWhereInput {
AND: [_ContentTypePostContentExtendedWhereInput]
OR: [_ContentTypePostContentExtendedWhereInput]
id: ID
id_not: ID
id_in: [ID]
id_not_in: [ID]
document: String
document_not: String
document_contains: String
document_not_contains: String
document_starts_with: String
document_not_starts_with: String
document_ends_with: String
document_not_ends_with: String
document_i: String
document_not_i: String
document_contains_i: String
document_not_contains_i: String
document_starts_with_i: String
document_not_starts_with_i: String
document_ends_with_i: String
document_not_ends_with_i: String
document_in: [String]
document_not_in: [String]
from: PostWhereInput
from_is_null: Boolean
# condition must be true for all nodes
cloudinaryImages_every: _BlockPostCloudinaryImageWhereInput
# condition must be true for at least 1 node
cloudinaryImages_some: _BlockPostCloudinaryImageWhereInput
# condition must be false for all nodes
cloudinaryImages_none: _BlockPostCloudinaryImageWhereInput
}
input _ContentTypePostContentExtendedWhereUniqueInput {
id: ID!
}
enum Sort_ContentTypePostContentExtendedsBy {
id_ASC
id_DESC
document_ASC
document_DESC
from_ASC
from_DESC
cloudinaryImages_ASC
cloudinaryImages_DESC
}
input _ContentTypePostContentExtendedUpdateInput {
document: String
from: PostRelateToOneInput
cloudinaryImages: _BlockPostCloudinaryImageRelateToManyInput
}
input _ContentTypePostContentExtendedsUpdateInput {
id: ID!
data: _ContentTypePostContentExtendedUpdateInput
}
input _ContentTypePostContentExtendedCreateInput {
document: String
from: PostRelateToOneInput
cloudinaryImages: _BlockPostCloudinaryImageRelateToManyInput
}
input _ContentTypePostContentExtendedsCreateInput {
data: _ContentTypePostContentExtendedCreateInput
}
type CloudinaryImage_File {
id: ID
path: String
filename: String
originalFilename: String
mimetype: String
encoding: String
publicUrl: String
publicUrlTransformed(transformation: CloudinaryImageFormat): String
}
# Mirrors the formatting options [Cloudinary provides](https://cloudinary.com/documentation/image_transformation_reference).
# All options are strings as they ultimately end up in a URL.
input CloudinaryImageFormat {
# Rewrites the filename to be this pretty string. Do not include `/` or `.`
prettyName: String
width: String
height: String
crop: String
aspect_ratio: String
gravity: String
zoom: String
x: String
y: String
format: String
fetch_format: String
quality: String
radius: String
angle: String
effect: String
opacity: String
border: String
background: String
overlay: String
underlay: String
default_image: String
delay: String
color: String
color_space: String
dpr: String
page: String
density: String
flags: String
transformation: String
}
# A keystone list
type Post {
# This virtual field will be resolved in one of the following ways (in this order):
# 1. Execution of 'labelResolver' set on the Post List config, or
# 2. As an alias to the field set on 'labelField' in the Post List config, or
# 3. As an alias to a 'name' field on the Post List (if one exists), or
# 4. As an alias to the 'id' field on the Post List.
_label_: String
id: ID!
contentBrief: _ContentType_Post_contentBrief
contentExtended: _ContentType_Post_contentExtended
title: String
picture: CloudinaryImage_File
slug: String
}
input PostWhereInput {
AND: [PostWhereInput]
OR: [PostWhereInput]
id: ID
id_not: ID
id_in: [ID]
id_not_in: [ID]
contentBrief: _ContentTypePostContentBriefWhereInput
contentBrief_is_null: Boolean
contentExtended: _ContentTypePostContentExtendedWhereInput
contentExtended_is_null: Boolean
title: String
title_not: String
title_contains: String
title_not_contains: String
title_starts_with: String
title_not_starts_with: String
title_ends_with: String
title_not_ends_with: String
title_i: String
title_not_i: String
title_contains_i: String
title_not_contains_i: String
title_starts_with_i: String
title_not_starts_with_i: String
title_ends_with_i: String
title_not_ends_with_i: String
title_in: [String]
title_not_in: [String]
picture: String
picture_not: String
picture_in: [String]
picture_not_in: [String]
slug: String
slug_not: String
slug_contains: String
slug_not_contains: String
slug_starts_with: String
slug_not_starts_with: String
slug_ends_with: String
slug_not_ends_with: String
slug_i: String
slug_not_i: String
slug_contains_i: String
slug_not_contains_i: String
slug_starts_with_i: String
slug_not_starts_with_i: String
slug_ends_with_i: String
slug_not_ends_with_i: String
slug_in: [String]
slug_not_in: [String]
}
input PostWhereUniqueInput {
id: ID!
}
enum SortPostsBy {
id_ASC
id_DESC
contentBrief_ASC
contentBrief_DESC
contentExtended_ASC
contentExtended_DESC
title_ASC
title_DESC
slug_ASC
slug_DESC
}
input PostUpdateInput {
contentBrief: _ContentTypePostContentBriefRelateToOneInput
contentExtended: _ContentTypePostContentExtendedRelateToOneInput
title: String
picture: Upload
slug: String
}
input PostsUpdateInput {
id: ID!
data: PostUpdateInput
}
input PostCreateInput {
contentBrief: _ContentTypePostContentBriefRelateToOneInput
contentExtended: _ContentTypePostContentExtendedRelateToOneInput
title: String
picture: Upload
slug: String
}
input PostsCreateInput {
data: PostCreateInput
}
enum _Block_Post_cloudinaryImageAlignType {
left
center
right
}
# A keystone list
type _Block_Post_cloudinaryImage {
# This virtual field will be resolved in one of the following ways (in this order):
# 1. Execution of 'labelResolver' set on the _Block_Post_cloudinaryImage List config, or
# 2. As an alias to the field set on 'labelField' in the _Block_Post_cloudinaryImage List config, or
# 3. As an alias to a 'name' field on the _Block_Post_cloudinaryImage List (if one exists), or
# 4. As an alias to the 'id' field on the _Block_Post_cloudinaryImage List.
_label_: String
id: ID!
# Cloudinary Image data returned from the Cloudinary API
image: CloudinaryImage_File
# Set the image alignment
align: _Block_Post_cloudinaryImageAlignType
# A reference back to the Slate.js Serialised Document this image is embedded within
from: _ContentType_Post_contentExtended
}
input _BlockPostCloudinaryImageWhereInput {
AND: [_BlockPostCloudinaryImageWhereInput]
OR: [_BlockPostCloudinaryImageWhereInput]
id: ID
id_not: ID
id_in: [ID]
id_not_in: [ID]
image: String
image_not: String
image_in: [String]
image_not_in: [String]
align: _Block_Post_cloudinaryImageAlignType
align_not: _Block_Post_cloudinaryImageAlignType
align_in: [_Block_Post_cloudinaryImageAlignType]
align_not_in: [_Block_Post_cloudinaryImageAlignType]
from: _ContentTypePostContentExtendedWhereInput
from_is_null: Boolean
}
input _BlockPostCloudinaryImageWhereUniqueInput {
id: ID!
}
enum Sort_BlockPostCloudinaryImagesBy {
id_ASC
id_DESC
align_ASC
align_DESC
from_ASC
from_DESC
}
input _BlockPostCloudinaryImageUpdateInput {
image: Upload
align: _Block_Post_cloudinaryImageAlignType
from: _ContentTypePostContentExtendedRelateToOneInput
}
input _BlockPostCloudinaryImagesUpdateInput {
id: ID!
data: _BlockPostCloudinaryImageUpdateInput
}
input _BlockPostCloudinaryImageCreateInput {
image: Upload
align: _Block_Post_cloudinaryImageAlignType
from: _ContentTypePostContentExtendedRelateToOneInput
}
input _BlockPostCloudinaryImagesCreateInput {
data: _BlockPostCloudinaryImageCreateInput
}
# The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).
scalar JSON
type _ListAccess {
# Access Control settings for the currently logged in (or anonymous)
# user when performing 'create' operations.
# NOTE: 'create' can only return a Boolean.
# It is not possible to specify a declarative Where clause for this
# operation
create: Boolean
# Access Control settings for the currently logged in (or anonymous)
# user when performing 'read' operations.
read: JSON
# Access Control settings for the currently logged in (or anonymous)
# user when performing 'update' operations.
update: JSON
# Access Control settings for the currently logged in (or anonymous)
# user when performing 'delete' operations.
delete: JSON
# Access Control settings for the currently logged in (or anonymous)
# user when performing 'auth' operations.
auth: JSON
}
type _ListQueries {
# Single-item query name
item: String
# All-items query name
list: String
# List metadata query name
meta: String
}
type _ListMutations {
# Create mutation name
create: String
# Create many mutation name
createMany: String
# Update mutation name
update: String
# Update many mutation name
updateMany: String
# Delete mutation name
delete: String
# Delete many mutation name
deleteMany: String
}
type _ListInputTypes {
# Input type for matching multiple items
whereInput: String
# Input type for matching a unique item
whereUniqueInput: String
# Create mutation input type name
createInput: String
# Create many mutation input type name
createManyInput: String
# Update mutation name input
updateInput: String
# Update many mutation name input
updateManyInput: String
}
type _ListSchemaFields {
# The path of the field in its list
path: String
# The name of the field in its list
name: String @deprecated(reason: "Use `path` instead")
# The field type (ie, Checkbox, Text, etc)
type: String
}
type _ListSchemaRelatedFields {
# The typename as used in GraphQL queries
type: String
# A list of GraphQL field names
fields: [String]
}
type _ListSchema {
# The typename as used in GraphQL queries
type: String
# Top level GraphQL query names which either return this type, or
# provide aggregate information about this type
queries: _ListQueries
# Top-level GraphQL mutation names
mutations: _ListMutations
# Top-level GraphQL input types
inputTypes: _ListInputTypes
# Information about fields defined on this list
fields(where: _ListSchemaFieldsInput): [_ListSchemaFields]
# Information about fields on other types which return this type, or
# provide aggregate information about this type
relatedFields: [_ListSchemaRelatedFields]
}
type _ListMeta {
# The Keystone list key
key: String
# The Keystone List name
name: String @deprecated(reason: "Use `key` instead")
# The list's user-facing description
description: String
# The list's display name in the Admin UI
label: String
# The list's singular display name
singular: String
# The list's plural display name
plural: String
# The list's data path
path: String
# Access control configuration for the currently authenticated request
access: _ListAccess
# Information on the generated GraphQL schema
schema: _ListSchema
}
type _QueryMeta {
count: Int
}
input _ksListsMetaInput {
key: String
# Whether this is an auxiliary helper list
auxiliary: Boolean
}
input _ListSchemaFieldsInput {
type: String
}
type unauthenticateUserOutput {
# `true` when unauthentication succeeds.
# NOTE: unauthentication always succeeds when the request has an invalid or missing authentication token.
success: Boolean
}
type authenticateUserOutput {
# Used to make subsequent authenticated requests by setting this token in a header: 'Authorization: Bearer <token>'.
token: String
# Retrieve information on the newly authenticated User here.
item: User
}
type Query {
# Search for all User items which match the where clause.
allUsers(
where: UserWhereInput
search: String
sortBy: [SortUsersBy!]
orderBy: String
first: Int
skip: Int
): [User]
# Search for the User item with the matching ID.
User(where: UserWhereUniqueInput!): User
# Perform a meta-query on all User items which match the where clause.
_allUsersMeta(
where: UserWhereInput
search: String
sortBy: [SortUsersBy!]
orderBy: String
first: Int
skip: Int
): _QueryMeta
# Retrieve the meta-data for the User list.
_UsersMeta: _ListMeta
# Search for all Product items which match the where clause.
allProducts(
where: ProductWhereInput
search: String
sortBy: [SortProductsBy!]
orderBy: String
first: Int
skip: Int
): [Product]
# Search for the Product item with the matching ID.
Product(where: ProductWhereUniqueInput!): Product
# Perform a meta-query on all Product items which match the where clause.
_allProductsMeta(
where: ProductWhereInput
search: String
sortBy: [SortProductsBy!]
orderBy: String
first: Int
skip: Int
): _QueryMeta
# Retrieve the meta-data for the Product list.
_ProductsMeta: _ListMeta
# Search for all Post items which match the where clause.
allPosts(
where: PostWhereInput
search: String
sortBy: [SortPostsBy!]
orderBy: String
first: Int
skip: Int
): [Post]
# Search for the Post item with the matching ID.
Post(where: PostWhereUniqueInput!): Post
# Perform a meta-query on all Post items which match the where clause.
_allPostsMeta(
where: PostWhereInput
search: String
sortBy: [SortPostsBy!]
orderBy: String
first: Int
skip: Int
): _QueryMeta
# Retrieve the meta-data for the Post list.
_PostsMeta: _ListMeta
# Retrieve the meta-data for all lists.
_ksListsMeta(where: _ksListsMetaInput): [_ListMeta]
# The version of the Keystone application serving this API.
appVersion: String
authenticatedUser: User
}
type Mutation {
# Create a single User item.
createUser(data: UserCreateInput): User
# Create multiple User items.
createUsers(data: [UsersCreateInput]): [User]
# Update a single User item by ID.
updateUser(id: ID!, data: UserUpdateInput): User
# Update multiple User items by ID.
updateUsers(data: [UsersUpdateInput]): [User]
# Delete a single User item by ID.
deleteUser(id: ID!): User
# Delete multiple User items by ID.
deleteUsers(ids: [ID!]): [User]
# Create a single Product item.
createProduct(data: ProductCreateInput): Product
# Create multiple Product items.
createProducts(data: [ProductsCreateInput]): [Product]
# Update a single Product item by ID.
updateProduct(id: ID!, data: ProductUpdateInput): Product
# Update multiple Product items by ID.
updateProducts(data: [ProductsUpdateInput]): [Product]
# Delete a single Product item by ID.
deleteProduct(id: ID!): Product
# Delete multiple Product items by ID.
deleteProducts(ids: [ID!]): [Product]
# Create a single Post item.
createPost(data: PostCreateInput): Post
# Create multiple Post items.
createPosts(data: [PostsCreateInput]): [Post]
# Update a single Post item by ID.
updatePost(id: ID!, data: PostUpdateInput): Post
# Update multiple Post items by ID.
updatePosts(data: [PostsUpdateInput]): [Post]
# Delete a single Post item by ID.
deletePost(id: ID!): Post
# Delete multiple Post items by ID.
deletePosts(ids: [ID!]): [Post]
# Authenticate and generate a token for a User with the Password Authentication Strategy.
authenticateUserWithPassword(
email: String
password: String
): authenticateUserOutput
unauthenticateUser: unauthenticateUserOutput
updateAuthenticatedUser(data: UserUpdateInput): User
}
# The `Upload` scalar type represents a file upload.
scalar Upload
enum CacheControlScope {
PUBLIC
PRIVATE
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment