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

Register multiple choice field as list #1033

Merged
merged 1 commit into from
Nov 28, 2020

Conversation

ulgens
Copy link
Collaborator

@ulgens ulgens commented Aug 26, 2020

MultipleChoiceField was registered as text input when it should be list.

@ulgens ulgens force-pushed the register_MultipleChoiceField_as_list branch from f04f777 to 1142f34 Compare September 28, 2020 07:15
@ulgens ulgens force-pushed the register_MultipleChoiceField_as_list branch 2 times, most recently from 2270767 to cf32389 Compare October 25, 2020 17:20
@ulgens
Copy link
Collaborator Author

ulgens commented Oct 25, 2020

@jkimbo Hey 👋 Should i create another PR for v3?

@jkimbo
Copy link
Member

jkimbo commented Oct 27, 2020

@ulgens the way I've been handling v3 for Graphene-Django is to merge the master branch into v3 every so often. So there is no need to create a PR specifically against the v3 branch.

@ulgens
Copy link
Collaborator Author

ulgens commented Nov 8, 2020

@zbyte64 Any luck here? 🙂

@ulgens ulgens force-pushed the register_MultipleChoiceField_as_list branch from cf32389 to 7aea0a7 Compare November 8, 2020 11:57
Copy link
Collaborator

@zbyte64 zbyte64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@ulgens
Copy link
Collaborator Author

ulgens commented Nov 28, 2020

@zbyte64 Anything missing for a merge? 🙂

@zbyte64 zbyte64 merged commit 4c0c821 into master Nov 28, 2020
@zbyte64 zbyte64 deleted the register_MultipleChoiceField_as_list branch November 28, 2020 18:30
@SantiagoAndre
Copy link

thanks is what i was looking for.
I don't know much about the handling of integrations, are these changes already in the latest version of the framework?
I need this update
thanks

@ulgens
Copy link
Collaborator Author

ulgens commented Dec 1, 2020

@SantiagoAndre This is merged to master but no new release is out yet. You can use it if you install the package over git repository.

@SantiagoAndre
Copy link

SantiagoAndre commented Dec 2, 2020

I found another problem, when I create DjangoFormMutation, and a form input field is a ModelMultipleChoiseFIeld, the response type of Mutation: "Payload", define this field as a list of IDS, the correct thing would be a list field of the model "Subject ", to be able to use the advantages that graphql brings when consuming the api.

class MyForm(forms.Form):
        subject = forms.ModelMultipleChoiceField(label = _("subjects"),
    queryset=Subject.objects.all())
class CreateMonitor(DjangoFormMutation):
    class Meta:
       form_class = RegistryMonitorForm    

Mutation

image

Automatic reponse type of model field

image

How to consume this Mutation

  createMonitor(input: {
         subject: ["U3ViamVjdE5vZGU6MQ==","U3ViamVjdE5vZGU6Mg=="]
    }) {
    subject
   }
  -------------- RESULT --------------------------
{
  "data": {
    "createMonitor": {
      "subject": [
        "1",
        "2"
      ],
      "errors": null
    }
  }
}

Esperated type

image
image

How to consume this Mutation

  createMonitor(input: {
         subject: ["U3ViamVjdE5vZGU6MQ==","U3ViamVjdE5vZGU6Mg=="]
    }) {
    subject{
         edges{
             node{
                   id
                  name
             }
        }
   }
}
   }
  -------------- RESULT --------------------------
{
  "data": {
    "createMonitor": {
     "subject": {
          "edges": [
            {
              "node": {
                "name": "subject name",
                "id": "U3ViamVjdE5vZGU6MQ=="
              }
            }
          ]
        },
      "errors": null
    }
  }
}

This change sounds great, could be add to next release.
Thanks.

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.

4 participants