mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
This is breaking change where bigint and bigserial Postgres types will be encoded as GraphQL String types, as opposed to Int as present in earlier releases. Input types were already encoded as String. This is achieved by selecting `bigint` and `bigserial` columns as `text`s in the SQL query: `select "big_id"::text ..` instead of `select "big_id" .. `. Reason for that change is outlined in #633 where JavaScript cannot decode 64 bit Integers.
This commit is contained in:
parent
300684f2dc
commit
91376316f2
@ -1,6 +1,6 @@
|
||||
Name,Aliases,Description,GraphQL Engine Type
|
||||
bigint,int8,signed eight-byte integer,Int_
|
||||
bigserial,serial8,autoincrementing eight-byte integer,Int_
|
||||
bigint,int8,signed eight-byte integer,String_
|
||||
bigserial,serial8,autoincrementing eight-byte integer,String_
|
||||
bit [ (n) ],,fixed-length bit string,Implicit_
|
||||
bit varying [ (n) ],varbit [ (n) ],variable-length bit string,Implicit_
|
||||
boolean,bool,logical Boolean (true/false),Bool_
|
||||
|
|
@ -233,9 +233,9 @@ mkColExtr (c, pct) =
|
||||
mkColExtrAl (Just c) (c, pct)
|
||||
|
||||
mkColExtrAl :: (IsIden a) => Maybe a -> (PGCol, PGColType) -> S.Extractor
|
||||
mkColExtrAl alM (c, pct) =
|
||||
if pct == PGGeometry || pct == PGGeography
|
||||
then S.mkAliasedExtrFromExp
|
||||
mkColExtrAl alM (c, pct)
|
||||
| pct == PGGeometry || pct == PGGeography =
|
||||
S.mkAliasedExtrFromExp
|
||||
( S.SEFnApp "ST_AsGeoJSON"
|
||||
[ S.mkSIdenExp c
|
||||
, S.SEUnsafe "15" -- max decimal digits
|
||||
@ -243,7 +243,10 @@ mkColExtrAl alM (c, pct) =
|
||||
] Nothing
|
||||
`S.SETyAnn` S.jsonType
|
||||
) alM
|
||||
else S.mkAliasedExtr c alM
|
||||
| pct == PGBigInt || pct == PGBigSerial =
|
||||
S.mkAliasedExtrFromExp
|
||||
(S.mkSIdenExp c `S.SETyAnn` S.textType) alM
|
||||
| otherwise = S.mkAliasedExtr c alM
|
||||
|
||||
-- validate headers
|
||||
validateHeaders :: (P1C m) => [T.Text] -> m ()
|
||||
|
@ -0,0 +1,21 @@
|
||||
description: Simple GraphQL query to fetch items from user table
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
user:
|
||||
- id: '1'
|
||||
name: User 1
|
||||
number: '123456789'
|
||||
- id: '2'
|
||||
name: User 2
|
||||
number: '123456780'
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
user {
|
||||
id
|
||||
name
|
||||
number
|
||||
}
|
||||
}
|
@ -85,3 +85,24 @@ args:
|
||||
true
|
||||
)
|
||||
|
||||
#User table with bigserial and bigint columns
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE "user" (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
number BIGINT
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: user
|
||||
- type: insert
|
||||
args:
|
||||
table: user
|
||||
objects:
|
||||
- name: User 1
|
||||
number: '123456789'
|
||||
- name: User 2
|
||||
number: '123456780'
|
||||
|
@ -18,3 +18,7 @@ args:
|
||||
sql: |
|
||||
drop table author
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table "user"
|
||||
|
17
server/tests-py/queries/v1/select/basic/select_user.yaml
Normal file
17
server/tests-py/queries/v1/select/basic/select_user.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
url: /v1/query
|
||||
status: 200
|
||||
response:
|
||||
- id: '1'
|
||||
name: User 1
|
||||
number: '123456789'
|
||||
- id: '2'
|
||||
name: User 2
|
||||
number: '123456780'
|
||||
query:
|
||||
type: select
|
||||
args:
|
||||
table: user
|
||||
columns:
|
||||
- id
|
||||
- name
|
||||
- number
|
@ -83,3 +83,24 @@ args:
|
||||
true
|
||||
)
|
||||
|
||||
#User table with bigserial and bigint columns
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE "user" (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
number BIGINT
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: user
|
||||
- type: insert
|
||||
args:
|
||||
table: user
|
||||
objects:
|
||||
- name: User 1
|
||||
number: '123456789'
|
||||
- name: User 2
|
||||
number: '123456780'
|
||||
|
@ -16,3 +16,7 @@ args:
|
||||
args:
|
||||
sql: |
|
||||
drop table author
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table "user"
|
||||
|
@ -19,6 +19,9 @@ class TestGraphQLQueryBasic:
|
||||
def test_nested_select_query_where(self, hge_ctx):
|
||||
check_query_f(hge_ctx, self.dir + '/nested_select_where_query_author_article.yaml')
|
||||
|
||||
def test_select_query_user(self, hge_ctx):
|
||||
check_query_f(hge_ctx, "queries/graphql_query/basic/select_query_user.yaml")
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def transact(self, request, hge_ctx):
|
||||
self.dir = 'queries/graphql_query/basic'
|
||||
|
@ -19,6 +19,9 @@ class TestV1SelectBasic:
|
||||
def test_nested_select_query_where(self, hge_ctx):
|
||||
check_query_f(hge_ctx, self.dir + '/nested_select_where_query_author_article.yaml')
|
||||
|
||||
def test_select_query_user(self, hge_ctx):
|
||||
check_query_f(hge_ctx, self.dir + '/select_user.yaml')
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def transact(self, request, hge_ctx):
|
||||
self.dir = "queries/v1/select/basic"
|
||||
|
Loading…
Reference in New Issue
Block a user