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

Invalid schema generated when a related list has access: false #3389

Closed
timleslie opened this issue Aug 13, 2020 · 0 comments · Fixed by #3409
Closed

Invalid schema generated when a related list has access: false #3389

timleslie opened this issue Aug 13, 2020 · 0 comments · Fixed by #3409
Assignees

Comments

@timleslie
Copy link
Contributor

When a list has a relationship to another list with access: false, keystone generates an invalid graphQL schema.

keystone.createList('User', {
  fields: {
    name: { type: Text },
    post: { type: Relationship, ref: 'Post', many: false },
  },
  access: true,
});

keystone.createList('Post', {
  fields: {
    name: { type: Text },
  },
  access: false,
});
Error: Unknown type "PostWhereUniqueInput". Did you mean "UserWhereUniqueInput", "PostRelateToOneInput", "UserWhereInput", "UserUpdateInput", or "UsersUpdateInput"?

While this is a fairly obscure access control configuration, it's something that can come up in systems which support multiple different schemas.

The solution involves checking for refList.access[schemaName] in the Relationship methods getGqlAuxTypes, gqlUpdateInputFields, and gqlCreateInputFields. Unfortunately the latter 2 of these are getter functions, so we can't pass in schemaName as required. Fixing the issue will require us to change these getter functions and pass in { schemaName }.

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 a pull request may close this issue.

1 participant