Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
486 additions
and
14 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { config } from '@keystone-6/core'; | ||
import { fixPrismaPath } from '../example-utils'; | ||
import { lists } from './schema'; | ||
import type { Context } from '.keystone/types'; | ||
|
||
export default config({ | ||
db: { | ||
provider: 'sqlite', | ||
url: process.env.DATABASE_URL || 'file:./keystone-example.db', | ||
|
||
onConnect: async (context: Context) => { | ||
if ((await context.db.Person.count()) > 0) return; | ||
|
||
const people = []; | ||
for (let i = 0; i < 5; ++i) { | ||
people.push(await context.db.Person.createOne({ data: { name: `Person #${i}` } })); | ||
} | ||
|
||
for (const { id } of people) { | ||
// TODO: should work with .sudo() | ||
// await context.sudo().db.Nice.createOne({ | ||
await context.prisma.priority.create({ | ||
data: { | ||
person: { | ||
connect: { | ||
id, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
await context.prisma.nice.create({ | ||
data: { | ||
person: { | ||
connect: { | ||
id, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
await context.prisma.naughty.create({ | ||
data: { | ||
person: { | ||
connect: { | ||
id, | ||
}, | ||
}, | ||
}, | ||
}); | ||
} | ||
}, | ||
|
||
// WARNING: this is only needed for our monorepo examples, dont do this | ||
...fixPrismaPath, | ||
}, | ||
lists, | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "@keystone-6/example-omit", | ||
"version": "0.1.0", | ||
"private": true, | ||
"license": "MIT", | ||
"scripts": { | ||
"dev": "keystone dev", | ||
"start": "keystone start", | ||
"build": "keystone build", | ||
"postinstall": "keystone postinstall" | ||
}, | ||
"dependencies": { | ||
"@keystone-6/core": "^5.0.0", | ||
"@prisma/client": "^4.13.0", | ||
"next": "^13.3.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"prisma": "^4.13.0", | ||
"typescript": "~5.0.0" | ||
}, | ||
"repository": "https://github.com/keystonejs/keystone/tree/main/examples/omit" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"template": "node", | ||
"container": { | ||
"startScript": "keystone dev", | ||
"node": "16" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,259 @@ | ||
# This file is automatically generated by Keystone, do not modify it manually. | ||
# Modify your Keystone config when you want to change this. | ||
|
||
type Person { | ||
id: ID! | ||
name: String | ||
} | ||
|
||
input PersonWhereUniqueInput { | ||
id: ID | ||
} | ||
|
||
input PersonWhereInput { | ||
AND: [PersonWhereInput!] | ||
OR: [PersonWhereInput!] | ||
NOT: [PersonWhereInput!] | ||
id: IDFilter | ||
name: StringFilter | ||
} | ||
|
||
input IDFilter { | ||
equals: ID | ||
in: [ID!] | ||
notIn: [ID!] | ||
lt: ID | ||
lte: ID | ||
gt: ID | ||
gte: ID | ||
not: IDFilter | ||
} | ||
|
||
input StringFilter { | ||
equals: String | ||
in: [String!] | ||
notIn: [String!] | ||
lt: String | ||
lte: String | ||
gt: String | ||
gte: String | ||
contains: String | ||
startsWith: String | ||
endsWith: String | ||
not: NestedStringFilter | ||
} | ||
|
||
input NestedStringFilter { | ||
equals: String | ||
in: [String!] | ||
notIn: [String!] | ||
lt: String | ||
lte: String | ||
gt: String | ||
gte: String | ||
contains: String | ||
startsWith: String | ||
endsWith: String | ||
not: NestedStringFilter | ||
} | ||
|
||
input PersonOrderByInput { | ||
id: OrderDirection | ||
name: OrderDirection | ||
} | ||
|
||
enum OrderDirection { | ||
asc | ||
desc | ||
} | ||
|
||
input PersonUpdateInput { | ||
name: String | ||
} | ||
|
||
input PersonUpdateArgs { | ||
where: PersonWhereUniqueInput! | ||
data: PersonUpdateInput! | ||
} | ||
|
||
input PersonCreateInput { | ||
name: String | ||
} | ||
|
||
type Priority { | ||
id: ID! | ||
person: Person | ||
} | ||
|
||
input PriorityWhereUniqueInput { | ||
id: ID | ||
} | ||
|
||
input PriorityWhereInput { | ||
AND: [PriorityWhereInput!] | ||
OR: [PriorityWhereInput!] | ||
NOT: [PriorityWhereInput!] | ||
id: IDFilter | ||
person: PersonWhereInput | ||
} | ||
|
||
input PriorityOrderByInput { | ||
id: OrderDirection | ||
} | ||
|
||
type Naughty { | ||
id: ID! | ||
} | ||
|
||
input NaughtyWhereUniqueInput { | ||
id: ID | ||
} | ||
|
||
input NaughtyWhereInput { | ||
AND: [NaughtyWhereInput!] | ||
OR: [NaughtyWhereInput!] | ||
NOT: [NaughtyWhereInput!] | ||
id: IDFilter | ||
} | ||
|
||
input NaughtyOrderByInput { | ||
id: OrderDirection | ||
} | ||
|
||
""" | ||
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 @specifiedBy(url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf") | ||
|
||
type Mutation { | ||
createPerson(data: PersonCreateInput!): Person | ||
createPeople(data: [PersonCreateInput!]!): [Person] | ||
updatePerson(where: PersonWhereUniqueInput!, data: PersonUpdateInput!): Person | ||
updatePeople(data: [PersonUpdateArgs!]!): [Person] | ||
deletePerson(where: PersonWhereUniqueInput!): Person | ||
deletePeople(where: [PersonWhereUniqueInput!]!): [Person] | ||
deletePriority(where: PriorityWhereUniqueInput!): Priority | ||
deletePriorities(where: [PriorityWhereUniqueInput!]!): [Priority] | ||
deleteNaughty(where: NaughtyWhereUniqueInput!): Naughty | ||
deleteNaughties(where: [NaughtyWhereUniqueInput!]!): [Naughty] | ||
} | ||
|
||
type Query { | ||
people(where: PersonWhereInput! = {}, orderBy: [PersonOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PersonWhereUniqueInput): [Person!] | ||
person(where: PersonWhereUniqueInput!): Person | ||
peopleCount(where: PersonWhereInput! = {}): Int | ||
priorities(where: PriorityWhereInput! = {}, orderBy: [PriorityOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PriorityWhereUniqueInput): [Priority!] | ||
priority(where: PriorityWhereUniqueInput!): Priority | ||
prioritiesCount(where: PriorityWhereInput! = {}): Int | ||
naughties(where: NaughtyWhereInput! = {}, orderBy: [NaughtyOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: NaughtyWhereUniqueInput): [Naughty!] | ||
naughty(where: NaughtyWhereUniqueInput!): Naughty | ||
naughtiesCount(where: NaughtyWhereInput! = {}): Int | ||
keystone: KeystoneMeta! | ||
} | ||
|
||
type KeystoneMeta { | ||
adminMeta: KeystoneAdminMeta! | ||
} | ||
|
||
type KeystoneAdminMeta { | ||
lists: [KeystoneAdminUIListMeta!]! | ||
list(key: String!): KeystoneAdminUIListMeta | ||
} | ||
|
||
type KeystoneAdminUIListMeta { | ||
key: String! | ||
itemQueryName: String! | ||
listQueryName: String! | ||
hideCreate: Boolean! | ||
hideDelete: Boolean! | ||
path: String! | ||
label: String! | ||
singular: String! | ||
plural: String! | ||
description: String | ||
initialColumns: [String!]! | ||
pageSize: Int! | ||
labelField: String! | ||
fields: [KeystoneAdminUIFieldMeta!]! | ||
groups: [KeystoneAdminUIFieldGroupMeta!]! | ||
initialSort: KeystoneAdminUISort | ||
isHidden: Boolean! | ||
isSingleton: Boolean! | ||
} | ||
|
||
type KeystoneAdminUIFieldMeta { | ||
path: String! | ||
label: String! | ||
description: String | ||
isOrderable: Boolean! | ||
isFilterable: Boolean! | ||
isNonNull: [KeystoneAdminUIFieldMetaIsNonNull!] | ||
fieldMeta: JSON | ||
viewsIndex: Int! | ||
customViewsIndex: Int | ||
createView: KeystoneAdminUIFieldMetaCreateView! | ||
listView: KeystoneAdminUIFieldMetaListView! | ||
itemView(id: ID): KeystoneAdminUIFieldMetaItemView | ||
search: QueryMode | ||
} | ||
|
||
enum KeystoneAdminUIFieldMetaIsNonNull { | ||
read | ||
create | ||
update | ||
} | ||
|
||
type KeystoneAdminUIFieldMetaCreateView { | ||
fieldMode: KeystoneAdminUIFieldMetaCreateViewFieldMode! | ||
} | ||
|
||
enum KeystoneAdminUIFieldMetaCreateViewFieldMode { | ||
edit | ||
hidden | ||
} | ||
|
||
type KeystoneAdminUIFieldMetaListView { | ||
fieldMode: KeystoneAdminUIFieldMetaListViewFieldMode! | ||
} | ||
|
||
enum KeystoneAdminUIFieldMetaListViewFieldMode { | ||
read | ||
hidden | ||
} | ||
|
||
type KeystoneAdminUIFieldMetaItemView { | ||
fieldMode: KeystoneAdminUIFieldMetaItemViewFieldMode | ||
fieldPosition: KeystoneAdminUIFieldMetaItemViewFieldPosition | ||
} | ||
|
||
enum KeystoneAdminUIFieldMetaItemViewFieldMode { | ||
edit | ||
read | ||
hidden | ||
} | ||
|
||
enum KeystoneAdminUIFieldMetaItemViewFieldPosition { | ||
form | ||
sidebar | ||
} | ||
|
||
enum QueryMode { | ||
default | ||
insensitive | ||
} | ||
|
||
type KeystoneAdminUIFieldGroupMeta { | ||
label: String! | ||
description: String | ||
fields: [KeystoneAdminUIFieldMeta!]! | ||
} | ||
|
||
type KeystoneAdminUISort { | ||
field: String! | ||
direction: KeystoneAdminUISortDirection! | ||
} | ||
|
||
enum KeystoneAdminUISortDirection { | ||
ASC | ||
DESC | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// This file is automatically generated by Keystone, do not modify it manually. | ||
// Modify your Keystone config when you want to change this. | ||
|
||
datasource sqlite { | ||
url = env("DATABASE_URL") | ||
shadowDatabaseUrl = env("SHADOW_DATABASE_URL") | ||
provider = "sqlite" | ||
} | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
output = "node_modules/.myprisma/client" | ||
} | ||
|
||
model Person { | ||
id String @id @default(cuid()) | ||
name String @default("") | ||
from_Priority_person Priority[] @relation("Priority_person") | ||
from_Nice_person Nice[] @relation("Nice_person") | ||
from_Naughty_person Naughty[] @relation("Naughty_person") | ||
} | ||
|
||
model Priority { | ||
id String @id @default(cuid()) | ||
person Person? @relation("Priority_person", fields: [personId], references: [id]) | ||
personId String? @map("person") | ||
@@index([personId]) | ||
} | ||
|
||
model Nice { | ||
id String @id @default(cuid()) | ||
person Person? @relation("Nice_person", fields: [personId], references: [id]) | ||
personId String? @map("person") | ||
@@index([personId]) | ||
} | ||
|
||
model Naughty { | ||
id String @id @default(cuid()) | ||
person Person? @relation("Naughty_person", fields: [personId], references: [id]) | ||
personId String? @map("person") | ||
@@index([personId]) | ||
} |
Oops, something went wrong.