mathsgod/r-graphql

此软件包最新版本(1.5.0)没有提供许可证信息。

PHP的GraphQL

1.5.0 2020-05-20 09:20 UTC

This package is auto-updated.

Last update: 2024-09-07 12:25:49 UTC


README

PHP Composer

r-graphql

try {
    $schema = Schema::Build(file_get_contents(__DIR__ . "/schema.gql"), $this->app);
    
} catch (Exception $e) {
    return ["error" => [
        "message" => $e->getMessage()
    ]];
}

$this->request->getBody()->getContents();
$input = json_decode($input, true);
$query = $input['query'];
$variableValues = $input['variables'];

$schema->debug=true;//debug mode

$result = $schema->executeQuery($query, $variableValues);

$this->write(json_encode($result));

添加了标量函数

JWT

try {
    $schema = Schema::Build(file_get_contents(__DIR__ . "/schema.gql"), $this->app);
    $schema->validation($jwt, $key, function ($payload)  {
        print_r($payload);
    });
} catch (Exception $e) {
    return ["error" => [
        "message" => $e->getMessage()
    ]];
}