当前位置: 首页 > 编程日记 > 正文

graphql是什么_为什么GraphQL是避免技术债务的关键

graphql是什么

GraphQL (not to be confused with GraphDB or Open Graph or even an actual graph) is a remarkably creative solution to a relatively common problem: How do you enable front end developers to access backend data in exactly the way they need it?

GraphQL(不要与GraphDB或Open Graph甚至是实际的图形混淆)是一个相对常见的问题的极富创造力的解决方案: 如何使前端开发人员以所需的方式完全访问后端数据?

Quick example: We want to display a list of products on a web page. So we write a service which returns a list of products. We make it super RESTful because that’s what someone on a podcast said we should do.

快速示例:我们想在网页上显示产品列表。 因此,我们编写了一个返回产品列表的服务。 我们使它成为超级RESTful,因为这是播客上的某人说我们应该做的。

{"items": [{"id": 2051,"name": "Extension Cord","price": 15,"productType": "Electrical","supplierName": "Northwind","shortDescription": "Outlet not where you need it? Extend your power to the right place at the right time",},{"id": 2053,"name": "LED Lamp","price": 14,"productType": "Hardware","supplierName": "Northwind","shortDescription": "Low power battery operated light",}]
}

Then we slap said products on the page. Go ahead and imagine a slapping sound. Or feel free to use this one here…

然后,我们在页面上拍了说产品。 继续想象一下拍手声。 或随时在这里使用此…

Now that we have everything done, someone decides we also need to display what quantity of each product we have in stock because of course they do.

现在我们已经完成了所有工作,有人决定我们还需要显示库存中每种产品的数量,因为他们当然这样做了。

Ok. I guess. I mean, you didn’t specify that in the original project document, but why not. Let’s just make the scope whatever you want it to be.

好。 我猜。 我的意思是,您没有在原始项目文档中指定它,但是为什么不指定呢。 让我们只是做任何希望它是范围。

The product quantity information is a field in the database, but it’s not being returned by the service. In order to get to it from the front end, we have to modify the code of our service and then redeploy before we can even think about making changes on the front end. For one field.

产品数量信息是数据库中的一个字段,但服务未将其返回。 为了从前端获得它,我们必须修改我们的服务代码,然后重新部署,然后才能考虑在前端进行更改。 对于一个领域。

Likewise, if this same someone (who can’t seem to decide what they really want in life) decides that we no longer need the SKU, we can ignore it on the front end, but it’s part of the API response so it ends up being junk data in the payload, and pointless bits that our users don’t need.

同样,如果同一个人(似乎无法决定他们生活中真正想要的)决定我们不再需要SKU,则可以在前端忽略它,但这是API响应的一部分,因此最终是有效负载中的垃圾数据,以及我们的用户不需要的毫无意义的位。

Every project is just this back and forth of unforeseen changes. That’s literally the definition of “Software Development”. I mean it’s not, but my point sounds better if I reference a dictionary.

每个项目都是无法预料的变化的来回。 从字面上看,这就是“软件开发”的定义。 我的意思不是,但是如果我引用字典,我的观点听起来会更好。

The point is that we end up making a lot of trade-offs on both the front and back ends just to make things work and keep up with the pace of change. And trade-offs equal technical debt.

关键是,我们最终要在前端和后端进行很多权衡,以使事情正常进行并跟上变化的步伐。 权衡等于技术债务。

This is the very essence of the problem that GraphQL is trying to solve.

这是GraphQL试图解决的问题的本质。

I only recently put all the GraphQL pieces together in my own head. It wasn’t until my colleague Simona Cotin volunteered to teach me GraphQL that I had the epiphany that it is, perhaps, the answer to a problem that I’ve been trying to work around the bulk of my professional career.

我只是最近才把所有GraphQL片段放在一起。 直到我的同事Simona Cotin自愿教我GraphQL时,我才意识到这也许是对我一直在努力解决的大部分职业问题的答案。

与我们一起学习GraphQL (Learn GraphQL With Us)

Simona and I did three teaching sessions together and we recorded each one. In these three videos, you can learn with me as I go from zero knowledge about GraphQL, to implementing a GraphQL interface and then consuming it from a React application.

我和西蒙娜(Simona)一起进行了三场教学,每场我们都记录下来。 在这三个视频中,当我从对GraphQL的零知识到实现GraphQL接口,然后从React应用程序中使用它时,您可以与我一起学习。

Each video comes with a Github repo that you can clone to get the fully working solution in case you get lost along the way.

每个视频都带有一个Github存储库,您可以克隆该存储库以获取完整的解决方案,以防万一您迷路了。

We use Azure Functions a lot in this video series because it’s so much easier to build a Serverless API than it is to start from scratch. Grab a free Azure account if you don’t already have one.

在本视频系列中,我们经常使用Azure Functions,因为构建无服务器API比从头开始要容易得多。 如果您还没有免费的Azure帐户,请获取一个。

Create your Azure free account today | Microsoft AzureGet started with 12 months of free services and $200 USD in credit. Create your free account today with Microsoft…azure.microsoft.com

立即创建您的Azure免费帐户| Microsoft Azure 开始使用12个月的免费服务和200美元的信用额度。 立即使用Microsoft创建免费帐户… azure.microsoft.com

第1部分:GraphQL简介 (Part 1: Introducing GraphQL)

In the first video, Simona introduces me to the concepts of GraphQL and the quirky syntax that it uses. We also create the GraphQL API in this video and deploy it.

在第一个视频中,Simona向我介绍了GraphQL的概念及其所使用的古怪语法。 我们还将在此视频中创建GraphQL API并进行部署。

simonaco/serverless-graphql-apis-part1Contribute to simonaco/serverless-graphql-apis-part1 development by creating an account on GitHub.github.com

simonaco / serverless- graphql-apis-part1通过在GitHub上创建一个帐户为simonaco / serverless-graphql-apis-part1开发做出贡献。 github.com

第2部分:本地安装Graphiql并进行部署 (Part 2: Installing Graphiql locally and deploying)

In part 2, I get the Graphiql visual GraphQL testing tool running locally on my own machine and then deploy it to Azure Storage so I can easily test my GraphQL API without needing to wire up an application.

在第2部分中,我获得了在自己的计算机上本地运行的Graphiql可视化GraphQL测试工具,然后将其部署到Azure存储,因此我可以轻松地测试GraphQL API,而无需连接应用程序。

simonaco/serverless-graphql-apis-part2Contribute to simonaco/serverless-graphql-apis-part2 development by creating an account on GitHub.github.com

simonaco / serverless- graphql-apis-part2通过在GitHub上创建一个帐户为simonaco / serverless-graphql-apis-part2开发做出贡献。 github.com

第3部分:在React App中使用API (Part 3: Using the API in a React App)

We round out this series by looking at how to actually call this API from an application. That’s kind of an important detail.

我们通过研究如何从应用程序实际调用此API来完善本系列文章。 这是一个重要的细节。

simonaco/serverless-graphql-apis-part3Contribute to simonaco/serverless-graphql-apis-part3 development by creating an account on GitHub.github.com

simonaco / serverless- graphql-apis-part3通过在GitHub上创建一个帐户为simonaco / serverless-graphql-apis-part3开发 做出 贡献。 github.com

了解有关GraphQL的更多信息 (Learn more about GraphQL)

Once you understand the problem that GraphQL solves, you’ll start to see opportunities for it everywhere. And the best part is that you don’t have to start fresh to use it. In fact, it’s recommended that you use it on top of a typical REST API, so you’re likely in the perfect spot to use GraphQL today.

一旦了解了GraphQL解决的问题,您将开始在各地发现它的机会。 最好的部分是您不必重新使用它。 实际上, 建议您在典型的REST API之上使用它,因此您很可能今天就可以使用GraphQL。

If you want to go further with GraphQL and React, check out Wes Bos’s course. It’s paid, but it’s worth every penny. This is an investment you will be glad you made. Wes doesn’t pay me anything to say that. But maybe he should.

如果您想进一步了解GraphQL和React,请查看Wes Bos的课程。 它是付费的,但值得每一分钱。 这是一项投资,您会很高兴。 韦斯不付我任何费用。 但是也许他应该。

Advanced React & GraphQLBuild Full Stack Applications with React and GraphQLadvancedreact.com

Advanced React&GraphQL 使用React和GraphQL构建全栈应用程序 advancedreact.com

翻译自: https://www.freecodecamp.org/news/why-graphql-is-the-key-to-staying-out-of-technical-debt-7915f8f59a9/

graphql是什么

相关文章:

JS如何判断json是否为空

1、判断json是否为空 jQuery.isEmptyObject(); 2、遍历json function getHsonLength(json{var jsonLength0;for (var i in json){jsonLength;}return jsonLength;}转载于:https://www.cnblogs.com/donaldworld/p/7423811.html

微软算法100题11 求二叉树中两节点之间的最大距离

第11 题求二叉树中节点的最大距离...如果我们把二叉树看成一个图,父子节点之间的连线看成是双向的,我们姑且定义"距离"为两节点之间边的个数。写一个程序,求一棵二叉树中相距最远的两个节点之间的距离 思路: 一棵树中节点的最大距…

小程序订阅消息 订阅消息开发

微信小程序交流QQ群: 173683895 173683866 526474645 。 群内打广告或者脏话一律飞机票 订阅消息 当用户勾选了订阅面板中的“总是保持以上选择,不再询问”时,模板消息会被添加到用户的小程序设置页,通过 wx.getSetting…

meetup_如何使用标准库和Node.js构建Meetup Slack机器人

meetupby Janeth Ledezma简妮丝莱德兹玛(Janeth Ledezma) 如何使用标准库和Node.js构建Meetup Slack机器人 (How to build a Meetup Slack bot with Standard Library and Node.js) In this guide, you will learn how to set up a Slack application that will display infor…

.NET使用OpenSSL生成的pem密钥文件[1024位]

using System; using System.Text; using System.Security.Cryptography; using System.Web; using System.IO;namespace Thinhunan.Cnblogs.Com.RSAUtility {public class PemConverter{/// <summary>/// 将pem格式公钥转换为RSAParameters/// </summary>/// <…

[2014百度之星资格赛]

第一个问题&#xff1a; Energy Conversion Problem Description魔法师百小度也有遇到难题的时候——如今。百小度正在一个古老的石门面前&#xff0c;石门上有一段古老的魔法文字&#xff0c;读懂这样的魔法文字须要耗费大量的能量和大量的脑力。过了许久。百小度最终读懂魔法…

视频录制,压缩实现源码

实现代码&#xff1a; <!DOCTYPE html> <html><head><meta charset"utf-8"><title></title><meta name"viewport" content"widthdevice-width, initial-scale1.0"><!-- <script src"./js…

alexa技能个数_如何在您的技能中使用Alexa演示语言

alexa技能个数by Garrett Vargas通过Garrett Vargas 如何在您的技能中使用Alexa演示语言 (How to use Alexa Presentation Language in your skill) Amazon recently released the Alexa Presentation Language (APL). APL provides a richer display for multimodal skills. …

HTML与XML总结

阅览《孙欣HTML》和《刘炜XML》过了一段时间&#xff0c;在这里学到的内容用思维导图来概括。HTML与XML都是标记语言。 同样点&#xff1a; HTML文档与XML文档有类似的结构。前者是&#xff08;head和body&#xff09;后者是&#xff08;声明和主体&#xff09;&#xff0c;大致…

ant PageHeaderWrapper 返回上一页

PageHeaderWrapper 返回上一页实现代码&#xff1a; <PageHeaderWrappertitle{false}content{<a onClick{() > router.goBack()}><Icon type"left" />返回</a>}breadcrumb{{routes: [{ path: /, breadcrumbName: 首页 },{ path: /pay_orde…

ruby 新建对象_Ruby面向对象编程的简介

ruby 新建对象by Saul Costa由Saul Costa Object-oriented programming (OOP) is a programming paradigm organized around objects. At a high level, OOP is all about being able to structure code so that its functionality can be shared throughout the application.…

ASP.NET导出文件FileResult的使用

本文给大家讲一下ASP.NET MVC中如何使用FileResult来导出文件&#xff0c;首先网上相关例子有很多大神都有讲&#xff0c;我在这只是稍微说一点不同——为什么我的导出没有反应呢&#xff1f; 这个问题&#xff0c;我找了半天也没有找到&#xff0c;最后是在一个网友的评论中体…

【AHOI 2016初中组】 自行车比赛 - 贪心

题目描述 小雪非常关注自行车比赛&#xff0c;尤其是环滨湖自行车赛。一年一度的环滨湖自行车赛&#xff0c;需要选手们连续比赛数日&#xff0c;最终按照累计得分决出冠军。今年一共有 N 位参赛选手。每一天的比赛总会决出当日的排名&#xff0c;第一名的选手会获得 N 点得分&…

【Ant Design Pro 三】样式动态绑定 react样式绑定

第一步&#xff0c;创建样式文件&#xff0c;在页面目录下根据自己习惯创建一个less文件&#xff0c;用来写样式类 第二部&#xff0c;引用该文件 import styles from ./details.less; //details.less 代码&#xff1a; .menu {width: 95%; } .navigation-menu{width: 90%; …

react hooks使用_如何使用React和Hooks检测外部点击

react hooks使用by Andrei Cacio通过安德烈卡西奥(Andrei Cacio) 如何使用React和Hooks检测外部点击 (How to detect an outside click with React and Hooks) “外部点击”是什么意思&#xff1f; (What does “Outside Click” mean?) You can think of it as the “anti-b…

正则表达式(1)

正则表达式的概念 正则表达式是一个字符串&#xff0c;使用单个字符串来描述、用来定义匹配规则&#xff0c;匹配一系列符合某个句法规则的字符串。在开发中&#xff0c;正则表达式通常被用来检索、替换那些符合某个规则的文本。 正则表达式的匹配规则 字符类&#xff1a;[abc]…

Android 曲线动画animation,类似加入购物车动画

按照惯例先放效果图&#xff1a;图中小球做抛物线运动 资源图片 1.首先布局文件activity_main.xml&#xff0c;布局很简单&#xff0c;就一个测试按钮 1 <RelativeLayout xmlns:android"http://schemas.android.com/apk/res/android"2 xmlns:tools"http:…

小程序音频播放报10001 解决方案 errCode:10001, errMsg:errCode:602,err:error,not found param

音频播放有两种方式&#xff1a; 第一种&#xff1a; innerAudioContext.src audioSrc;innerAudioContext.play(); 第二种&#xff1a; innerAudioContext.autoplay true;innerAudioContext.src audioSrc; 之前使用第一种&#xff0c;华为手机不能正常播放&#xff0c;…

在线学位课程_您在四年制计算机科学学位课程中学到的知识

在线学位课程by Colin Smith通过科林史密斯 您在四年制计算机科学学位课程中学到的知识 (What you learn in a 4 year Computer Science degree) I recently wrote an article on whether you need a computer science degree to get a job in tech. I thought that going ove…

Swift学习笔记-协议(Protocols)

1.0 翻译&#xff1a;geek5nan 校对&#xff1a;dabing1022 2.0 翻译&#xff1a;futantan 校对&#xff1a;小铁匠Linus 定稿&#xff1a;shanksyang 本页包含内容&#xff1a; 协议的语法&#xff08;Protocol Syntax&#xff09;对属性的规定&#xff08;Property Requireme…

JavaScript简单重写构造器的原型

1 //简单重写原型对象&#xff1a;2 3 //一个构造函数Person4 function Person(){5 6 }7 //重写Person的原型8 //把Person的原型赋值给一个新的对象 是我们重写的过程9 Person.prototype{ 10 // 对于构造器 如果我们不给他写&#xff0c;则构造器就是Object的构造器了 …

node.js cannot find module

找不到模块的解决方案 &#xff1a; 把node_module整个文件夹删掉,然后npm clean cache,看下package.json里有没有express的依赖项,有的话直接npm install,没有的话 npm install express --save。 有人说 npm clean cache 命令变成了 npm cache clean&#xff0c;可以都试一下

我在React Native中构建时获得的经验教训

by Amanda Bullington通过阿曼达布林顿(Amanda Bullington) 我在React Native中构建时获得的经验教训 (Lessons I learned while building in React Native) When I received an offer for a software engineering role to build an app in React Native, I wasn’t sure what…

【Ant Design Pro 五】箱套路由在菜单栏显示返回上一页

效果图&#xff1a; 场景&#xff1a;从菜单栏进入子页面&#xff0c;但是子页面默认不在路由显示&#xff0c;完成操作后需要返回上级页面。所以要在菜单栏中加返回的功能。 实现代码&#xff1a; import React from react; import { Button, Card, Icon } from antd; impor…

[002] The Perks of Being a Wallflower - 读后记

The Perks of Being a Wallflower 今天(2015年10月30日 18:26:17)读完"The Perks of Being a Wallflower". 本书290页,我是在小米pad上完成阅读的,epub格式,花费四天时间,每天至少5小时. 生词很多,就不一一列出了. 使用透析法并不强求完全的正确理解原文.强调完整的阅…

ios集成firebase_如何将Firebase与您的应用程序集成

ios集成firebaseYou’ve probably heard about Firebase, but may not know much about how it works and how it fits in with your application. Well, you’ve come to the right place. We’ll go over what Firebase is and how to integrate it with your Android projec…

PLSQL创建Oracle定时任务

转自&#xff1a;http://www.cnblogs.com/yx007/p/6519544.html#_label0转载于:https://www.cnblogs.com/good-tomorrow/p/7443817.html

判断h5是不是在小程序中

执行代码&#xff1a; if (ua.indexOf(MicroMessenger) -1) {//说明不在微信中// 走不在小程序的逻辑 } else {wx.miniProgram.getEnv(function(res) {if (res.miniprogram) {// 走在小程序的逻辑} else {// 走不在小程序的逻辑}}) }

CSS3关于过渡效果的问题

首先trasition:transform只是单单表示后面只要有含有的tranform的所有属性可以参与动画&#xff0c;而trasition:all表示后面所有动画属性都可以参动画&#xff0c;当父容器有relative时&#xff0c;子容器有absolute&#xff0c;子容器会跟着父容器相对定位。当你想要然后一个…

在线学位课程_如何选择计算机科学学位课程

在线学位课程by Colin Smith通过科林史密斯 如何选择计算机科学学位课程 (How to choose a Computer Science degree program) I remember combing through the countless computer science programs online and feeling a bit lost on what I should be looking for. I ended…