apollo

Why use IntrospectionFragmentMatcher?

我的梦境 提交于 2019-12-04 09:31:07
问题 Is there any reason to use IntrospectionFragmentMatcher to determine concrete types of values returned from interface and union fields? I'm talking about apollo-client . I'm using InMemoryCache with addTypename: true , so the type is known the moment the client gets the response. Meanwhile my console is plagued with warnings like these: The only reason I see the documentation hint at is response validation. But why validate the server-sent response at all? If the server is not worth trusting,

关于配置中心调研

≡放荡痞女 提交于 2019-12-04 06:44:28
概述 随着程序功能的日益复杂,程序的配置日益增多:各种功能的开关、参数的配置、服务器的地址…… 对程序配置的期望值也越来越高:配置修改后实时生效,分环境、分集群管理配置,代码安全、审核机制…… 在这样的大环境下,传统的通过配置文件、数据库等方式已经越来越无法满足开发人员对配置管理的需求。 所以,配置中心应运而生。 环境简介 目前公司使用阿里云管理所有服务,原因是为了降低运维成本——傻瓜式运维。 服务部署使用edas,配置管理使用acm。 调研目的 将所有代码中的基础依赖(如数据库、分布式存储等)相关配置回收到配置中心(acm或其他开源工具)管理,提升安全性,使资源可复用,减少因版本差异带来的开发工作量。 方案比较 方案 优点 缺点 备注 edas-acm 运维介入少,便于维护 扩容不方便,每次扩容都要重新为ecs实例单独授权,授权期间扩容实例服务不可用(4xx、5xx) edas团队有优化计划,但目前无排期 第三方 扩容方便 运维成本较高(服务器、人力),负载能力、稳定性待验证 第三方配置中心产品 Disconf:百度开源的配置管理中心, 目前已经不维护了 Spring Cloud Config: Spring Cloud 生态组件,可以和Spring Cloud体系无缝整合。 Apollo: 携程开源的配置管理中心,具备规范的权限、流程治理等特性。 Nacos:

Why isn't Apollo Server a middleware for Express, rather than being a server that accepts Express as a middleware?

旧街凉风 提交于 2019-12-04 05:53:20
I'm just wondering what's the reason for this seemingly awkward configuration (from Getting Started w/ Apollo Server ), const server = new ApolloServer({ // These will be defined for both new or existing servers typeDefs, resolvers, }); server.applyMiddleware({ app }); // app is from an existing express app Why is that I'm calling .applyMiddleware() and feeding it my app rather than using app.use() , it even seems from the docs that Apollo is only answering requests on /graphql wouldn't it be better to follow the Express API of, let apollo = require('apollo-server').ApolloMiddleware app.use( '

React-Apollo, don't run query on component load

半城伤御伤魂 提交于 2019-12-04 04:08:10
I'm using the awesome https://github.com/apollographql/react-apollo library and I'm trying to see if there is a better convention to load data into components than how I'm doing it now. I've set up my components to with the apollo HOC to load data into my components, like so: const mainQuery = gql` query currentProfileData($userId:String, $communityId:String!){ created: communities(id:$communityId) { opportunities{ submittedDate approvalDate status opportunity{ id } } } } `; const mainQueryOptions = { options: { variables: { userId: '_', communityId: '_' }, }, }; const ComponentWithData =

CAT客户端如何从Apollo中读取配置?

試著忘記壹切 提交于 2019-12-04 01:52:52
运行环境 以下就是这个示例的运行环境,如果版本号不一样,区别也应该不会很大,可以根据实际情况做相应调整。 JDK 8 spring boot 2.0.7.RELEASE cat-client 3.0.0 apollo-client 1.3.0 欢迎关注微信公众号: 万猫学社 ,每周一分享Java技术干货。 去除Apollo对CAT的依赖 众所周知,Apollo对CAT是有依赖的,但不是强依赖,而是使用了SPI技术,只有项目里引用了cat-client才会生效。目前我们想把CAT客户端配置放在Apollo里,也就是在CAT客户端初始化之前从Apollo读取相应配置,这就形成了循环依赖,所以首先要去除Apollo对CAT客户端的依赖。 查看Apollo客户端的源码,我发现有一个叫做 MessageProducerManager 的接口,再看一下META-INF\services\com.ctrip.framework.apollo.tracer.spi.MessageProducerManager文件,发现这个接口的默认实现是 DefaultMessageProducerManager ,如果发现CAT客户端被引入时,这个类就会初始化CAT客户端并向CAT客户端发送消息。 MessageProducerManager 接口还有另外一个实现,就是

Apollo Server - Confusion about cache/datasource options

房东的猫 提交于 2019-12-03 16:43:33
The docs ( https://www.apollographql.com/docs/apollo-server/features/data-sources.html#Using-Memcached-Redis-as-a-cache-storage-backend ) show code like this: const { RedisCache } = require('apollo-server-cache-redis'); const server = new ApolloServer({ typeDefs, resolvers, cache: new RedisCache({ host: 'redis-server', // Options are passed through to the Redis client }), dataSources: () => ({ moviesAPI: new MoviesAPI(), }), }); I was wondering how that cache key is used, considering it seems like the caching is actually custom implemented in something like MoviesAPI() and then used via

Missing selection set for object GraphQL+Apollo error

南楼画角 提交于 2019-12-03 13:07:06
I have a set of mutations that trigger the local state of certain types of popups. They're generally set up like this: openDialog: (_, variables, { cache }) => { const data = { popups: { ...popups, dialog: { id: 'dialog', __typename: 'Dialog', type: variables.type } } }; cache.writeData({ data: data }); return null; } And the defaults I pass in look like: const defaults = { popups: { __typename: TYPENAMES.POPUPS, id, message: null, modal: null, menu: null, dialog: null } }; The way they're used in my React code is with a Mutation wrapper component, like so: const OPEN_ALERT_FORM = gql`

How do you get total contributions with Githubs API v4

流过昼夜 提交于 2019-12-03 11:43:12
问题 I have been looking through the Github V4 API docs and I cannot seem to find a way to query total contributions for the year (as displayed on your github profile). Has anyone managed to use the new API to grab some statistics from your personal profile? I am using graphQL and a Personal Access Token on github, and managed to get minimal user profile data; username, profile name etc. 回答1: There is no API for this as such. So there are two ways to go about it. Simple data scraping the user url

【Graphql实践】使用 Apollo(iOS) 访问 Github 的 Graphql API

纵饮孤独 提交于 2019-12-03 11:06:21
最近在协助调研 Apollo 生成的代码是否有可能跨 Query 共享模型的问题,虽然初步结论是不能,并不是预期的结果,但是在调研过程中积累的一些经验,有必要记录下。如果你也对 Graphql 感兴趣,不妨先从 Github 的 Graphql API 来切手实践。 关于 Graphql 官网 尽管只是做客户端的一些实践,我还是建议你先过一遍 Graphql 官网的学习指南。这样能更快速地理解概念。一些客户端库的文档,大部分都只是介绍基本用法。 中文版,可以直接看 http://graphql.cn/ 制作访问 Github API 的 Token Github 中有多个 Token 的概念,你需要的是在 https://github.com/settings/tokens 这个页面。初步接触 Github API 的童鞋,可能会走好多弯路,比如把 Github APP 的token生成规则当成了 API 的访问 Token,几经周折生成出来,却发现完全不好使。 curl -H "Authorization: bearer 7b7cc672235587292be65d11d8ae729b14a0d162" https://api.github.com/graphql 其中的 7b7cc672235587292be65d11d8ae729b14a0d162

py2app problems, getting errors

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to test out the functionality of py2app, for creating standalone mac applications. I generated a setup file for my test code, called 'hello.py'. """ This is a setup.py script generated by py2applet Usage: python setup.py py2app """ from setuptools import setup APP = ['hello.py'] DATA_FILES = [] OPTIONS = {'argv_emulation': True} setup( app=APP, data_files=DATA_FILES, options={'py2app': OPTIONS}, setup_requires=['py2app'], ) And I'm trying to make a simple app that just says hello world with a GUI. Here is the code for hello.py