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

OXID Academy - GraphQL within OXID eShop

OXID Academy - 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
https://github.com/OXID-eSales/graphql-catalogue-module
https://github.com/OXID-eSales/graphql-account-module
https://graphqlite.thecodingmachine.io/docs/3.0/features.html

Florian Engelhardt

August 06, 2020
Tweet

More Decks by Florian Engelhardt

Other Decks in Programming

Transcript

  1. GraphQL? GraphQL? a query language for your API ask for

    what you need, get exactly that get many resources in a single request 3
  2. GraphQL? GraphQL? 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 3
  3. Start with a schema definition Start with a schema definition

    type Query { category(id: String!): Category } type Category { id: ID! title: String! active: Bool! articles: [Article] parent: Category siblings: [Category] children: [Category] } type Article { id: ID! title: String! category: Category } 4
  4. How to query that How to query that { query

    { category(id: "943a9ba3050e78b443c16e043ae60ef3") { id title children { id title } } } } 5
  5. What do you get? What do you get? { "data":

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

  7. 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. } } 9
  8. Basic Example - Type Basic Example - Type /** *

    @Type() */ class Category { /** * @Field() */ public function getTitle(): string { return $this->title; } // ... } 10
  9. Basic Example - The Schema Basic Example - The Schema

    type Query { category(id: String!): Category } type Category { title: String! } 11
  10. Howto use this in my module? Howto use this in

    my module? create a namespace mapper class 14
  11. 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 14
  12. 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 14
  13. 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 14
  14. Roadmap - Business Roadmap - Business Queries, mutations and types

    for Catalog - 0.1 Account - in progress Checkout 17
  15. 19