Skip to content

Commit

Permalink
Add graphql.isNonNull.update (#8283)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Cousens <[email protected]>
Co-authored-by: Josh Calder <[email protected]>
Co-authored-by: rburgst <[email protected]>
  • Loading branch information
4 people authored Feb 2, 2023
1 parent 8451751 commit 11bb288
Show file tree
Hide file tree
Showing 95 changed files with 1,045 additions and 385 deletions.
5 changes: 5 additions & 0 deletions .changeset/rotten-apples-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-6/core': major
---

Changes `graphql.omit` type from array to explicit `{ read: boolean, create: boolean, update: boolean }`
5 changes: 5 additions & 0 deletions .changeset/rotten-bananas-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-6/core': major
---

Changes `graphql.*.isNonNull` to `graphql.isNonNull.*`, and adds `graphql.isNonNull.update` for optimistic locking usecases
5 changes: 5 additions & 0 deletions .changeset/rotten-bananas-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-6/core': minor
---

Removes `keystone build` errors for `graphql.isNonNull.create` and `graphql.isNonNull.update` when field access control is configured
3 changes: 3 additions & 0 deletions docs/pages/docs/fields/bigint.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Options:
- `isIndexed` (default: `false`)
- If `true` then this field will be indexed by the database.
- If `'unique'` then all values of this field must be unique.
{% if $nextRelease %}
{% else /%}
- `graphql.read.isNonNull` (default: `false`): If you have no read access control and you don't intend to add any in the future,
you can set this to true and the output field will be non-nullable. This is only allowed when you have no read access control because otherwise,
when access is denied, `null` will be returned which will cause an error since the field is non-nullable and the error
Expand All @@ -32,6 +34,7 @@ Options:
you can set this to true and the create field will be non-nullable and have a default value at the GraphQL level.
This is only allowed when you have no create access control because otherwise, the item will always fail access control
if a user doesn't have access to create the particular field regardless of whether or not they specify the field in the create.
{% /if %}

```typescript
import { config, list } from '@keystone-6/core';
Expand Down
3 changes: 3 additions & 0 deletions docs/pages/docs/fields/calendarday.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Options:
- `isIndexed` (default: `false`)
- If `true` then this field will be indexed by the database.
- If `'unique'` then all values of this field must be unique.
{% if $nextRelease %}
{% else /%}
- `graphql.read.isNonNull` (default: `false`): If you have no read access control and you don't intend to add any in the future,
you can set this to true and the output field will be non-nullable. This is only allowed when you have no read access control because otherwise,
when access is denied, `null` will be returned which will cause an error since the field is non-nullable and the error
Expand All @@ -28,6 +30,7 @@ Options:
you can set this to true and the create field will be non-nullable and have a default value at the GraphQL level.
This is only allowed when you have no create access control because otherwise, the item will always fail access control
if a user doesn't have access to create the particular field regardless of whether or not they specify the field in the create.
{% /if %}

```typescript
import { config, list } from '@keystone-6/core';
Expand Down
3 changes: 3 additions & 0 deletions docs/pages/docs/fields/checkbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Options:

- `defaultValue` (default: `false`): This value will be used for the field when creating items if no explicit value is set.
- `db.map`: Adds a [Prisma `@map`](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#map) attribute to this field which changes the column name in the database
{% if $nextRelease %}
{% else /%}
- `graphql.read.isNonNull` (default: `false`): If you have no read access control and you don't intend to add any in the future,
you can set this to true and the output field will be non-nullable. This is only allowed when you have no read access control because otherwise,
when access is denied, `null` will be returned which will cause an error since the field is non-nullable and the error
Expand All @@ -17,6 +19,7 @@ Options:
you can set this to true and the create field will be non-nullable and have a default value at the GraphQL level.
This is only allowed when you have no create access control because otherwise, the item will always fail access control
if a user doesn't have access to create the particular field regardless of whether or not they specify the field in the create.
{% /if %}

```typescript
import { config, list } from '@keystone-6/core';
Expand Down
3 changes: 3 additions & 0 deletions docs/pages/docs/fields/decimal.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Options:
- `isIndexed` (default: `false`)
- If `true` then this field will be indexed by the database.
- If `'unique'` then all values of this field must be unique.
{% if $nextRelease %}
{% else /%}
- `graphql.read.isNonNull` (default: `false`): If you have no read access control and you don't intend to add any in the future,
you can set this to true and the output field will be non-nullable. This is only allowed when you have no read access control because otherwise,
when access is denied, `null` will be returned which will cause an error since the field is non-nullable and the error
Expand All @@ -30,6 +32,7 @@ Options:
you can set this to true and the create field will be non-nullable and have a default value at the GraphQL level.
This is only allowed when you have no create access control because otherwise, the item will always fail access control
if a user doesn't have access to create the particular field regardless of whether or not they specify the field in the create.
{% /if %}

```typescript
import { config, list } from '@keystone-6/core';
Expand Down
3 changes: 3 additions & 0 deletions docs/pages/docs/fields/float.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Options:
- `isIndexed` (default: `false`)
- If `true` then this field will be indexed by the database.
- If `'unique'` then all values of this field must be unique.
{% if $nextRelease %}
{% else /%}
- `graphql.read.isNonNull` (default: `false`): If you have no read access control and you don't intend to add any in the future,
you can set this to true and the output field will be non-nullable. This is only allowed when you have no read access control because otherwise,
when access is denied, `null` will be returned which will cause an error since the field is non-nullable and the error
Expand All @@ -27,6 +29,7 @@ Options:
you can set this to true and the create field will be non-nullable and have a default value at the GraphQL level.
This is only allowed when you have no create access control because otherwise, the item will always fail access control
if a user doesn't have access to create the particular field regardless of whether or not they specify the field in the create.
{% /if %}

```typescript
import { config, list } from '@keystone-6/core';
Expand Down
3 changes: 3 additions & 0 deletions docs/pages/docs/fields/integer.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Options:
- `isIndexed` (default: `false`)
- If `true` then this field will be indexed by the database.
- If `'unique'` then all values of this field must be unique.
{% if $nextRelease %}
{% else /%}
- `graphql.read.isNonNull` (default: `false`): If you have no read access control and you don't intend to add any in the future,
you can set this to true and the output field will be non-nullable. This is only allowed when you have no read access control because otherwise,
when access is denied, `null` will be returned which will cause an error since the field is non-nullable and the error
Expand All @@ -29,6 +31,7 @@ Options:
you can set this to true and the create field will be non-nullable and have a default value at the GraphQL level.
This is only allowed when you have no create access control because otherwise, the item will always fail access control
if a user doesn't have access to create the particular field regardless of whether or not they specify the field in the create.
{% /if %}

```typescript
import { config, list } from '@keystone-6/core';
Expand Down
3 changes: 3 additions & 0 deletions docs/pages/docs/fields/multiselect.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Options:
The `value` will be used in the GraphQL API and stored in the database.
- `defaultValue` (default: `[]`): This value will be used for the field when creating items if no explicit value is set.
- `db.map`: Adds a [Prisma `@map`](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#map) attribute to this field which changes the column name in the database
{% if $nextRelease %}
{% else /%}
- `graphql.read.isNonNull` (default: `false`): If you have no read access control and you don't intend to add any in the future,
you can set this to true and the output field will be non-nullable. This is only allowed when you have no read access control because otherwise,
when access is denied, `null` will be returned which will cause an error since the field is non-nullable and the error
Expand All @@ -26,6 +28,7 @@ Options:
you can set this to true and the create field will be non-nullable and have a default value at the GraphQL level.
This is only allowed when you have no create access control because otherwise, the item will always fail access control
if a user doesn't have access to create the particular field regardless of whether or not they specify the field in the create.
{% /if %}

```typescript
import { config, list } from '@keystone-6/core';
Expand Down
8 changes: 8 additions & 0 deletions docs/pages/docs/fields/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ Options:
See the [Lists API](../config/lists#ui) for details.
- `graphql`: Configures certain aspects of the GraphQL API.
- `cacheHint` (default: `undefined`): Allows you to specify the [dynamic cache control hints](https://www.apollographql.com/docs/apollo-server/performance/caching/#in-your-resolvers-dynamic) used for queries to this list.
{% if $nextRelease %}
- `isNonNull.read` (default: `false`): Changing this to `true` will change the GraphQL output type to be non-nullable.
If you have 'read' field access control, this will be rejected with a runtime `Error` as `null` may be returned if the access control returns false.
- `isNonNull.create` (default: `false`): Enforce that this field is non-nullable in the \*CreateInput for the respective list item.
Fields that have a `defaultValue` only have that default value included in the GraphQL if this field is `true`.
- `isNonNull.update` (default: `false`): Enforce that this field is non-nullable in the \*UpdateInput for the respective list item.
This field additionally results in the AdminUI always sending this particular field in updates, including when it has not changed.
{% /if %}
- `omit` (default: 'undefined'): Controls whether this field appears in the autogenerated types of the GraphQL API
This option accepts either `true`, or an array of the values `read`, `create`, or `update`.
If you specify `true` then the field will be excluded from all input and output types in the GraphQL API.
Expand Down
3 changes: 3 additions & 0 deletions docs/pages/docs/fields/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Options:
- If `'unique'` then all values of this field must be unique.
- `ui.displayMode` (default: `'select'`): Configures the display mode of the field in the Admin UI.
Can be one of `['select', 'segmented-control', 'radio']`.
{% if $nextRelease %}
{% else /%}
- `graphql.read.isNonNull` (default: `false`): If you have no read access control and you don't intend to add any in the future,
you can set this to true and the output field will be non-nullable. This is only allowed when you have no read access control because otherwise,
when access is denied, `null` will be returned which will cause an error since the field is non-nullable and the error
Expand All @@ -35,6 +37,7 @@ Options:
you can set this to true and the create field will be non-nullable and have a default value at the GraphQL level.
This is only allowed when you have no create access control because otherwise, the item will always fail access control
if a user doesn't have access to create the particular field regardless of whether or not they specify the field in the create.
{% /if %}

```typescript
import { config, list } from '@keystone-6/core';
Expand Down
3 changes: 3 additions & 0 deletions docs/pages/docs/fields/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Options:
- If `'unique'` then all values of this field must be unique.
- `ui` (default: `{ displayMode: 'input' }`): Configures the display mode of the field in the Admin UI.
Can be one of `['input', 'textarea']`.
{% if $nextRelease %}
{% else /%}
- `graphql.read.isNonNull` (default: `false`): If you have no read access control and you don't intend to add any in the future,
you can set this to true and the output field will be non-nullable. This is only allowed when you have no read access control because otherwise,
when access is denied, `null` will be returned which will cause an error since the field is non-nullable and the error
Expand All @@ -33,6 +35,7 @@ Options:
you can set this to true and the create field will be non-nullable and have a default value at the GraphQL level.
This is only allowed when you have no create access control because otherwise, the item will always fail access control
if a user doesn't have access to create the particular field regardless of whether or not they specify the field in the create.
{% /if %}

{% hint kind="tip" %}
**\*Warning** Unlike with other `keystone` fields, `db.isNullable` is defaulted to `false` for the text field.
Expand Down
3 changes: 3 additions & 0 deletions docs/pages/docs/fields/timestamp.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Options:
- `isIndexed` (default: `false`)
- If `true` then this field will be indexed by the database.
- If `'unique'` then all values of this field must be unique.
{% if $nextRelease %}
{% else /%}
- `graphql.read.isNonNull` (default: `false`): If you have no read access control and you don't intend to add any in the future,
you can set this to true and the output field will be non-nullable. This is only allowed when you have no read access control because otherwise,
when access is denied, `null` will be returned which will cause an error since the field is non-nullable and the error
Expand All @@ -28,6 +30,7 @@ Options:
you can set this to true and the create field will be non-nullable and have a default value at the GraphQL level.
This is only allowed when you have no create access control because otherwise, the item will always fail access control
if a user doesn't have access to create the particular field regardless of whether or not they specify the field in the create.
{% /if %}

```typescript
import { config, list } from '@keystone-6/core';
Expand Down
7 changes: 7 additions & 0 deletions examples/assets-local/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ type KeystoneAdminUIFieldMeta {
description: String
isOrderable: Boolean!
isFilterable: Boolean!
isNonNull: [KeystoneAdminUIFieldMetaIsNonNull!]
fieldMeta: JSON
viewsIndex: Int!
customViewsIndex: Int
Expand All @@ -313,6 +314,12 @@ type KeystoneAdminUIFieldMeta {
search: QueryMode
}

enum KeystoneAdminUIFieldMetaIsNonNull {
read
create
update
}

type KeystoneAdminUIFieldMetaCreateView {
fieldMode: KeystoneAdminUIFieldMetaCreateViewFieldMode!
}
Expand Down
7 changes: 7 additions & 0 deletions examples/assets-s3/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ type KeystoneAdminUIFieldMeta {
description: String
isOrderable: Boolean!
isFilterable: Boolean!
isNonNull: [KeystoneAdminUIFieldMetaIsNonNull!]
fieldMeta: JSON
viewsIndex: Int!
customViewsIndex: Int
Expand All @@ -313,6 +314,12 @@ type KeystoneAdminUIFieldMeta {
search: QueryMode
}

enum KeystoneAdminUIFieldMetaIsNonNull {
read
create
update
}

type KeystoneAdminUIFieldMetaCreateView {
fieldMode: KeystoneAdminUIFieldMetaCreateViewFieldMode!
}
Expand Down
7 changes: 7 additions & 0 deletions examples/auth/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ type KeystoneAdminUIFieldMeta {
description: String
isOrderable: Boolean!
isFilterable: Boolean!
isNonNull: [KeystoneAdminUIFieldMetaIsNonNull!]
fieldMeta: JSON
viewsIndex: Int!
customViewsIndex: Int
Expand All @@ -197,6 +198,12 @@ type KeystoneAdminUIFieldMeta {
search: QueryMode
}

enum KeystoneAdminUIFieldMetaIsNonNull {
read
create
update
}

type KeystoneAdminUIFieldMetaCreateView {
fieldMode: KeystoneAdminUIFieldMetaCreateViewFieldMode!
}
Expand Down
7 changes: 7 additions & 0 deletions examples/basic/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ type KeystoneAdminUIFieldMeta {
description: String
isOrderable: Boolean!
isFilterable: Boolean!
isNonNull: [KeystoneAdminUIFieldMetaIsNonNull!]
fieldMeta: JSON
viewsIndex: Int!
customViewsIndex: Int
Expand All @@ -461,6 +462,12 @@ type KeystoneAdminUIFieldMeta {
search: QueryMode
}

enum KeystoneAdminUIFieldMetaIsNonNull {
read
create
update
}

type KeystoneAdminUIFieldMetaCreateView {
fieldMode: KeystoneAdminUIFieldMetaCreateViewFieldMode!
}
Expand Down
7 changes: 7 additions & 0 deletions examples/blog/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ type KeystoneAdminUIFieldMeta {
description: String
isOrderable: Boolean!
isFilterable: Boolean!
isNonNull: [KeystoneAdminUIFieldMetaIsNonNull!]
fieldMeta: JSON
viewsIndex: Int!
customViewsIndex: Int
Expand All @@ -274,6 +275,12 @@ type KeystoneAdminUIFieldMeta {
search: QueryMode
}

enum KeystoneAdminUIFieldMetaIsNonNull {
read
create
update
}

type KeystoneAdminUIFieldMetaCreateView {
fieldMode: KeystoneAdminUIFieldMetaCreateViewFieldMode!
}
Expand Down
7 changes: 7 additions & 0 deletions examples/custom-admin-ui-logo/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ type KeystoneAdminUIFieldMeta {
description: String
isOrderable: Boolean!
isFilterable: Boolean!
isNonNull: [KeystoneAdminUIFieldMetaIsNonNull!]
fieldMeta: JSON
viewsIndex: Int!
customViewsIndex: Int
Expand All @@ -274,6 +275,12 @@ type KeystoneAdminUIFieldMeta {
search: QueryMode
}

enum KeystoneAdminUIFieldMetaIsNonNull {
read
create
update
}

type KeystoneAdminUIFieldMetaCreateView {
fieldMode: KeystoneAdminUIFieldMetaCreateViewFieldMode!
}
Expand Down
7 changes: 7 additions & 0 deletions examples/custom-admin-ui-navigation/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ type KeystoneAdminUIFieldMeta {
description: String
isOrderable: Boolean!
isFilterable: Boolean!
isNonNull: [KeystoneAdminUIFieldMetaIsNonNull!]
fieldMeta: JSON
viewsIndex: Int!
customViewsIndex: Int
Expand All @@ -274,6 +275,12 @@ type KeystoneAdminUIFieldMeta {
search: QueryMode
}

enum KeystoneAdminUIFieldMetaIsNonNull {
read
create
update
}

type KeystoneAdminUIFieldMetaCreateView {
fieldMode: KeystoneAdminUIFieldMetaCreateViewFieldMode!
}
Expand Down
7 changes: 7 additions & 0 deletions examples/custom-admin-ui-pages/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ type KeystoneAdminUIFieldMeta {
description: String
isOrderable: Boolean!
isFilterable: Boolean!
isNonNull: [KeystoneAdminUIFieldMetaIsNonNull!]
fieldMeta: JSON
viewsIndex: Int!
customViewsIndex: Int
Expand All @@ -274,6 +275,12 @@ type KeystoneAdminUIFieldMeta {
search: QueryMode
}

enum KeystoneAdminUIFieldMetaIsNonNull {
read
create
update
}

type KeystoneAdminUIFieldMetaCreateView {
fieldMode: KeystoneAdminUIFieldMetaCreateViewFieldMode!
}
Expand Down
7 changes: 7 additions & 0 deletions examples/custom-field-view/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ type KeystoneAdminUIFieldMeta {
description: String
isOrderable: Boolean!
isFilterable: Boolean!
isNonNull: [KeystoneAdminUIFieldMetaIsNonNull!]
fieldMeta: JSON
viewsIndex: Int!
customViewsIndex: Int
Expand All @@ -277,6 +278,12 @@ type KeystoneAdminUIFieldMeta {
search: QueryMode
}

enum KeystoneAdminUIFieldMetaIsNonNull {
read
create
update
}

type KeystoneAdminUIFieldMetaCreateView {
fieldMode: KeystoneAdminUIFieldMetaCreateViewFieldMode!
}
Expand Down
Loading

1 comment on commit 11bb288

@vercel
Copy link

@vercel vercel bot commented on 11bb288 Feb 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.