在线看片18_亚洲性吧_在线污_神马午夜达达兔_奇米色网_在线免费看污

GraphQL

本文檔假定你熟悉GraphQL的概念。如果不是這樣,請首先在官方網站上面了解 GraphQL。

依賴類庫

composer require webonyx/graphql-php

EasySwoole Http 中使用

其實在EasySwoole Http服務器中使用,本質問題在于,如何得到RAW_POST過來的json數據。我們直接貼代碼:

namespace App\HttpController;

use EasySwoole\Http\AbstractInterface\Controller;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
use GraphQL\GraphQL;
use GraphQL\Type\Schema;

class Index extends Controller
{

    function index()
    {
        $queryType = new ObjectType([
            'name' => 'Query',
            'fields' => [
                'echo' => [
                    'type' => Type::string(),
                    'args' => [
                        'message' => Type::nonNull(Type::string()),
                    ],
                    'resolve' => function ($root, $args) {
                        return $root['prefix'] . $args['message'];
                    }
                ],
            ],
        ]);
        $schema = new Schema([
            'query' => $queryType
        ]);

        $input = $this->json();
        $query = $input['query'];
        $variableValues = isset($input['variables']) ? $input['variables'] : null;
        try {
            $rootValue = ['prefix' => 'You said: '];
            $result = GraphQL::executeQuery($schema, $query, $rootValue, null, $variableValues);
            $output = $result->toArray();
        } catch (\Exception $e) {
            $output = [
                'errors' => [
                    [
                        'message' => $e->getMessage()
                    ]
                ]
            ];
        }

        $this->writeJson(200,$output);
    }
}
主站蜘蛛池模板: 鸥美一级片 | 毛片一级片 | 日韩高清二区 | 欧美日本激情 | 欧美精品h| 日韩欧美激情视频 | 中文字幕在线免费视频 | 精品一区二区在线观看 | 超碰成人网 | 亚洲成年人专区 | 久久精品av | 最好看的2019年中文在线观看 | 精品小视频 | 亚洲天堂一区 | 日本欧美一区二区三区 | 色吊丝欧美 | 精品久久久久久中文字幕 | 亚洲日本高清 | 亚拍一区 | 国产精品久久久久久久久久免费 | 色偷偷亚洲| av网站观看 | 新加坡毛片 | 中文字幕视频网站 | 小萝莉末成年一区二区 | 在线亚洲观看 | 日本激情网站 | 91亚洲国产成人精品一区二区三 | 成人极品视频 | 四虎免费观看 | 久草最新视频 | 成人亚洲天堂 | 深夜福利久久 | 最新国产拍偷乱偷精品 | 黄色av中文字幕 | 日韩一区二区在线观看视频 | 国产成人精品毛片 | 福利小视频在线观看 | 成人高清 | 美国做爰xxxⅹ性视频 | 免费在线性爱视频 |