apollo

updateQueries after GraphQL mutation not working with the Apollo client

微笑、不失礼 提交于 2019-12-31 02:07:25
问题 After I'm sending a createMessage mutation in my app, I want to update the local ApolloStore using updateQueries. My setup looks as follows: const ChatWithAllMessages = graphql(allMessages, {name: 'allMessagesQuery'})(Chat) export default graphql(createMessage, { props({ownProps, mutate}) { return { createMessageMutation(text, conversationId) { return mutate({ variables: { text, conversationId }, updateQueries: { allConversations: (previousState, {mutationResult}) => { console.log('Chat - did

(三)SpringBoot整合Apollo

こ雲淡風輕ζ 提交于 2019-12-30 18:17:07
一、将Apollo的源码依赖打入到本地仓库      1、解压apollo-master.zip,进入apollo-master\scripts目录   2、点击build.bat文件就能打入依赖(要配置好maven的环境,他会自动的找到你maven的本 地仓库) 二、创建一个SpringBoot项目   1、创建项目springboot-apollo   2、导入依赖信息 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.1.RELEASE</version> <relativePath /> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <spring-cloud

How to pass root parameters in the resolver function of a nested query?

青春壹個敷衍的年華 提交于 2019-12-30 11:24:23
问题 I have a query of the following nature Category1(name: $cat1){ Category2(secondName: $cat2){ secondName }} My schema is like so: const Query = new GraphQLObjectType({ name: 'Query', fields: { Category1: { type: new GraphQLList(Category1Type), args: { name }, resolve: resolveCategory1 }} }) And then the Category1Type is defined as: const Category1Type = new GraphQLObjectType({ name: 'Category1', description: '<>', fields: () => ({ name: { type: GraphQLString }, category2: { type: new

GraphQL how to avoid duplicate code between input and output types

≡放荡痞女 提交于 2019-12-30 06:14:28
问题 I'am new to GraphQL but I really like it. Now that I'am playing with interfaces and unions, I'am facing a problem with mutations. Suppose that I have this schema : interface FoodType { id: String type: String composition: [Ingredient] } type Pizza implements FoodType { id: String type: String pizzaType: String toppings: [String] size: String composition: [Ingredient] } type Salad implements FoodType { id: String type: String vegetarian: Boolean dressing: Boolean composition: [Ingredient] }

How to call a GraphQL query/mutation from an Express server backend?

别等时光非礼了梦想. 提交于 2019-12-30 03:12:42
问题 My frontend is localhost:3000 , and my GraphQL server is localhost:3333 . I've used react-apollo to query/mutate in JSX land, but haven't made a query/mutation from Express yet. I'd like to make the query/mutation here in my server.js . server.get('/auth/github/callback', (req, res) => { // send GraphQL mutation to add new user }); Below seems like the right direction, but I'm getting TypeError: ApolloClient is not a constructor : const express = require('express'); const next = require('next

GraphQL - How to respond with different status code?

℡╲_俬逩灬. 提交于 2019-12-29 04:43:50
问题 I'm having a trouble with Graphql and Apollo Client. I always created differents responses like 401 code when I using REST but here I don't know how I to do a similar behavior. When I get the response I want it go to the catch function. I have this code in the front: client.query({ query: gql` query TodoApp { todos { id text completed } } `, }) .then(data => console.log(data)) .catch(error => console.error(error)); Can anybody help me? 回答1: The way to return errors in GraphQL (at least in

springboot 集成apollo

我的梦境 提交于 2019-12-26 12:30:42
直接干货,程序员最爱 第一步,pom中添加依赖 <!--集成阿波罗 --> <dependency> <groupId>com.ctrip.framework.apollo</groupId> <artifactId>apollo-client</artifactId> <version>1.5.0</version> </dependency> 第二步 application.properties 添加配置文件(这样配置默认指项目的 application命名空间 ) apollo.bootstrap.enabled=true app.id=switch(阿波罗项目创建的appid) 第三步 window 创建C:\opt\settings 目录 ,目录下放入 server.properties 文件 env=dev apollo.meta=http://ip(apollo服务坐在的机器):8088 第四步 程序中获取配置的方式 1.通过@value注解获取配置值 例如: @Value(“${test}”) private String test; 2.通过@ConfigurationProperties注入到bean对象中获取配置信息 例如: @ConfigurationProperties(prefix=”test”) Public class Myprop{ private

002-apollo安装2

百般思念 提交于 2019-12-26 00:41:11
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> apollo安装 安装的mysql版本要求在5.6.5+ 运行命令 SHOW VARIABLES WHERE Variable_name = 'version'; 下载包地址: https://github.com/ctripcorp/apollo/releases wget https://github.com/ctripcorp/apollo/releases/download/v1.5.1/apollo-configservice-1.5.1-github.zip wget https://github.com/ctripcorp/apollo/releases/download/v1.5.1/apollo-adminservice-1.5.1-github.zip wget https://github.com/ctripcorp/apollo/releases/download/v1.5.1/apollo-portal-1.5.1-github.zip 另一个版本 wget https://github.com/ctripcorp/apollo/releases/download/v1.4.0/apollo-adminservice-1.4.0-github.zip wget https:/

手机升级Android10,APP竟然闪退了

允我心安 提交于 2019-12-25 18:36:05
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 工作中的惊喜不断,今天遇到一个问题,一个客户的手机升级为最新的Android 10系统后,原来的我们项目的APP一点击Icon启动APP就闪退,根本不能用。 一开始怀疑是App版本兼容问题,查看项目app/build.gradle文件中配置如下: android { compileSdkVersion 27 buildToolsVersion "27.0.3" defaultConfig { multiDexEnabled true applicationId "com.huaxing.alpha.apps.apollo" // "com.huaxing.alpha.apps.apollo" 正式的极光推送包名,// "com.astarup.app" 测试报名 minSdkVersion 23 targetSdkVersion 27 versionCode 49 versionName "5.5.3" manifestPlaceholders = [ JPUSH_APPKEY: "d21c04aa23b0050dea5bf85c", //"d21c04aa23b0050dea5bf85c", // efd166b53c414825b0d3afe7 是测试的key APP_CHANNEL :

Meteor/Apollo: SSL Access for HTTPS and WS?

安稳与你 提交于 2019-12-25 11:56:45
问题 I’m trying to get SSL working in Meteor for https and websockets. I’m getting this error: (STDERR) Error: listen EACCES 0.0.0.0:443 Here's my setup. For SSL access I have installed nourharidy/meteor-ssl. I can use any comparable package or approach that people have found useful! As required by nourharidy/meteor-ssl, in server/main.js I have: SSL('/path/to/private/server.key','/path/to/private/server.crt', 443); Here's the rest of my setup: My ROOT_URL environment variable is: https://10.0.1