Get started with apollo server with node.js:

Install:

npm install --save apollo-server graphql

index.js:

const { ApolloServer, gql } = require('apollo-server');

const books = [
{
title: 'Harry Potter and the Chamber of Secrets',
author: 'J.K. Rowling',
},
{
title: 'Jurassic Park',
author: 'Michael Crichton',
},
]; const typeDefs = gql`
# Comments in GraphQL are defined with the hash (#) symbol.
type Book {
"Title of the book, this will appear in graphql playground"
title: String
author: String
} # The "Query" type is the root of all GraphQL queries.
# (A "Mutation" type will be covered later on.)
type Query {
books: [Book]
}
`; // Resolvers define the technique for fetching the types in the
// schema. We'll retrieve books from the "books" array above.
const resolvers = {
Query: {
books: () => books,
},
}; const server = new ApolloServer({ typeDefs, resolvers }); server.listen().then(({ url }) => {
console.log(`

最新文章

  1. 相克军_Oracle体系_随堂笔记008-存储结构
  2. Oracle恢复删除数据 && connect by 树形结构查询
  3. BZOJ2773 : ispiti
  4. xx
  5. UVA 11610 Reverse Prime (数论+树状数组+二分,难题)
  6. 启动 mysql 失败 Warning:The /usr/local/mysql/data directory is not owned by the 'mysql' or '_mysql'
  7. IntelliJ IDEA 14 利用JRebel实现热部署 二
  8. C语言和C++中动态申请内存
  9. Linux网桥
  10. AndroidUI 布局动画-点九PNG技术
  11. NYoj 部分和问题(深搜经典)
  12. ORM项目中小知识点积累
  13. 借用nginx.vim工具进行语法高亮和格式化配置nginx.conf文件
  14. [NOI2012]随机数生成器
  15. Ubuntu中安装和配置 Java JDK,并卸载自带OpenJDK(以Ubuntu 14.04为例)
  16. event.stopPropagation(),event.preventDefault()和return false的区别
  17. RN TextInput用法
  18. windows开启Apache的mod_rewrite模块
  19. spring boot整合JWT例子
  20. Cocos2d-x 2.2.3 使用NDK配置编译环境

热门文章

  1. 【ZOJ4067】Books(贪心)
  2. go环境安装
  3. [译] 如何像 Python 高手一样编程?
  4. android 研究的环境搭建、高效工具、网站资源
  5. linux内核分析之进程地址空间【转】
  6. wchar_t类型的几个函数
  7. c/c++中const用法总结
  8. Centos 查看进程的几条命令
  9. C/51单片机
  10. NetStream配置