Skip to content

context.db should not omit types omitted from the GraphQL schema#9402

Merged
dcousens merged 3 commits intokeystonejs:mainfrom
mikehazell:use-sudo-schema-on-db-api
Feb 4, 2025
Merged

context.db should not omit types omitted from the GraphQL schema#9402
dcousens merged 3 commits intokeystonejs:mainfrom
mikehazell:use-sudo-schema-on-db-api

Conversation

@mikehazell
Copy link
Copy Markdown
Contributor

@mikehazell mikehazell commented Nov 21, 2024

The keystone List documentation says:

omit (default: undefined): Allows you to configure which parts of the CRUD API are autogenerated for your GraphQL API …

.. but this none-the-less affects the types of context.db

const SomeList = list({
  graphql: {
    omit: {
      create: true
    },
  },
  fields: {
    someFieldName: text({
      label: '...',
    }),
  },
})
context.db.SomeList.create({
  data: { ... }
})

The .data type in db.SomeList.create results in a never, which is unnecessary.
This pull request fixes that.

@mikehazell mikehazell requested a review from dcousens November 21, 2024 01:35
@dcousens dcousens changed the title FIX: DB API should use the types from graphQLSchemaSudo conext.db should not omit types omitted from the GraphQL schema Nov 21, 2024
@dcousens dcousens changed the title conext.db should not omit types omitted from the GraphQL schema context.db should not omit types omitted from the GraphQL schema Nov 21, 2024
@codesandbox-ci
Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 0f89bb9:

Sandbox Source
@keystone-6/sandbox Configuration

@mikehazell
Copy link
Copy Markdown
Contributor Author

@dcousens for the record. The type error is not "the method is 'undefined'".

I get this:

Type '{ ... input data  ... }' is not assignable to type 'never'.ts(2322)
context.d.ts(107, 18): The expected type comes from property 'data' which is declared here on type '{ readonly data: never; }'

@dcousens dcousens force-pushed the use-sudo-schema-on-db-api branch from ce3f3d4 to f2928cd Compare February 4, 2025 08:36
@dcousens dcousens merged commit e5d7ace into keystonejs:main Feb 4, 2025
emmatown added a commit that referenced this pull request Feb 24, 2025
…9402)

Co-authored-by: Emma Hamilton <git@emmas.town>
Co-authored-by: Daniel Cousens <dcousens@users.noreply.github.com>
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.

2 participants