久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='OY0Ar'></tfoot>
<legend id='OY0Ar'><style id='OY0Ar'><dir id='OY0Ar'><q id='OY0Ar'></q></dir></style></legend>
        <bdo id='OY0Ar'></bdo><ul id='OY0Ar'></ul>
      <i id='OY0Ar'><tr id='OY0Ar'><dt id='OY0Ar'><q id='OY0Ar'><span id='OY0Ar'><b id='OY0Ar'><form id='OY0Ar'><ins id='OY0Ar'></ins><ul id='OY0Ar'></ul><sub id='OY0Ar'></sub></form><legend id='OY0Ar'></legend><bdo id='OY0Ar'><pre id='OY0Ar'><center id='OY0Ar'></center></pre></bdo></b><th id='OY0Ar'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='OY0Ar'><tfoot id='OY0Ar'></tfoot><dl id='OY0Ar'><fieldset id='OY0Ar'></fieldset></dl></div>

    1. <small id='OY0Ar'></small><noframes id='OY0Ar'>

        我應(yīng)該在客戶(hù)端將 GraphQL ID 作為字符串處理嗎?

        Should I handle a GraphQL ID as a string on the client?(我應(yīng)該在客戶(hù)端將 GraphQL ID 作為字符串處理嗎?)

              <tbody id='bzQxJ'></tbody>
            <tfoot id='bzQxJ'></tfoot>

              <small id='bzQxJ'></small><noframes id='bzQxJ'>

              1. <i id='bzQxJ'><tr id='bzQxJ'><dt id='bzQxJ'><q id='bzQxJ'><span id='bzQxJ'><b id='bzQxJ'><form id='bzQxJ'><ins id='bzQxJ'></ins><ul id='bzQxJ'></ul><sub id='bzQxJ'></sub></form><legend id='bzQxJ'></legend><bdo id='bzQxJ'><pre id='bzQxJ'><center id='bzQxJ'></center></pre></bdo></b><th id='bzQxJ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='bzQxJ'><tfoot id='bzQxJ'></tfoot><dl id='bzQxJ'><fieldset id='bzQxJ'></fieldset></dl></div>
                  <bdo id='bzQxJ'></bdo><ul id='bzQxJ'></ul>
                  <legend id='bzQxJ'><style id='bzQxJ'><dir id='bzQxJ'><q id='bzQxJ'></q></dir></style></legend>
                  本文介紹了我應(yīng)該在客戶(hù)端將 GraphQL ID 作為字符串處理嗎?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我正在使用以下方法構(gòu)建應(yīng)用程序:

                  I am building an application using:

                  • MySQL 作為后端數(shù)據(jù)庫(kù)
                  • Apollo GraphQL 服務(wù)器作為該數(shù)據(jù)庫(kù)的查詢(xún)層
                  • Sequelize 作為 GraphQL 和 MySQL 之間的 ORM 層

                  在構(gòu)建 GraphQL 架構(gòu)時(shí),我使用 GraphQL ID 數(shù)據(jù)類(lèi)型來(lái)唯一標(biāo)識(shí)記錄.這是一個(gè)示例架構(gòu)及其 MySQL 解析器/連接器

                  As I am building out my GraphQL schema I'm using the GraphQL ID data type to uniquely identify records. Here's an example schema and its MySQL resolver/connector

                  Graphql 類(lèi)型:

                  type Person {
                    id: ID!
                    firstName: String
                    middleName: String
                    lastName: String
                    createdAt: String
                    updatedAt: String
                  }
                  

                  續(xù)集連接器

                  export const Person = sequelize.define('person', {
                    firstName: { type: Sequelize.STRING },
                    middleName: { type: Sequelize.STRING },
                    lastName: { type: Sequelize.STRING },
                  });
                  

                  GraphQL 解析器:

                  Query: {
                    person(_, args) {
                      return Person.findById(args.id);
                  }
                  

                  這樣一切正常.這是我的問(wèn)題.GraphQL 似乎將 ID 類(lèi)型視為字符串.雖然 ID 值被 Sequelize 作為 INT 存儲(chǔ)在 MySQL 數(shù)據(jù)庫(kù)中.我可以使用 GraphQL 使用與數(shù)據(jù)庫(kù)中的 ID 值匹配的字符串或整數(shù)來(lái)查詢(xún) MySQL 數(shù)據(jù)庫(kù).但是,GraphQL 將始終以字符串形式返回 ID 值.

                  So that all works. Here's my question. GraphQL seems to treat the ID type as a string. While the ID value gets stored in the MySQL database as an INT by Sequelize. I can use GraphQL to query the MySQL db with either a string or a integer that matches the ID value in the database. However, GraphQL will always return the ID value as a string.

                  我應(yīng)該如何在客戶(hù)端處理這個(gè)值?我是否應(yīng)該在從 GraphQL 獲取它后立即將其轉(zhuǎn)換為整數(shù)?我應(yīng)該修改我的續(xù)集代碼以將 ID 值存儲(chǔ)為字符串嗎?像這樣使用 GraphQL ID 時(shí),是否有正確的處理方法?

                  How should I be handling this value in the client? Should I always convert it to an integer as soon as I get it from GraphQL? Should I modify my sequelize code to store the ID value as a string? Is there a correct way to proceed when using GraphQL IDs like this?

                  推薦答案

                  ID 是 GraphQL 規(guī)范(2016 年 10 月工作草案):

                  ID is a scalar type described in the GraphQL specification (working draft October 2016):

                  ID 類(lèi)型的序列化方式與 String 相同;然而,它并不是人類(lèi)可讀的.雖然它通常是數(shù)字,但它應(yīng)該始終序列化為字符串.

                  The ID type is serialized in the same way as a String; however, it is not intended to be human‐readable. While it is often numeric, it should always serialize as a String.


                  你的觀察


                  Your observation

                  我可以使用 GraphQL 使用與數(shù)據(jù)庫(kù)中的 ID 值匹配的字符串或整數(shù)來(lái)查詢(xún) MySQL 數(shù)據(jù)庫(kù).但是,GraphQL 將始終以字符串形式返回 ID 值.

                  I can use GraphQL to query the MySQL db with either a string or a integer that matches the ID value in the database. However, GraphQL will always return the ID value as a string.

                  符合關(guān)于結(jié)果強(qiáng)制的規(guī)范:

                  GraphQL 與 ID 格式無(wú)關(guān),并序列化為字符串以確保 ID 可以表示的多種格式的一致性

                  GraphQL is agnostic to ID format, and serializes to string to ensure consistency across many formats ID could represent

                  輸入強(qiáng)制:

                  當(dāng)期望作為輸入類(lèi)型時(shí),任何字符串(例如4")或整數(shù)(例如 4)輸入值都應(yīng)根據(jù)給定的 GraphQL 服務(wù)器期望的 ID 格式強(qiáng)制轉(zhuǎn)換為 ID

                  When expected as an input type, any string (such as "4") or integer (such as 4) input value should be coerced to ID as appropriate for the ID formats a given GraphQL server expects


                  我應(yīng)該如何在客戶(hù)端處理這個(gè)值?

                  • 使用 ID results 時(shí),將它們視為字符串.
                  • 當(dāng)使用 ID inputs 時(shí)(在 GraphQL 變量或用于突變或查詢(xún)的輸入?yún)?shù)中),您可以使用整數(shù)或字符串.
                  • When working with ID results, treat them as strings.
                  • When using ID inputs (in GraphQL variables or input parameters for mutations or queries), you can either use integers or strings.

                  我是否應(yīng)該在從 GraphQL 中獲取后立即將其轉(zhuǎn)換為整數(shù)?

                  這在很大程度上取決于您的應(yīng)用程序.沒(méi)有明確規(guī)定是"的一般規(guī)則.或否"在這里.

                  That's highly depending on your application. There is no general rule that dictates a clear "yes" or "no" here.

                  我是否應(yīng)該修改我的 sequelize 代碼以將 ID 值存儲(chǔ)為字符串?

                  不,這不是必需的.

                  關(guān)于 ID 類(lèi)型的 GraphQL 規(guī)范沒(méi)有涵蓋你如何存儲(chǔ)id,只涵蓋了 GraphQL 服務(wù)器應(yīng)該如何處理 ID輸入和輸出.由 GraphQL 層來(lái)確保這種行為.實(shí)際存儲(chǔ)中如何處理 id 由存儲(chǔ)層決定.

                  The GraphQL specification about the ID type does not cover how you store the ids, only how a GraphQL server is expected to treat ID input and output. It's up to the GraphQL layer to ensure this behaviour. How ids are handled in the actual storage is up to the storage layer.

                  在使用像這樣的 GraphQL ID 時(shí),是否有正確的處理方法?

                  我希望上面的答案也回答了這個(gè)問(wèn)題:)

                  I hope the above answers also answer this question :)

                  這篇關(guān)于我應(yīng)該在客戶(hù)端將 GraphQL ID 作為字符串處理嗎?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數(shù)根據(jù) N 個(gè)先前值來(lái)決定接下來(lái)的 N 個(gè)行)
                  reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達(dá)式的結(jié)果;條款?)
                  Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數(shù)的 ignore 選項(xiàng)是忽略整個(gè)事務(wù)還是只是有問(wèn)題的行?) - IT屋-程序員軟件開(kāi)發(fā)技
                  Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時(shí)出錯(cuò),使用 for 循環(huán)數(shù)組)
                  pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調(diào)用 o23.load 時(shí)發(fā)生錯(cuò)誤 沒(méi)有合適的驅(qū)動(dòng)程序)
                  How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數(shù)據(jù)庫(kù)表作為 Spark 數(shù)據(jù)幀讀取?)

                      <tbody id='MxwX5'></tbody>
                      • <bdo id='MxwX5'></bdo><ul id='MxwX5'></ul>
                        1. <legend id='MxwX5'><style id='MxwX5'><dir id='MxwX5'><q id='MxwX5'></q></dir></style></legend>
                        2. <i id='MxwX5'><tr id='MxwX5'><dt id='MxwX5'><q id='MxwX5'><span id='MxwX5'><b id='MxwX5'><form id='MxwX5'><ins id='MxwX5'></ins><ul id='MxwX5'></ul><sub id='MxwX5'></sub></form><legend id='MxwX5'></legend><bdo id='MxwX5'><pre id='MxwX5'><center id='MxwX5'></center></pre></bdo></b><th id='MxwX5'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='MxwX5'><tfoot id='MxwX5'></tfoot><dl id='MxwX5'><fieldset id='MxwX5'></fieldset></dl></div>

                          <small id='MxwX5'></small><noframes id='MxwX5'>

                          <tfoot id='MxwX5'></tfoot>

                          1. 主站蜘蛛池模板: 国产精品久久久亚洲 | 在线观看黄色 | 精品国产乱码久久久久久影片 | 欧美午夜一区 | 日韩中文字幕在线观看 | 亚洲视频一区在线 | 99久久电影 | 亚洲视频在线一区 | 欧美乱码精品一区二区三区 | 亚洲精品大全 | 亚洲精品18| 欧美精品1区2区3区 精品国产欧美一区二区 | 久久免费看| 欧美精品日韩精品国产精品 | 国产在线精品一区二区 | 天天干天天草 | 在线免费观看亚洲 | 日韩影音 | 成人在线视频网址 | 亚洲国产aⅴ精品 | 91亚洲国产成人久久精品网站 | 夜夜干夜夜操 | 成人一区二区三区在线观看 | 免费在线观看一区二区三区 | 91短视频网址 | 国产专区免费 | 国产精品一二区 | 亚洲一区国产 | 在线观看中文字幕视频 | 鸳鸯谱在线观看高清 | 午夜精品一区二区三区在线观看 | 国产成人精品一区二区三区 | 成人污污视频 | 国产精品亚洲精品日韩已方 | 久久免费精品 | 狠狠做深爱婷婷综合一区 | 亚洲久草| 一区二区三区视频播放 | 成人一区二区三区在线观看 | 亚洲精品99久久久久久 | 日韩在线精品视频 |