Apollo Server is a community-maintained open-source GraphQL server. It works with many Node.js HTTP server frameworks, or can run on its own with a built-in Express server. Apollo Server works with any GraphQL schema built with GraphQL.js--or define a schema's type definitions using schema definition language (SDL).
Read the documentation for information on getting started and many other use cases and follow the CHANGELOG for updates.
Apollo Server is built with the following principles in mind:
Anyone is welcome to contribute to Apollo Server, just read CONTRIBUTING.md, take a look at the roadmap and make your first PR!
To get started with Apollo Server:
npm install apollo-server-<integration> graphql
There are two ways to install Apollo Server:
apollo-server
package.express
, koa
, hapi
, etc.), use the appropriate Apollo Server integration package.For more info, please refer to the Apollo Server docs.
In a new project, install the apollo-server
and graphql
dependencies using:
npm install apollo-server graphql
Then, create an index.js
which defines the schema and its functionality (i.e. resolvers):
const { ApolloServer, gql } = require('apollo-server');
// The GraphQL schema
const typeDefs = gql`
type Query {
"A simple type for getting started!"
hello: String
}
`;
// A map of functions which return data for the schema.
const resolvers = {
Query: {
hello: () => 'world',
},
};
const server = new ApolloServer({
typeDefs,
resolvers,
});
server.listen().then(({ url }) => {
console.log(`�� Server ready at ${url}`);
});
Due to its human-readability, we recommend using schema-definition language (SDL) to define a GraphQL schema--a
GraphQLSchema
object fromgraphql-js
can also be specified instead oftypeDefs
andresolvers
using theschema
property:const server = new ApolloServer({ schema: ... });
Finally, start the server using node index.js
and go to the URL returned on the console.
For more details, check out the Apollo Server Getting Started guide and the fullstack tutorial.
For questions, the Apollo community forum is a great place to get help.
While the standalone installation above can be used without making a decision about which web framework to use, the Apollo Server integration packages are paired with specific web frameworks (e.g. Express, Koa, hapi).
The following web frameworks have Apollo Server integrations, and each of these linked integrations has its own installation instructions and examples on its package README.md
:
A request context is available for each request. When context
is defined as a function, it will be called on each request and will receive an object containing a req
property, which represents the request itself.
By returning an object from the context
function, it will be available as the third positional parameter of the resolvers:
new ApolloServer({
typeDefs,
resolvers: {
Query: {
books: (parent, args, context, info) => {
console.log(context.myProperty); // Will be `true`!
return books;
},
}
},
context: async ({ req }) => {
return {
myProperty: true
};
},
})
The Apollo Server documentation contains additional details on how to get started with GraphQL and Apollo Server.
The raw Markdown source of the documentation is available within the docs/
directory of this monorepo--to contribute, please use the Edit on GitHub buttons at the bottom of each page.
If you wish to develop or contribute to Apollo Server, we suggest the following:
Fork this repository
Install Direnv (a tool that automatically sets up environment variables in project directories) or nvm. We use nvm to ensure we're running the expected version of Node (and we use Direnv to install and run nvm automatically).
Install the Apollo Server project on your computer
git clone https://github.com/[your-user]/apollo-server
cd apollo-server
direnv allow # sets up nvm for you; if you installed nvm yourself, try `nvm install` instead
npm install
npm test
npm run pretest && npx jest packages/apollo-server-foo/src/__tests__/bar.test.ts
. Note that you do need to re-compile TypeScript before each time you run a test, or changes across packages may not be picked up. Instead of running npm run pretest
from scratch before each test run, you can also run tsc --build tsconfig.json --watch
in another shell, or use the VSCode Run Build Task
to run that for you.Are you stuck? Want to contribute? Come visit us in the Apollo community forum!
Apollo builds open-source software and a graph platform to unify GraphQL across your apps and services. We help you ship faster with:
Check out the Odyssey learning platform, the perfect place to start your GraphQL journey with videos and interactive code challenges. Join the Apollo Community to interact with and get technical help from the GraphQL community.
Apollo - Server Http 接口文档 https://ctripcorp.github.io/apollo/#/zh/usage/other-language-client-user-guide ConfigFileController 带缓存的Http接口从Apollo读取配置 接口会从缓存中获取配置,适合频率较高的配置拉取请求,如简单的每30秒轮询一次配置 // 使用 Guava
不懂的地方还是有很多,分享一下学习的心得,如果有错误,还望各位大佬斧正~ 什么是GraphQL GraphQL,是Facebook开源的一种api查询语言,对查询数据提供了一套完整的描述,客户端可以精准的获取需要的数据,而没有任何冗余 最基础的查询方式如上图,左边是请求,右边是响应,我希望获取todoList这个集合,集合里的每一个元素都包括_id,content,completed字段,服务端返
https://cyber-rt.readthedocs.io/en/latest/CyberRT_Python_API.html https://cyber-rt.readthedocs.io/en/latest/api/pythonapi.html 1. 背景 Cyber RT 核心代码是由 C++ 开发,同时为了方便开发者,提供了 Python 接口。 2. Cyber RT Python
apollo是一款优秀的分布式配置中心,而且目前公司中也是采用apollo来作为配置中心。关于apollo具体的内容,推荐大家去看官网,本文主要讲在apollo的1.6.0版本之前,基于现有apollo,额外搭建新的环境。 1、为何只适用1.6.0版本之前? 因为在1.6.0之前,apollo需要新增自定义环境,需要修改代码中的枚举类,以及在portal的数据库中进行相关配置。而且1.6.0之后
Apollo Server开箱支持Apollo Engine,只是由于某些不可知的原因Apollo Engine的 API 在国内不可访问(我是真不知道为什么这个 API 会被墙的),所以只能另外想办法了. Apollo Server本身有一个Apollo Tracing可以用于性能监控的扩展,通过扩展Apollo Tracing收集指标传输到分布式跟踪系统中. 另外有一个开源库Apollo Op
-Denv=fat -Dapollo.cluster=stg 转载于:https://www.cnblogs.com/zfzf1/p/9935696.html
metaService这个服务是用来提供“元服务”的,我们可以看到源码中只有一个DiscoveryService和一个ServiceController,DiscoveryService封装了三个方法,通过EurekaClient分别获取 Admin Service服务列表(IP+Port) Config Service服务列表(IP+Port) meta Service服务列表(IP+Port)
Apollo简单操作 1、apollo安装和配置: 下载地址: http://www.apache.org/dyn/closer.cgi?path=activemq/activemq-apollo/1.7/apache-apollo-1.7-unix-distro.tar.gz 解压后对文件目录赋权限后就可以开始安装: zqgame@kickseed:/data/apache$apache-ap
本实例中同时创建了Service和Client #include "cyber/examples/proto/examples.pb.h" #include "cyber/cyber.h" using apollo::cyber::examples::proto::Driver; int main(int argc, char
当我们使用RESTFul的风格进行编码的时候有没有注意过一个问题,我们的请求是与依赖息息相关的。例如我有一个通讯录,点击某个人的时候显示某个人的基本信息,那么这时候我们的请求就是与userid相关的。实际的一个请求可能更加复杂,例如依赖条件不止一个,但是我们传统写的时候都是当这里的userid发生变化或者是某一组条件发生变化的时候再去发起新的请求。那么这组逻辑可否抽象出来呢 ?例如当某一个状态或一
阿波罗启动不起来,一直报错:Config service failed to start in 120 seconds! Please check ./service/apollo-ser 解决方案:延长启动时间 改成600s 修改demo.sh declare -i max_counter=120 # 120*5=600s
Apollo(阿波罗)是携程框架部门研发的分布式配置中心,能够集中化管理应用不同环境、不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限、流程治理等特性,适用于微服务配置管理场景。 Swoft 基于 Apollo 提供的 API,在之上进行封装,使之能在 Swoft 中快速使用。 安装 swoft/whoops 作为一个额外的扩展组件,需要手动安装: Composer 安装 com
Apollo以ActiveMQ原型为基础,是一个更快、更可靠、更易于维护的消息代理工具。Apache称Apollo为最快、最强健的 STOMP(Streaming Text Orientated Message Protocol,流文本定向消息协议)服务器。 Apollo的特性如下: 支持Stomp 1.0和Stomp 1.1协议 主题和队列 队列浏览器 主题持久订阅 镜像队列 可靠的消息传递 消
Apollo Client 是一个全功能的 GraphQL 客户端,用于 React 、Angular 的交互。允许你轻松通过 GraphQL 获取数据并构建 UI 组件。
Glimmer Apollo: Ember and Glimmer integration for Apollo Client. Documentation Visit glimmer-apollo.com to read the docs. Compatibility Apollo Client v3.0 or above GlimmerX v0.6 or above Node.js v12 o
Apollo Angular Apollo Angular allows you to fetch data from your GraphQL server and use it in building complex and reactive UIs using the Angular framework. Apollo Angular may be used in any context t
apollo-link ⚠️ THIS PROJECT HAS BEEN DEPRECATED ⚠️ The Links in this repo have been migrated to the apollo-client project (as of >= @apollo/client@3.0.0). Please refer to the Apollo Client migration g