Skip to content

Commit

Permalink
Add support for lists with no fields in GraphQL (#9254)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens authored Aug 6, 2024
1 parent 9c27c75 commit 27207a1
Show file tree
Hide file tree
Showing 19 changed files with 949 additions and 133 deletions.
5 changes: 5 additions & 0 deletions .changeset/add-empty-lists.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-6/core': minor
---

Add support for lists with no fields in GraphQL
30 changes: 29 additions & 1 deletion examples/custom-esbuild/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ type Mutation {
}

type Query {
posts(where: PostWhereInput! = {}, orderBy: [PostOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PostWhereUniqueInput): [Post!]
post(where: PostWhereUniqueInput!): Post
posts(where: PostWhereInput! = {}, orderBy: [PostOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PostWhereUniqueInput): [Post!]
postsCount(where: PostWhereInput! = {}): Int
keystone: KeystoneMeta!
}
Expand Down Expand Up @@ -131,6 +131,7 @@ type KeystoneAdminUIListMeta {
labelField: String!
fields: [KeystoneAdminUIFieldMeta!]!
groups: [KeystoneAdminUIFieldGroupMeta!]!
graphql: KeystoneAdminUIGraphQL!
initialSort: KeystoneAdminUISort
isHidden: Boolean!
isSingleton: Boolean!
Expand Down Expand Up @@ -203,6 +204,33 @@ type KeystoneAdminUIFieldGroupMeta {
fields: [KeystoneAdminUIFieldMeta!]!
}

type KeystoneAdminUIGraphQL {
names: KeystoneAdminUIGraphQLNames!
}

type KeystoneAdminUIGraphQLNames {
outputTypeName: String!
whereInputName: String!
whereUniqueInputName: String!
createInputName: String!
createMutationName: String!
createManyMutationName: String!
relateToOneForCreateInputName: String!
relateToManyForCreateInputName: String!
itemQueryName: String!
listOrderName: String!
listQueryCountName: String!
listQueryName: String!
updateInputName: String!
updateMutationName: String!
updateManyInputName: String!
updateManyMutationName: String!
relateToOneForUpdateInputName: String!
relateToManyForUpdateInputName: String!
deleteMutationName: String!
deleteManyMutationName: String!
}

type KeystoneAdminUISort {
field: String!
direction: KeystoneAdminUISortDirection!
Expand Down
15 changes: 15 additions & 0 deletions examples/empty-lists/keystone.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { config } from '@keystone-6/core'
import { fixPrismaPath } from '../example-utils'
import { lists } from './schema'
import type { TypeInfo } from '.keystone/types'

export default config<TypeInfo>({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL ?? 'file:./keystone-example.db',

// WARNING: this is only needed for our monorepo examples, don't do this
...fixPrismaPath,
},
lists,
})
20 changes: 20 additions & 0 deletions examples/empty-lists/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@keystone-6/example-empty-lists",
"version": "0.0.1",
"private": true,
"license": "MIT",
"scripts": {
"dev": "keystone dev",
"start": "keystone start",
"build": "keystone build",
"postinstall": "keystone postinstall"
},
"dependencies": {
"@keystone-6/core": "workspace:^",
"@prisma/client": "catalog:"
},
"devDependencies": {
"prisma": "catalog:",
"typescript": "catalog:"
}
}
7 changes: 7 additions & 0 deletions examples/empty-lists/sandbox.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"template": "node",
"container": {
"startScript": "keystone dev",
"node": "18"
}
}
Loading

0 comments on commit 27207a1

Please sign in to comment.