2 • Full Stack developer. • Working at Affirm, responsible of interservice communication with GraphQL… we’re hiring! ;) • pyjade, validate_email, interpy, jsjinja, promise, gdom… github.com/syrusakbary
15 • /all_talks_with_user_name_and_avatar “Could you please add an option to get the data back without this field but with this extra field for that new view that I’m making?” • Logic of fetching is moved to the server • Each time the client changes any data fetching requirements the server has to be updated (even if the schema/ models remain constant) • Difficult to scale
25 • Query validation • Strictly typed: input and output • No data Underfetching / Overfetching • Introspection • Resolver Context • One roundtrip for data fetching • Backend agnostic Advantages of GraphQL
28 • Most starred GraphQL framework (excluding FB implementation) - 750 stars… much like! • Used by 20+ companies in production (Affirm included) • Large community • Supports Python 2.7+ and 3.2+ • Fully compatible with Django 1.6+ Some Graphene info
32 { me { name talks { title time } } } class Query(graphene.ObjectType): me = graphene.Field(User) class User(graphene.ObjectType): name = graphene.String() talks = graphene.List(Talk) GraphQL Query Implementation
33 { me { name talks { title time } } } class Query(graphene.ObjectType): me = graphene.Field(User) class User(graphene.ObjectType): name = graphene.String() talks = graphene.List(Talk) class Talk(graphene.ObjectType): title = graphene.String() time = DateTime() GraphQL Query Implementation
34 class Query(graphene.ObjectType): me = graphene.Field(User) class User(graphene.ObjectType): name = graphene.String() talks = graphene.List(Talk) class Talk(graphene.ObjectType): title = graphene.String() time = DateTime()
38 class Talk(models.Model): title = models.CharField(max_length=50) time = models.DateTimeField() speaker = models.ForeignKey(User, related_name='talks') class User(models.Model): name = models.CharField(max_length=50) avatar = models.ImageField()
43 • Easier to maintain than REST API’s • 1-click documentation and UI (GraphiQL) • Quick integration in Frontend with React thanks to Relay • Seamless integration with Django • Much faster development process Why Graphene/GraphQL is better