graphql

Mapping array of images leads to the same image repeating on every instance

混江龙づ霸主 提交于 2021-02-05 11:34:50
问题 Im trying to map an object from an array of arrayed images into an image gallery on separate product pages (coming from strapi). The correct number of images appear but it repeats the same image over them. Even on product pages that shouldn't include that image in their respective array. examples - https://imgur.com/a/PKlpofy Ive checked the source and the image src links are all different versions of the same image. - https://imgur.com/a/968w77b GraphIQL - https://imgur.com/a/HvgMA8r Any

GraphQL : Get children of specific implementation

谁说胖子不能爱 提交于 2021-02-05 09:23:29
问题 I'm getting a GraphQL object with a 'children' field. That field is of the type 'X' and has two different implementations, 'Y' and 'Z'. So when I'm doing my query I can do this : { fieldOne fieldTwo children { ... on Y { fieldOne fieldTwo } ... on Z { fieldOne } } } Is there a way for me to only get the children with the Y implementation ? Because if I'm doing this : { fieldOne fieldTwo children { ... on Y { fieldOne fieldTwo } } } I will get and object that looks like this : { fieldOne

What's the difference between GraphQL and rest api

落爺英雄遲暮 提交于 2021-02-05 09:12:33
问题 I want to know what are all reasons of qraphQL to be used instead of rest api . As much I know instead of making multiple requests (to reduce HTTP request), can make a group of HTTP requests in one request using graphQL . Can anybody describe little more, please? Thanks in advance. 回答1: There are many articles covering this question in more details available on the internet. I am trying to give a short overview here. GraphQL offers a couple of advantages over REST. Main difference In a REST

What's the difference between GraphQL and rest api

。_饼干妹妹 提交于 2021-02-05 09:12:06
问题 I want to know what are all reasons of qraphQL to be used instead of rest api . As much I know instead of making multiple requests (to reduce HTTP request), can make a group of HTTP requests in one request using graphQL . Can anybody describe little more, please? Thanks in advance. 回答1: There are many articles covering this question in more details available on the internet. I am trying to give a short overview here. GraphQL offers a couple of advantages over REST. Main difference In a REST

Passing variables to query with complex input types

折月煮酒 提交于 2021-02-04 08:34:29
问题 According to graphQl docs: When you're passing arguments in code, it's generally better to avoid constructing the whole query string yourself. Instead, you can use $ syntax to define variables in your query, and pass the variables as a separate map. https://graphql.org/graphql-js/passing-arguments/ In this context, I'm trying to query the following schema: const typeDefs = " input OrderInputData { date: String! time: String! frequency: String! extras: [Int!] mailAlarm: String phoneAlarm:

How to query multiple images in Gatsby from Strapi using Graphql

旧街凉风 提交于 2021-02-04 08:10:30
问题 I have set up a multiple media(images) field called pictures on my project content type on Strapi and I have added 2 projects with pictures containing 4 images each. I want to query these images in Gatsby using Graphql. This is my plugins array in gatsby-config.js plugins: [ `gatsby-plugin-react-helmet`, { resolve: `gatsby-source-filesystem`, options: { name: `images`, path: `${__dirname}/src/images`, }, }, `gatsby-plugin-sharp`, `gatsby-transformer-sharp`, { resolve: `gatsby-plugin-manifest`

Related Graphql objects giving undefined

流过昼夜 提交于 2021-02-04 06:50:44
问题 I am getting this error when I start the server Error: Expected undefined to be a GraphQL type. UPDATE: I believe this has to do with javascript requiring each other. What is the best way to solve this? I have an account type in file accountTypes.js const { channelType } = require('../channel/channelTypes'); //Define Order type const accountType = new GraphQLObjectType({ name: 'Account', description: 'An account', fields: () => ({ id: { type: new GraphQLNonNull(GraphQLInt), description: 'The

人人都是 API 设计者:我对 RESTful API、GraphQL、RPC API 的思考

浪尽此生 提交于 2021-02-04 04:29:06
梁桂钊 | 作者 有一段时间没怎么写文章了,今天提笔写一篇自己对 API 设计的思考。首先,为什么写这个话题呢?其一,我阅读了《阿里研究员谷朴:API 设计最佳实践的思考》一文后受益良多,前两天并转载了这篇文章也引发了广大读者的兴趣,我觉得我应该把我自己的思考整理成文与大家一起分享与碰撞。其二,我觉得我针对这个话题,可以半个小时之内搞定,争取在 1 点前关灯睡觉,哈哈。 现在,我们来一起探讨 API 的设计之道。我会抛出几个观点,欢迎探讨。 一、定义好的规范,已经成功了一大半 通常情况下,规范就是大家约定俗成的标准,如果大家都遵守这套标准,那么自然沟通成本大大降低。例如,大家都希望从阿里的规范上面学习,在自己的业务中也定义几个领域模型:VO、BO、DO、DTO。其中,DO(Data Object)与数据库表结构一一对应,通过 DAO 层向上传输数据源对象。而 DTO(Data Transfer Object)是远程调用对象,它是 RPC 服务提供的领域模型。对于 BO(Business Object),它是业务逻辑层封装业务逻辑的对象,一般情况下,它是聚合了多个数据源的复合对象。那么,VO(View Object) 通常是请求处理层传输的对象,它通过 Spring 框架的转换后,往往是一个 JSON 对象。 事实上,阿里这种复杂的业务中如果不划分清楚 DO、BO、DTO、VO

从使用角度分析GET和POST的差异性 应用场景

坚强是说给别人听的谎言 提交于 2021-02-01 09:19:27
以前只会用GET和POST,但有时候就会傻傻分不清什么时候该用GET,什么时候该用POST,花了一段时间把这两个东西给琢磨了一遍,特此记录一下。 这里着重讲一下GET和POST一些细节。在讲两者传输区别之前,一个需要注意的就是: 很多人一提到地址栏的传参方式,就联想到GET,其实不管是GET还是POST都可以通过地址URL传递参数,因为参数属于URL的一部分,服务端只要能获取URL就能获取其中的参数。很多浏览器也对URL传参的大小做了限制,一般是2K字节数,很多服务器最多也只处理64K的URL。 GET请求: HTTP协议规定GET请求一般是将数据放在http的header部分,由于header本身只是作为一个标识,并不适合传输大量的数据,所以最好只用于传递一些关键参数信息。GET可以被浏览器缓存,很适合一些请求资源应用场景。 POST请求: HTTP协议规定POST请求一般是将数据放在http的body部分。这样不会受到传输数据的大小限制,理论上可以传输极大的数据包。不过POST请求作为不能被浏览器缓存 HTTP对通过body部分传输数据提供很多种(也就是请求头部对应的Content-Type属性),由于太多,就不一一举例了,就拿postman提供的几种方式作说明: multipart/form-data: 以表单的方式 上传文件 时就是使用的这种方式。 application

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