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

Support for Django Rest Framework serializers #186

Merged
merged 27 commits into from
Jul 24, 2017

Conversation

patrick91
Copy link
Member

@patrick91 patrick91 commented May 28, 2017

Hello from PyConWeb!

I've been working on an integration for Django Rest Framework, to allow the use of its
serializers as GraphQL mutation.

Let me know if this is something you wanted to be merged into graphene-django :)

It's still a work in progress, but I was able to have a working Mutation from a Serializer, still haven't pushed all the code :)

Ideally the code for the Mutation will look like this:

class MyAwesomeMutation(SerializerMutation):
    class Meta:
        serializer_class = MyAwesomeMutation

SerializerMutation will take are of the rest, defining the fields for the output, the fields for the input and the errors.

TODO:

  • converter for the fields
  • converter for the serializer
  • SerializerMutation base class
  • Docs 📝
  • Use six to support Python 2
  • Add missing fields

thanks @simobasso

@coveralls
Copy link

Coverage Status

Coverage decreased (-3.8%) to 89.989% when pulling 531c840 on patrick91:feature/rest-framework into afec960 on graphql-python:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-3.8%) to 89.989% when pulling 531c840 on patrick91:feature/rest-framework into afec960 on graphql-python:master.

@coveralls
Copy link

coveralls commented May 28, 2017

Coverage Status

Coverage decreased (-2.8%) to 91.023% when pulling 3ba9a63 on patrick91:feature/rest-framework into afec960 on graphql-python:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-4.1%) to 89.67% when pulling cae5620 on patrick91:feature/rest-framework into afec960 on graphql-python:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-4.1%) to 89.67% when pulling cae5620 on patrick91:feature/rest-framework into afec960 on graphql-python:master.

@syrusakbary
Copy link
Member

The code looks great!
Might be a good idea to use six for the metaclass (so there is compatibility with Python 2.7).

Once the docs are done, I will help to make all the tests pass in the different environments!

@patrick91
Copy link
Member Author

@syrusakbary thanks!
Shall I make a PR for this one as well? #187

It will allow us to use the latest version of Django Rest Framework and to remove some code :)

@audiolion
Copy link

Would this allow for validations to be done with rest framework serializers? I think it would lower the barrier to switching to Graphene from rest framework, really cool stuff!

@coveralls
Copy link

coveralls commented Jun 23, 2017

Coverage Status

Coverage decreased (-3.8%) to 89.99% when pulling 6c2f682 on patrick91:feature/rest-framework into afec960 on graphql-python:master.

@coveralls
Copy link

coveralls commented Jun 23, 2017

Coverage Status

Coverage decreased (-3.2%) to 90.638% when pulling 6c2f682 on patrick91:feature/rest-framework into afec960 on graphql-python:master.

@syrusakbary
Copy link
Member

The PR #202 is now merged into master. Now the tests should be passing.
Once the missing fields are added I think it should be safe to merge this one :)

@patrick91 patrick91 force-pushed the feature/rest-framework branch from 6c2f682 to c389924 Compare June 26, 2017 08:19
@coveralls
Copy link

coveralls commented Jun 26, 2017

Coverage Status

Coverage decreased (-0.3%) to 92.508% when pulling c389924 on patrick91:feature/rest-framework into 7c52aa3 on graphql-python:master.

@coveralls
Copy link

coveralls commented Jun 26, 2017

Coverage Status

Coverage decreased (-0.3%) to 92.524% when pulling f747102 on patrick91:feature/rest-framework into 7c52aa3 on graphql-python:master.

@coveralls
Copy link

coveralls commented Jun 26, 2017

Coverage Status

Coverage decreased (-0.4%) to 92.423% when pulling 7888fa7 on patrick91:feature/rest-framework into 7c52aa3 on graphql-python:master.

@coveralls
Copy link

coveralls commented Jun 26, 2017

Coverage Status

Coverage decreased (-0.5%) to 92.324% when pulling 5c3306e on patrick91:feature/rest-framework into 7c52aa3 on graphql-python:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.8%) to 92.004% when pulling 5c3306e on patrick91:feature/rest-framework into 7c52aa3 on graphql-python:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.8%) to 92.004% when pulling 5c3306e on patrick91:feature/rest-framework into 7c52aa3 on graphql-python:master.

@coveralls
Copy link

coveralls commented Jun 26, 2017

Coverage Status

Coverage decreased (-0.5%) to 92.324% when pulling 5c3306e on patrick91:feature/rest-framework into 7c52aa3 on graphql-python:master.

@syrusakbary
Copy link
Member

@patrick91 Great! Let me know once is tested :)

@coveralls
Copy link

coveralls commented Jun 29, 2017

Coverage Status

Coverage decreased (-0.6%) to 92.234% when pulling 93bbc19 on patrick91:feature/rest-framework into 7c52aa3 on graphql-python:master.

2 similar comments
@coveralls
Copy link

coveralls commented Jun 29, 2017

Coverage Status

Coverage decreased (-0.6%) to 92.234% when pulling 93bbc19 on patrick91:feature/rest-framework into 7c52aa3 on graphql-python:master.

@coveralls
Copy link

coveralls commented Jun 29, 2017

Coverage Status

Coverage decreased (-0.6%) to 92.234% when pulling 93bbc19 on patrick91:feature/rest-framework into 7c52aa3 on graphql-python:master.

@spockNinja
Copy link
Contributor

I have been testing out this PR on a project and things are going well overall. I have just a couple additions in patrick91#1 -- but I can always make a separate PR to the base fork after this is merged if that's easier.

@patrick91
Copy link
Member Author

patrick91 commented Jul 11, 2017 via email

@spockNinja
Copy link
Contributor

You mean the static "input" name for the graphene.InputObjectType? It doesn't bother me too much right now, but I could definitely see others being more picky about that.

@abdulhaq-e
Copy link

Thanks for your contribution. It's working great so far. Sometimes, one needs to add additional arguments to the serializer when instantiating it. It would be great if the instantiation was moved to a separate method so it can be easily overridden.

@grantmcconnaughey grantmcconnaughey mentioned this pull request Jul 18, 2017
1 task
@coveralls
Copy link

coveralls commented Jul 21, 2017

Coverage Status

Coverage decreased (-0.5%) to 92.356% when pulling 42e9107 on patrick91:feature/rest-framework into 7c52aa3 on graphql-python:master.

@patrick91 patrick91 changed the title [WIP] Support for Django Rest Framework serializers Support for Django Rest Framework serializers Jul 22, 2017
@patrick91
Copy link
Member Author

@abdulhaq-e can you open an issue when this PR is merged? :)

@syrusakbary this is ready to merge! @spockNinja added support for other fields and also nested serializers :)

@abdulhaq-e
Copy link

@patrick91 I'll submit a PR once this is merged.

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.

6 participants