linkorb/graphael 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

linkorb/graphael

Composer 安装命令:

composer require linkorb/graphael

包简介

Graphael: GraphQL Server builder

README 文档

README

Graphael is a framework for rapidly building GraphQL API Servers.

Usage

Create a new project directory, and add the following line to your composer.json in the require section:

"require": {
  "linkorb/graphael": "^1.0"
}

Create a public/ directory, with an index.php file like the following:

<?php

use Graphael\Server;
use Symfony\Component\Dotenv\Dotenv;

$loader = require_once __DIR__.'/../vendor/autoload.php';

// Load .env file if it exists
$envFilename = __DIR__ . '/../.env';
if (file_exists($envFilename)) {
    $dotenv = new Dotenv();
    $dotenv->load($envFilename);
}

// Application level configuration
$config = [
    'environment_prefix' => 'MY_API_',
    'type_namespace' => 'MyApi\\Type', //
    'type_path' => __DIR__ . '/../src/Type' // Directory to scan for Type classes
    'type_postfix' => 'Type',
];

// Instantiate a GraphQL server based on the configuration
$server = new Server($config);
$server->handleRequest();

Application configuration

The server is being instantiated with a $config array that contains the following configuration required options:

  • environment_prefix: Prefix of your environment config variables
  • type_path: Directory to scan for Type class files
  • type_namespace: Namespace of your Type classes. Should match PSR 4 namespace in your composer.json
  • type_postfix: Postfix of your type classes. Defaults to Type.

And following optional:

  • jwt_username_claim: Claim in JWT that will be used to get username (default: 'username')
  • jwt_roles_claim: Claim in JWT for user roles (default: 'roles')
  • jwt_default_role: Default user role in case of absence roles claim (default: 'AUTHENTICATED')

Environment configuration

Create a .env file (or use other means to configure your application's environment variables).

Each variable is prefixed with the environment_prefix defined earlier, in this example MY_API_:

MY_API_DEBUG=1
MY_API_PDO_URL=mysql://username:password@localhost/my_db
MY_API_JWT_KEY=supersecret

Supported environment variables:

  • DEBUG: Set to 1 to run the app in debug mode
  • PDO_URL: Connection string to your database. Supports all PDO backends
  • JWT_KEY: Optional. If defined, the API only allows connections with JWTs signed with this key. Can be a string value or an absolute path to a public key file.

Authentication

If the JWT_KEY environment variable is defined, the server checks for a JWT in one of two places:

  1. A jwt query parameter (i.e. /graphql?jwt=abc.def.ghi)
  2. A Authorization HTTP header (i.e. Authorization: Bearer abc.def.ghi)

统计信息

  • 总下载量: 702
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固