Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Code First Approach on GraphQL Using Graphene D...

Code First Approach on GraphQL Using Graphene Django

Ngalam Backend Community

October 28, 2019
Tweet

More Decks by Ngalam Backend Community

Other Decks in Technology

Transcript

  1. Code First Approach on GraphQL using Graphene Django Aulia’ Illahi

    BackEndEngineer DegetekStudio @barungerti 28 OKT 2019
  2. Today’s Talk • Brief about GraphQL • SDL/Schema First •

    Code First (Main Topics) • Introduction GraphQL with graphene-django • Hands-on implementing code first using graphene-django
  3. Brief about GraphQL • GraphQL is a query and manipulation

    language for API. Created by Facebook 2012 → Open Source 2015 • Graphql workflow: − Created by defining types and fields types, − then providing functions for each field on each type.
  4. Type Reference • Schema • Scalars(String, Int, Float, Boolean,ID,etc) •

    List & Non-Null • ObjectType & DjangoObjectType • ENUM • Interface • Unions
  5. Why GraphQL? • Single Endpoints • DX(Developer Experience) • Solve

    Underfetching • Solve Overfetching • Rapid Development
  6. Schema(SDL) First • Making schema design a priority in the

    development process. • schema-first approach, you describe your GraphQL schema in SDL and hook up your business logic using ariadne-graphql library.
  7. 1. Inconsistencies between schema definition and resolvers • Schema and

    resolver should be match. • This gonna be trouble if schema growing big.
  8. 3. Redundancy in schema definitions (code reuse) • Another question

    is how to reuse SDL definitions. • A common example for this issue are Relay-style connections. While providing a powerful approach to implement pagination, they require a lot of boilerplate and repeated code.
  9. 4. IDE support & developer experience SDL is typically represented

    as plain strings in your programs Solution/Tools: → graphql-tag(gql) → plugin apollo graphql on vs code
  10. 5. Composing GraphQL schema Compose number of existing schema into

    a single schema. Solutions/Tools: → schema stitching → schema delegation
  11. Code First • Code-First/Resolver-First approach, you describe model and graphene-django

    will generate schemas as Python Type Object based on the graphene-django library. • And just describe resolver and mutation
  12. GraphQL with graphene-django • Graphene is a library that provides

    tools to implement a GraphQL API in Python using a code-first approach. • Graphene is fully featured with integrations for the most popular web frameworks and ORMs.
  13. Graphene Django Operation Queries : • fetching API to the

    server(query language) Mutation: • allow to create , update , and delete (Manipulation Language) to the server. • Subscriptions: • Listen every changes on server and send realtime to client