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

Can't exclude user node fields "id" and "pk" #24

Closed
pors opened this issue Apr 7, 2020 · 8 comments
Closed

Can't exclude user node fields "id" and "pk" #24

pors opened this issue Apr 7, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@pors
Copy link
Collaborator

pors commented Apr 7, 2020

I have this setting:

"USER_NODE_EXCLUDE_FIELDS": ["password", "is_superuser", "id", "pk"]

And I get this warning:

.../graphene_django/types.py:103: UserWarning: Excluding the custom field "id" on DjangoObjectType "UserNode" has no effect. Either remove the custom field or remove the field from the "exclude" list.

And the same for pk.

@PedroBern
Copy link
Owner

I'm not sure, but my first hunch is:

pk

Because it is a field in the UserNode, I didn't try, but probably trying to exclude archived/verified/secondary_email would result in the same warning

id

Because of graphene.relay.Node.Field that has an id field, resulting in the same case I wrote above for pk.


Being these cases, I don't plan to fix it, but I will investigate further to see if I find other possible reasons. If you make progress on this please let me know!

@PedroBern PedroBern added the bug Something isn't working label Apr 7, 2020
@pors
Copy link
Collaborator Author

pors commented Apr 7, 2020

What is the reason you chose for the relay interface for users?

@PedroBern
Copy link
Owner

Because of the filtering. From the docs:

(...) filtering is automatically available when implementing a relay.Node. (...)

@PedroBern
Copy link
Owner

It's odd, when I try to remove the id I don't get the warning message. When I try to remove the pk I get an exception:

Exception: "pk" exists on model <class 'users.models.CustomUser'> but it's not a field.

What version are you using of django-graphql-auth and graphene?

@pors
Copy link
Collaborator Author

pors commented Apr 11, 2020

It's odd, when I try to remove the id I don't get the warning message. When I try to remove the pk I get an exception:

Removing how?

Exception: "pk" exists on model <class 'users.models.CustomUser'> but it's not a field.

What version are you using of django-graphql-auth and graphene?

graphene==2.1.8
graphene-django==2.9.0
django-graphql-auth==0.3.8

@PedroBern
Copy link
Owner

PedroBern commented Apr 13, 2020

Removing how?

I mean, adding to USER_NODE_EXCLUDE_FIELDS .

@pors
Copy link
Collaborator Author

pors commented Apr 13, 2020

Shall I close this? Now that we have #27 coming up?

@PedroBern
Copy link
Owner

yes, I close it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants