久久久久久久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'>

        我應該在客戶端將 GraphQL ID 作為字符串處理嗎?

        Should I handle a GraphQL ID as a string on the client?(我應該在客戶端將 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>
                  本文介紹了我應該在客戶端將 GraphQL ID 作為字符串處理嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在使用以下方法構建應用程序:

                  I am building an application using:

                  • MySQL 作為后端數據庫
                  • Apollo GraphQL 服務器作為該數據庫的查詢層
                  • Sequelize 作為 GraphQL 和 MySQL 之間的 ORM 層

                  在構建 GraphQL 架構時,我使用 GraphQL ID 數據類型來唯一標識記錄.這是一個示例架構及其 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 類型:

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

                  續集連接器

                  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);
                  }
                  

                  這樣一切正常.這是我的問題.GraphQL 似乎將 ID 類型視為字符串.雖然 ID 值被 Sequelize 作為 INT 存儲在 MySQL 數據庫中.我可以使用 GraphQL 使用與數據庫中的 ID 值匹配的字符串或整數來查詢 MySQL 數據庫.但是,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.

                  我應該如何在客戶端處理這個值?我是否應該在從 GraphQL 獲取它后立即將其轉換為整數?我應該修改我的續集代碼以將 ID 值存儲為字符串嗎?像這樣使用 GraphQL ID 時,是否有正確的處理方法?

                  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 規范(2016 年 10 月工作草案):

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

                  ID 類型的序列化方式與 String 相同;然而,它并不是人類可讀的.雖然它通常是數字,但它應該始終序列化為字符串.

                  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 使用與數據庫中的 ID 值匹配的字符串或整數來查詢 MySQL 數據庫.但是,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.

                  符合關于結果強制的規范:

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

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

                  輸入強制:

                  當期望作為輸入類型時,任何字符串(例如4")或整數(例如 4)輸入值都應根據給定的 GraphQL 服務器期望的 ID 格式強制轉換為 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


                  我應該如何在客戶端處理這個值?

                  • 使用 ID results 時,將它們視為字符串.
                  • 當使用 ID inputs 時(在 GraphQL 變量或用于突變或查詢的輸入參數中),您可以使用整數或字符串.
                  • 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.

                  我是否應該在從 GraphQL 中獲取后立即將其轉換為整數?

                  這在很大程度上取決于您的應用程序.沒有明確規定是"的一般規則.或否"在這里.

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

                  我是否應該修改我的 sequelize 代碼以將 ID 值存儲為字符串?

                  不,這不是必需的.

                  關于 ID 類型的 GraphQL 規范沒有涵蓋你如何存儲id,只涵蓋了 GraphQL 服務器應該如何處理 ID輸入和輸出.由 GraphQL 層來確保這種行為.實際存儲中如何處理 id 由存儲層決定.

                  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 時,是否有正確的處理方法?

                  我希望上面的答案也回答了這個問題:)

                  I hope the above answers also answer this question :)

                  這篇關于我應該在客戶端將 GraphQL ID 作為字符串處理嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

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

                      <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精品免费观看 | 日本一二三区电影 | 国产日韩一区二区三免费高清 | 日本精品视频 | 91久久精品一区二区二区 | 精品中文字幕久久 | 成人午夜毛片 | 中文字幕人成人 | 国产精品日本一区二区不卡视频 | 黄网站免费在线 | 少妇诱惑av| 免费观看av| 911影院| 国产高清在线精品一区二区三区 | 高清国产午夜精品久久久久久 | 久久久久亚洲精品 | 欧美日韩亚洲三区 | 二区中文 | 国产精品成人一区二区三区 | 国产麻豆乱码精品一区二区三区 | 久久婷婷麻豆国产91天堂 | 欧美一区二区三区 | 九九热国产精品视频 | 国产日韩欧美一区二区在线播放 | 天堂一区二区三区 | 综合激情久久 | 在线超碰 | 国产成人精品在线 | 精品一区二区三区不卡 | 国产欧美一区二区三区免费 | 国产成人精品久久二区二区91 | 99久久精品免费看国产小宝寻花 | 亚洲狠狠爱 | 国产日韩欧美二区 | 午夜国产羞羞视频免费网站 | 欧美日韩一区二区在线观看 | 久久综合久久综合久久综合 | 日韩视频在线观看一区二区 | 99久久久无码国产精品 | 久久久久亚洲精品 |