mage2tv/module-apollo-boost-amd
最新稳定版本:0.3.1.1
Composer 安装命令:
composer require mage2tv/module-apollo-boost-amd
包简介
The popular apollo-boost graphql library transpiled to AMD, wrapped in a Magento 2 module.
README 文档
README
The popular apollo-boost library transpiled to AMD and wrapped in a Magento 2 module.
Usage:
-
Install
mage2tv/module-apollo-boost-amd -
In your JavaScript AMD modules, require
'apollo-boost' -
Use the "exported"
ApolloClientandgqlfunction:
const client = new ApolloAmd.ApolloClient();
const query = ApolloAmd.gql(my_graphql_query);
// or:
const {ApolloClient, gql} = ApolloAmd;
Example:
define(['uiComponent', 'apollo-boost'], function (Component, ApolloAmd) { 'use strict'; const {ApolloClient, gql} = ApolloAmd; const client = new ApolloClient({url: '/graphql'}); const query = gql(` query exampleProducts($count: Int = 1) { products(filter: {} pageSize: $count sort: { name: DESC }) { total_count items { id type_id name sku } } } `); return Component.extend({ defaults: { tracks: { result: true } }, initialize: function () { client.query({ query: query, variables: { count: 3 } }) .then(data => { this.result = data; }) .catch(console.error); return this._super(); } }); });
统计信息
- 总下载量: 21.29k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-28