# GraphQL GraphQL 组件对 [thecodingmachine/graphqlite](https://github.com/thecodingmachine/graphqlite) 进行抽象。 ## 安装 ```bash composer require hyperf/graphql ``` ## 快速开始 ### 简单查询 ```php getBody()->getContents(); $input = json_decode($rawInput, true); $query = $input['query']; $variableValues = isset($input['variables']) ? $input['variables'] : null; return GraphQL::executeQuery($this->schema, $query, null, null, $variableValues)->toArray(); } #[Query] public function hello(string $name): string { return $name; } } ``` 查询: ```graphql { hello(name: "graphql") } ``` 响应: ```json { "data": { "hello": "graphql" } } ``` ### 类型映射 ```php name = $name; $this->price = $price; } #[Field] public function getName(): string { return $this->name; } #[Field] public function getPrice(): ?float { return $this->price; } } ``` 在 `GraphQLController` 中加入 ```php