-
Notifications
You must be signed in to change notification settings - Fork 27
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
Allow modify UserType fields to return or filter extra information of the custom user #264
Comments
you link is broken, can you share a minimal example of what you suggest?
IIRC |
So the problem is that injecting an extra field to the UserType is not flexible enough, because by doing so, we allow both: UPDATE the field and READ the field. So basically the lacking feature is, to add read-only fields/information to the user, which COULD BE QUERIED along with user information (when querying UserType), BUT CAN NOT BE MODIFIED through updateUser mutation |
And I suggested some possible solutions
The broken link was not meant to be link but I was just speaking python properties, check this for more information, to demonstrate how we may want calculate extra information of the user but not defining an actual field to the model. |
@LinnaViljami I think I would just add |
I agree, the idea sounds logical (returned UserType being separated from the editable fields) I am quite a beginner with strawberry graphql (I mostly use graphql-django), so I am not sure if then UserType should be defined as interface to allow inheritance. But without considering the technical details, your approach sounds good. Could you post an minimal example how then would be possible to: |
~ class MyUserModel(AbstractUserModel): # ideally `AbstractUserModel` would be provided by gqlauth
some_cool_field: models.CharField()
@strawberry_django.type(model=MyUserModel)
class MyUserType(GqlAuthUserInterface):
some_cool_field: auto
@strawberry.field
def field_not_in_model(self) -> int:
return 2 |
We currently have a Profile model connected to from
In the Graphene implementation, this meant we could reference it as follows:
This is proving challenging to replicate on moving across to Strawberry, resulting in the following error: |
Any updates on that ? |
Not ATM sorry I don't have much time recently. You can open a PR though. |
Description
Allow modify UserType fields to return or filter extra information of the custom user
Expected behavior
All CustomUser model fields should be returned along UserType in mutations and queries.
Returned fields should be able to controlled with django setting, for example FILTER_USER_FIELDS = ['customField1', 'customField2', ...].
The best and most flexible solution could allow calculate extra information without even defining new field to user model but instead just define property or custom function and return a calculated value in graphql response along the other fields of the UserType.
Actual behavior
Currently UserType can be modified only through the USER_FIELDS, with USER_MODEL.USERNAME_FIELD, USER_MODEL.EMAIL_FIELD or gqlauth_settings.UPDATE_MUTATION_FIELDS. This is not enough if we want to define a custom non pk field that user can not modify through mutation.
Requirements
strawberry-django-auth 0.374
The text was updated successfully, but these errors were encountered: