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

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mikehazell
Copy link
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 added the 🐛 bug Unresolved bug label 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
Copy link

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
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 self-assigned this Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Unresolved bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants