Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): schema and field deprecation #5489

Merged
merged 28 commits into from
Jan 23, 2024
Merged

feat(core): schema and field deprecation #5489

merged 28 commits into from
Jan 23, 2024

Conversation

binoy14
Copy link
Contributor

@binoy14 binoy14 commented Jan 11, 2024

Description

This PR adds ability to deprecate documents and fields.

Example to deprecate a document

defineType({
  name: 'deprecatedDocument',
  title: 'Deprecated Document',
  type: 'document',
  deprecated: {
    reason: 'This document type is deprecated, use the author document',
  },
})

Screenshot 2024-01-11 at 10 58 32 AM

Example to deprecate a field

defineField({
  deprecated: {
    reason:
      'Use the non deprecated string field for new content, this field was originally for the old frontend',
  },
  description: 'This field is used to create the header for the site',
  validation: (Rule) => Rule.required(),
  name: 'string',
  title: 'string',
  type: 'string',
}),

Screenshot 2024-01-09 at 2 00 44 PM

The deprecation messages also gets carried over to the graphql schema

What to review

Test for deprecated fields
Test for deprecated document

Notes for release

  • Adds support for deprecating fields and document types

Copy link

vercel bot commented Jan 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview Jan 23, 2024 4:19pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 23, 2024 4:19pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Jan 23, 2024 4:19pm

Copy link
Contributor

github-actions bot commented Jan 11, 2024

Package Documentation Change
sanity -3%
Full Report
@sanity/migrate
This branch Next branch
0 documented 0 documented
30 not documented 0 not documented
@sanity/diff
This branch Next branch
13 documented 13 documented
16 not documented 16 not documented
@sanity/block-tools
This branch Next branch
4 documented 4 documented
9 not documented 9 not documented
@sanity/types
This branch Next branch
55 documented 55 documented
239 not documented 234 not documented
sanity/desk
This branch Next branch
84 documented 84 documented
64 not documented 64 not documented
@sanity/portable-text-editor
This branch Next branch
21 documented 21 documented
44 not documented 44 not documented
@sanity/mutator
This branch Next branch
7 documented 7 documented
4 not documented 4 not documented
@sanity/cli
This branch Next branch
1 documented 1 documented
31 not documented 31 not documented
@sanity/schema/_internal
This branch Next branch
0 documented 0 documented
12 not documented 12 not documented
@sanity/util/paths
This branch Next branch
1 documented 1 documented
15 not documented 15 not documented
sanity/router
This branch Next branch
17 documented 17 documented
26 not documented 26 not documented
@sanity/util/legacyDateFormat
This branch Next branch
0 documented 0 documented
3 not documented 3 not documented
@sanity/schema
This branch Next branch
0 documented 0 documented
2 not documented 2 not documented
sanity/structure
This branch Next branch
2 documented 2 documented
6 not documented 6 not documented
sanity/cli
This branch Next branch
2 documented 2 documented
0 not documented 0 not documented
@sanity/vision
This branch Next branch
0 documented 0 documented
3 not documented 3 not documented
@sanity/util/fs
This branch Next branch
0 documented 0 documented
3 not documented 3 not documented
sanity/_internal
This branch Next branch
0 documented 0 documented
1 not documented 1 not documented
sanity/_internalBrowser
This branch Next branch
0 documented 0 documented
3 not documented 3 not documented
@sanity/util/content
This branch Next branch
1 documented 1 documented
5 not documented 5 not documented
sanity
This branch Next branch
177 documented 183 documented
843 not documented 846 not documented

Copy link
Contributor

github-actions bot commented Jan 11, 2024

Component Testing Report Updated Jan 23, 2024 4:21 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 33s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 13s 3 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 13s 4 2 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 34s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 18s 9 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 2s 18 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 7s 3 0 0

@binoy14
Copy link
Contributor Author

binoy14 commented Jan 11, 2024

@juice49 could you look at the unit tests and commit snapshots if it looks good

@juice49 juice49 force-pushed the feat/type-deprecation branch from 80ae5ee to 731fac3 Compare January 16, 2024 11:12
@binoy14 binoy14 force-pushed the feat/type-deprecation branch from 28761f5 to 4831d7d Compare January 17, 2024 21:08
@binoy14 binoy14 force-pushed the feat/type-deprecation branch from 47125d3 to e3737e3 Compare January 18, 2024 17:51
Copy link
Contributor

@ricokahler ricokahler left a comment

Choose a reason for hiding this comment

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

Looks great! I had one non-blocking comment in there to consider regarding types but I'd say go to go otherwise.

packages/@sanity/types/src/schema/types.ts Outdated Show resolved Hide resolved
@juice49 juice49 added this pull request to the merge queue Jan 23, 2024
Merged via the queue into next with commit f7c2417 Jan 23, 2024
40 checks passed
@juice49 juice49 deleted the feat/type-deprecation branch January 23, 2024 16:24
jtpetty pushed a commit that referenced this pull request Jan 24, 2024
* feat(schema): add `deprecated` property to schema definitions

* feat(schema): add `DeprecatedSchemaType` type and `isDeprecatedSchemaType` type guard

* test(schema): add deprecations to test schema

* chore: add debug schema for deprecated fields

* chore(debug): update deprecated debug schema

* feat(core): add deprecated reason in the fields

* feat(desk): add document panel banner for deprecated document types

* feat(core): remove templates derived from deprecated document types from global document creation menu

* fix(core): deprecation existence check

* feat(cli): add support for GraphQL deprecations

* feat(cli): inherit GraphQL field deprecations from parent type

* feat(cli): extend GraphQL field deprecation inheritance to document interface fields

* test(cli): update snapshot

* chore(structure): add todo

* refactor(structure): move `DeprecatedDocumentTypeBanner` component into `banners` directory

* refactor(structure): adopt standard `Banner` component

* feat(core): add badge for deprecated fields (#5470)

* feat(core): add badge for deprecated fields

* fix(core): update styles for deprecated message

* chore(test): add tests for deprecated fields (#5484)

* chore(test): add test for deprecated document

* test(cli): update snapshot

* test(cli): update snapshot

* chore(test-studio): add example for deprecation of object type

* feat: pass depreacted info to object types (#5516)

* test(core): add test for named deprecated array

* fix(core): remove unnecessary fragment

* refactor(core): separate deprecation and search query filtering when computing available document creation types

* fix(core): fixes alignment for boolean input

* feat(types): establish first-class `DeprecatedSchemaType` type

---------

Co-authored-by: Ash <[email protected]>
Co-authored-by: Bjørge Næss <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants