apollo

Multiple Queries/Mutation in Apollo 2.1

点点圈 提交于 2021-02-06 08:45:51
问题 I need some help using the new Query and Mutation component in Apollo 2.1, especially with multiple queries and mutations. I have the following problems: I have a graphql request that depends on a previous graphql result, how can I deal with this? How do I add two different mutations (in my component I need to do two different actions) in a component that already has a query? 回答1: edit 2019/08/24 from the Apollo docs: The new hooks API for Apollo Client is a simpler way to fetch data in your

应用配置管理演变及apollo概念拆解

。_饼干妹妹 提交于 2021-02-06 01:28:03
前言 应用程序在运行的时候往往需要依赖一些配置信息进行逻辑运算,而且这些配置基本上伴随着应用程序的整个生命周期。 一般来说配置是独立于程序代码的的只读变量。应用程序去读取配置来改变自己的行为,但是其不能改变配置,而是交由其他入口完成修改这一动作。 故配置需要进行管理,同一个应用在不同的部署环境(开发、测试、预生产、生产)经常需要不同的配置,所以需要有便捷、完善的配置管理流程去进行管理。 代码配置管理的演变 开端 最开始的配置是如何编写及放置的呢? 当然是代码写到哪里,配置就加到哪里,这是最早期和顺手的做法,如下图。 (图中的提示语其实就是一个配置项) 这种做法最大的弊端就是:1、不能复用,一次修改,处处修改;2、不能按照不同环境所需进行调整。所以,此处应当进行抽离。 分工 逻辑代码一类,配置项一类,把配置内容进行抽离,独立放置到一个文件中,就是我所说的分工。既然配置项独立出一个文件了,那么后面的按环境加载就好办了。 一般来说,会对不同环境的配置文件使用不同的前缀进行命名,然后相应环境机器上也会有相关的一个环境变量供程序读取,读取后依靠这个环境变量进行按需加载配置文件就好了。 优点: 1、与项目关联紧密; 缺点: 1、更新及发布麻烦,需要修改代码; 2、缺失权限管理,安全性低; 3、不同应用项目配置不能共用; 4、配置零散,分散在各个项目代码中; 分权 按照前一个(分工

应用配置管理演变及apollo概念拆解

这一生的挚爱 提交于 2021-02-05 14:33:20
前言 应用程序在运行的时候往往需要依赖一些配置信息进行逻辑运算,而且这些配置基本上伴随着应用程序的整个生命周期。 一般来说配置是独立于程序代码的的只读变量。应用程序去读取配置来改变自己的行为,但是其不能改变配置,而是交由其他入口完成修改这一动作。 故配置需要进行管理,同一个应用在不同的部署环境(开发、测试、预生产、生产)经常需要不同的配置,所以需要有便捷、完善的配置管理流程去进行管理。 代码配置管理的演变 开端 最开始的配置是如何编写及放置的呢? 当然是代码写到哪里,配置就加到哪里,这是最早期和顺手的做法,如下图。 (图中的提示语其实就是一个配置项) 这种做法最大的弊端就是:1、不能复用,一次修改,处处修改;2、不能按照不同环境所需进行调整。所以,此处应当进行抽离。 分工 逻辑代码一类,配置项一类,把配置内容进行抽离,独立放置到一个文件中,就是我所说的分工。既然配置项独立出一个文件了,那么后面的按环境加载就好办了。 一般来说,会对不同环境的配置文件使用不同的前缀进行命名,然后相应环境机器上也会有相关的一个环境变量供程序读取,读取后依靠这个环境变量进行按需加载配置文件就好了。 优点: 1、与项目关联紧密; 缺点: 1、更新及发布麻烦,需要修改代码; 2、缺失权限管理,安全性低; 3、不同应用项目配置不能共用; 4、配置零散,分散在各个项目代码中; 分权 按照前一个(分工

Files bigger than 16 kb gets corrupted when uploaded, using apollo and graphql

丶灬走出姿态 提交于 2021-01-29 20:11:35
问题 Think i tried everything, but nothing seems to work. I have a React app, and i want to upload pictures to a folder. I am using Apollo server and Graphql. The weird thing is that if the file is less than 17 kb, it works!. But anything bigger than that, the file gets corrupted. I can see the image file in the folder but it is 0kb, and when i try to open it it says that the image contains errors". I don't have a limit to size of items. The resolver: I tried using a different method of doing this

Vue.js apollo graphql sends request to localhost instead to certain endpoint

落花浮王杯 提交于 2021-01-29 07:15:35
问题 I configured a multiclient vue apollo, but for some reason it sends requests only to localhost. However I never specified a localhost endpoint. Here is my config file vue-apollo.js: import Vue from "vue"; import VueApollo from "vue-apollo"; import { createApolloClient, restartWebsockets } from "vue-cli-plugin-apollo/graphql-client"; Vue.use(VueApollo); const AUTH_TOKEN = "apollo-token"; const httpsEndpoint = process.env.VUE_APP_GRAPHQL_HTTPS || "https://myst.endpoint.prod/graphql"; export

Query works in GraphiQL but returns empty array in Actual Code while using React Apollo

荒凉一梦 提交于 2021-01-28 21:51:07
问题 I have a simple query like this import gql from "graphql-tag"; export const GET_TODOS_BY_PRODUCT = gql` query getTodosByProduct( $id: ID! $completed: Boolean = false $limit: Int = 100 ) { product(id: $id) { hashtag todos(completed: $completed, limit: $limit) { body } } } `; In GraphiQL, it returns results like - { "data": { "product": { "todos": [ { "body": "Remove Custom Font from Tweet #a2k", "product": { "id": "1439" }, "__typename": "Todo" }, { "body": "Make Site a PWA #a2k", "product": {

Query works in GraphiQL but returns empty array in Actual Code while using React Apollo

跟風遠走 提交于 2021-01-28 21:24:56
问题 I have a simple query like this import gql from "graphql-tag"; export const GET_TODOS_BY_PRODUCT = gql` query getTodosByProduct( $id: ID! $completed: Boolean = false $limit: Int = 100 ) { product(id: $id) { hashtag todos(completed: $completed, limit: $limit) { body } } } `; In GraphiQL, it returns results like - { "data": { "product": { "todos": [ { "body": "Remove Custom Font from Tweet #a2k", "product": { "id": "1439" }, "__typename": "Todo" }, { "body": "Make Site a PWA #a2k", "product": {

Question about parent/child relationships and components

我是研究僧i 提交于 2021-01-28 14:10:26
问题 I'm currently trying to port a project from vuex/REST to vue-apollo. The project shows a list of events, and each event can be expanded to show details, including attendees. So I'm having an EventList component, that fetches the events and all attributes necessary for the list. And I have a EventDetails child component that is expanded from the list onclick. EventDetails requires some event data as well as the list of attendees to render. Problem is, I cannot find an elegant way to build the

React apollo not update data after mutation

我只是一个虾纸丫 提交于 2021-01-28 08:08:16
问题 I have user and user update form, but the problem is that user data in a web app is not updated after mutation. mutation: mutation UserUpdate($user: UserUpdateInput!, $id: String!) { userUpdate(user: $user, id: $id) { id } } query: query UsersItemQuery($id: String!) { userById(id: $id) { id email datetime firstName lastName middleName phone role podcasts { id title } } } I use it on my UserItem.tsx component: const usersItem = useQuery<UsersItemQuery, UsersItemQueryVariables>(usersItemQuery,

React Apollo updating client cache after mutation

巧了我就是萌 提交于 2021-01-28 07:44:34
问题 I am trying to update my chache after succesfully executing a mutation. Here is my query and mutation: export const Dojo_QUERY = gql` query Dojo($id: Int!){ dojo(id: $id){ id, name, logoUrl, location { id, city, country }, members{ id }, disziplines{ id, name } } }`; export const addDiszipline_MUTATION = gql` mutation createDisziplin($input:DisziplineInput!,$dojoId:Int!){ createDisziplin(input:$input,dojoId:$dojoId){ disziplin{ name, id } } }`; and my mutation call: const [createDisziplin] =