【问题标题】:KeystoneJS as back-end with Flutter as front-endKeystoneJS 作为后端,Flutter 作为前端
【发布时间】:2020-05-08 02:31:50
【问题描述】:

使用KeystoneJSFlutter for web 开发的前端是否可能/可行?这样做有意义吗?任何提示将不胜感激。

【问题讨论】:

    标签: flutter keystonejs flutter-web


    【解决方案1】:

    Keystonejs 是任何其他提供无头 cms 功能的后端。如果 Flutter 中可用,您可以像使用 GraphQL 客户端的任何其他后端一样使用它。

    我看到 Flutter 确实做到了support http request,您可以使用此功能通过普通的 http 查询(http 包)调用 GraphQL。从User 列表中获取所有用户的示例查询

    var client = http.Client();
    try {
      var response = await client.post('https://keystoneproject.com/admin/api',
          body: { 'query': 'query { allUsers { id name email isAdmin }}' });
     // this gives you result in JSON format `{ data: { allusers { id: "id value", name: "name of user", email: "email of user", isAdmin: false } }
      print(await client.get(response.bodyFields['data']));
    } finally {
      client.close();
    }
    
    

    如果您的查询有任何参数,正文还应包含 variable 字段(请参阅 GraphQL 参考以了解其工作原理,我认为这不是答案的范围)

    【讨论】:

      猜你喜欢
      • 2021-10-25
      • 1970-01-01
      • 2014-10-21
      • 2016-11-15
      • 2018-05-04
      • 1970-01-01
      • 2019-01-05
      • 2015-09-14
      • 2018-06-26
      相关资源
      最近更新 更多