Pro Yearly is on sale from $80 to $50! »

GraphQL within OXID eShop

GraphQL within OXID eShop

#OXID_eSales
Ever wanted to create a GraphQL API within OXID eShop? The wait is over. We @OXID_eSales released the GraphQL-Base module which allowes you to create GraphQL queries and mutations in OXID.

https://github.com/OXID-eSales/graphql-base-module

8b8824ec70715f8599896375626c20d9?s=128

Florian Engelhardt

November 12, 2019
Tweet

Transcript

  1. GRAPHQL WITHIN OXID ESHOP GRAPHQL WITHIN OXID ESHOP 1

  2. FLORIAN ENGELHARDT FLORIAN ENGELHARDT 2

  3. HUSBAND AND DAD HUSBAND AND DAD 3

  4. WHO ARE YOU? WHO ARE YOU? 4

  5. GraphQL 5

  6. TIME FOR THEORY TIME FOR THEORY a query language for

    your API ask for what you need, get exactly that get many resources in a single request describe what’s possible with a type system 6
  7. START WITH A SCHEMA DEFINITION START WITH A SCHEMA DEFINITION

    type Query { category(id: String!): Category } type Mutation { categoryCreate(category: Category!): Category } type Category { id: ID! title: String! articles: [Article] parent: Category siblings: [Category] children: [Category] } type Article { id: ID! title: String! category: Category } 7
  8. HOW TO QUERY THAT HOW TO QUERY THAT { query

    { category(id: "id-of-category") { id title children { id title } } } } 8
  9. WHAT DO YOU GET? WHAT DO YOU GET? { "data":

    { "category": { "id": "943a9ba3050e78b443c16e043ae60ef3", "title": "Kiteboarding", "children": [ { "id": "0f41a4463b227c437f6e6bf57b1697c4", "title": "Trapeze" }, { "id": "0f4f08358666c54b4fde3d83d2b7ef04", "title": "Kiteboards" } ] } } } 9
  10. 10

  11. GRAPHQLITE GRAPHQLITE Create a complete GraphQL API by simply annotating

    your PHP classes — GraphQLite docs 11
  12. BASIC EXAMPLE - CONTROLLER BASIC EXAMPLE - CONTROLLER class CategoryController

    { /** * @Query() */ public function category(string $id): Category { // Some code that looks for a category and returns it. } } 12
  13. BASIC EXAMPLE - TYPE BASIC EXAMPLE - TYPE /** *

    @Type() */ class Category { /** * @Field() */ public function getTitle(): string { return $this->title; } // ... } 13
  14. BASIC EXAMPLE - THE SCHEMA BASIC EXAMPLE - THE SCHEMA

    type Query { category(id: String!): Category } type Category { title: String! } 14
  15. BASIC EXAMPLE - QUERY BASIC EXAMPLE - QUERY { query

    { category (id: "42") { name } } } 15
  16. HOWTO GET THIS RUNNING IN OXID? HOWTO GET THIS RUNNING

    IN OXID? 16
  17. OXID-ESALES/GRAPHQL-BASE OXID-ESALES/GRAPHQL-BASE bootstrap GraphQLite auth using JWT 17

  18. HOWTO USE THIS IN MY MODULE? HOWTO USE THIS IN

    MY MODULE? 18
  19. HOWTO USE THIS IN MY MODULE? HOWTO USE THIS IN

    MY MODULE? create a namespace mapper class 18
  20. HOWTO USE THIS IN MY MODULE? HOWTO USE THIS IN

    MY MODULE? create a namespace mapper class tag this class graphql_namespace_mapper in services.yaml 18
  21. HOWTO USE THIS IN MY MODULE? HOWTO USE THIS IN

    MY MODULE? create a namespace mapper class tag this class graphql_namespace_mapper in services.yaml create a permission provider class 18
  22. HOWTO USE THIS IN MY MODULE? HOWTO USE THIS IN

    MY MODULE? create a namespace mapper class tag this class graphql_namespace_mapper in services.yaml create a permission provider class tag this class graphql_permission_provider in services.yaml 18
  23. DEMO TIME! DEMO TIME! 19

  24. ROADMAP - BUSINESS ROADMAP - BUSINESS Queries, mutations and types

    for Catalog User (Account) Checkout 20
  25. ROADMAP - TECH ROADMAP - TECH GraphQLite v4 Caching (and

    cache invalidation ) 21
  26. 22

  27. FURTHER READINGS FURTHER READINGS GraphQL GraphQLite oxid-esales/graphql-base oxid-esales/graphql-example oxid-esales/graphql-developer dotbox.org

    @realFlowControl 23