Giter VIP home page Giter VIP logo

think-graphql's Introduction

Think GraphQL

Better GraphQL SDK for thinkphp 5

文档

这里是本项目的文档地址,建议您阅读后再进一步使用。

如果您不知道GraphQL是什么,建议您阅读GraphQL的官方文档

声明

  1. 使用GraphQL需要您事先了解GraphQL的运作机制。

  2. 本项目是在graphql-php的基础上二次封装,所有的Type都完全兼容graphql-php

  3. 在使用前建议您阅读文档、查看Demo来了解使用方法。

安装

$ composer require smilecc/think-graphql:dev-master

注意:由于ThinkPHP 5.1对比5.0有较大改变,所以目前只支持新版5.1。

使用

首先需要在/application/command.php中增加一个指令。

<?php

return [
    'smilecc\think\GraphQLCommand'
];

然后在项目根目录下使用如下命令初始化框架

$ php think graph init

运行该命令之后如果提示初始化成功,则可以在/config/graph.php看到生成出的配置文件,以及在/application/http/graph文件夹下生成出的实例项目。

在初始化完毕之后,你可以使用GraphQL的测试工具请求http://localhost/api/graph进行尝试,正确安装的情况下会有如下的响应。

Query内容:

{
    user(id: 1){
    id
    nickname
    created_time
  }
}

响应内容:

{
  "data": {
    "user": {
      "id": "1",
      "nickname": "TestUser",
      "created_time": "1533028910"
    }
  }
}

最后

如果您有任何的疑问和建议可以在Issues中反馈给我。

讨论群

如果有不懂或疑问,欢迎加入Q群进行交流,在加群之前请您知悉。

  • 请勿发广告、推广、发黄赌毒等不和谐言语。
  • Bug等相关问题仍需提Issues,我会尽快处理,目的是更好的为其他开发者提供参考。

think-graphql's People

Contributors

smilecc avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.