`
sillycat
  • 浏览: 2550976 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

GraphQL 2019(1)Apollo Basic

 
阅读更多
GraphQL 2019(1)Apollo Basic

Client React
https://github.com/apollographql/react-apollo
https://apollographqlcn.github.io/react-docs-cn/
https://juejin.im/post/5cff441ef265da1b6836b32b

Spring Boot Based Server
https://blog.csdn.net/taiyangdao/article/details/75303181
https://www.jianshu.com/p/d6aeeddccaf3
https://juejin.im/post/5d61397bf265da03c92703a3
https://juejin.im/post/5c886063e51d454ffb104bfd
https://github.com/graphql-java-kickstart/graphql-spring-boot
https://github.com/graphql-java/graphql-java
https://www.graphql-java.com/tutorials/getting-started-with-spring-boot/
https://graphql.org/code/#java

Sample
https://github.com/spring-petclinic/spring-petclinic-graphql
https://github.com/graphql-java/awesome-graphql-java

Type System - Query Mutation
Interface & Union Types

GraphQL - Int, Float, String, Boolean, ID

Simple example before I dive into my big project sample
https://github.com/SimonPower/hello-graphql
https://juejin.im/post/5d4fa9b2e51d4561d54de941

Data Loader
https://www.jianshu.com/p/fbd1257116b0

Debug Tool is here
http://localhost:4000/graphql

Try to Query with my code
query {
    getEmployees {
        cursor
      prevCursor
      nextCursor
      totalRecordCount
      hasMoreRecords
      records {
          id
          gmtCreate
          gmtModified
          name
      }
    }
}

Check this Project
https://github.com/graphql-boilerplates/node-graphql-server

Mutation example
mutation {
  signup (email: "luohuazju@gmail.com", password: "12345678", name: "Hua") {
    token
    user {
      id
      email
      name
    }
  }
}

Put this in the header if we need to access login
{
  "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjazVodmF4YXd4bnJwMGIwMHhvMm9qN2k0IiwiaWF0IjoxNTc5MjQ3OTc4fQ.89_D85qTKILtDsIPOj_hwho4ZTdtCfhNztVDZqaIyas"
}

Hashmap in NodeJS
https://www.npmjs.com/package/hashmap
const HashMap = require('hashmap').HashMap;

const mockItems = new HashMap();
mockItems.set("1",
  {
    "id": "1", "gmtCreate": 1579242037, "gmtModified": 1579242037,
    "name": "double11",
    "rankID": "1",
    "ratio": 0.02,
    "minimumAmount": 8000.00
  });
mockItems.set("2", {
    "id": "2", "gmtCreate": 1579242038, "gmtModified": 1579242038,
    "name": "double12",
    "rankID": "2",
    "ratio": 0.01,
    "minimumAmount": 5000.00
  });

function loadAllAllowances() {
    return mockItems.values();
}

function getAllowanceByID(id) {
    return mockItems.get(id);
}

module.exports = {
    loadAllAllowances,
    getAllowanceByID
}


NodeJS Cache
https://github.com/node-cache/node-cache

All options for ApolloServer
https://www.apollographql.com/docs/apollo-server/api/apollo-server/#apolloserver

References:
GraphQL
http://taobaofed.org/blog/2015/11/26/graphql-basics-server-implementation/
http://taobaofed.org/blog/2016/03/10/graphql-in-depth/
https://zhuanlan.zhihu.com/p/28077095
http://imweb.io/topic/58499c299be501ba17b10a9e
https://github.com/chentsulin/awesome-graphql

https://www.jianshu.com/p/2ec22fc1219c

Apollo Server
https://www.jianshu.com/p/70d61aee696b
https://github.com/wenshaoyan/apollo-server-example/blob/master/example-express.js
https://juejin.im/post/5b03cdcd51882542c760eaef
https://juejin.im/post/5ca1d5076fb9a05e512356a3
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics