Skip to content

Commit 0297398

Browse files
committed
fix values not getting properly coerced
1 parent d1bc9ab commit 0297398

File tree

6 files changed

+39
-1
lines changed

6 files changed

+39
-1
lines changed

examples/kitchen-sink/schema.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ create function c.no_args_mutation() returns int as $$ select 2 $$ language sql;
167167

168168
create function c.person_first_name(person c.person) returns text as $$ select split_part(person.name, ' ', 1) $$ language sql stable;
169169
create function c.person_friends(person c.person) returns setof c.person as $$ select friend.* from c.person as friend where friend.id in (person.id + 1, person.id + 2) $$ language sql stable;
170+
create function c.person_first_post(person c.person) returns a.post as $$ select * from a.post where a.post.author_id = person.id limit 1 $$ language sql stable;
170171
create function c.compound_type_computed_field(compound_type c.compound_type) returns integer as $$ select compound_type.a + compound_type.foo_bar $$ language sql stable;
171172
create function a.post_headline_trimmed(post a.post, length int default 10, omission text default '') returns text as $$ select substr(post.headline, 0, length) || omission $$ language sql stable;
172173

src/postgraphql/__tests__/__snapshots__/postgraphqlIntegrationQueries-test.js.snap

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,10 @@ Object {
808808
"nodes": Array [
809809
Object {
810810
"firstName": "John",
811+
"firstPost": Object {
812+
"headline": "I hate yogurt. It’s just stuff with bits in.",
813+
"id": 2,
814+
},
811815
"friends": Object {
812816
"nodes": Array [
813817
Object {
@@ -840,6 +844,10 @@ Object {
840844
},
841845
Object {
842846
"firstName": "Sara",
847+
"firstPost": Object {
848+
"headline": "No… It’s a thing; it’s like a plan, but with more greatness.",
849+
"id": 1,
850+
},
843851
"friends": Object {
844852
"nodes": Array [
845853
Object {
@@ -872,6 +880,10 @@ Object {
872880
},
873881
Object {
874882
"firstName": "Budd",
883+
"firstPost": Object {
884+
"headline": "Stop talking, brain thinking. Hush.",
885+
"id": 6,
886+
},
875887
"friends": Object {
876888
"nodes": Array [
877889
Object {
@@ -899,6 +911,7 @@ Object {
899911
},
900912
Object {
901913
"firstName": "Kathryn",
914+
"firstPost": null,
902915
"friends": Object {
903916
"nodes": Array [
904917
Object {
@@ -914,6 +927,10 @@ Object {
914927
},
915928
Object {
916929
"firstName": "Joe",
930+
"firstPost": Object {
931+
"headline": "Please, Don-Bot… look into your hard drive, and open your mercy file!",
932+
"id": 5,
933+
},
917934
"friends": Object {
918935
"nodes": Array [],
919936
},

src/postgraphql/__tests__/__snapshots__/postgraphqlIntegrationSchema-test.js.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ type Person implements Node {
607607
email: Email!
608608
createdAt: Datetime
609609
firstName: String
610+
firstPost: Post
610611

611612
# Reads and enables paginatation through a set of \`Person\`.
612613
friends(
@@ -3709,6 +3710,7 @@ type Person implements Node {
37093710
email: Email!
37103711
createdAt: Datetime
37113712
firstName: String
3713+
firstPost: Post
37123714

37133715
# Reads and enables paginatation through a set of \`Person\`.
37143716
friends(
@@ -5524,6 +5526,7 @@ type Person implements Node {
55245526
email: Email!
55255527
createdAt: Datetime
55265528
firstName: String
5529+
firstPost: Post
55275530

55285531
# Reads and enables paginatation through a set of \`Person\`.
55295532
friends(

src/postgraphql/__tests__/__snapshots__/postgraphqlIntegrationSchemaExport-test.js.snap

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,7 @@ type Person implements Node {
16361636
email: Email!
16371637
createdAt: Datetime
16381638
firstName: String
1639+
firstPost: Post
16391640

16401641
# Reads and enables paginatation through a set of \`Person\`.
16411642
friends(
@@ -5631,6 +5632,18 @@ exports[`test exports a schema as JSON 1`] = `
56315632
\"isDeprecated\": false,
56325633
\"deprecationReason\": null
56335634
},
5635+
{
5636+
\"name\": \"firstPost\",
5637+
\"description\": null,
5638+
\"args\": [],
5639+
\"type\": {
5640+
\"kind\": \"OBJECT\",
5641+
\"name\": \"Post\",
5642+
\"ofType\": null
5643+
},
5644+
\"isDeprecated\": false,
5645+
\"deprecationReason\": null
5646+
},
56345647
{
56355648
\"name\": \"friends\",
56365649
\"description\": \"Reads and enables paginatation through a set of \`Person\`.\",

src/postgraphql/__tests__/fixtures/queries/procedure-computed-fields.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ query {
3232
}
3333
}
3434
}
35+
firstPost {
36+
id
37+
headline
38+
}
3539
}
3640
}
3741
allEdgeCases {

src/postgraphql/schema/procedures/createPgProcedureObjectTypeGqlFieldEntry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function createPgSingleProcedureQueryGqlFieldEntry (
5959
const input = [source, ...argEntries.map(([argName], i) => fixtures.args[i + 1].fromGqlInput(args[argName]))]
6060
const query = sql.compile(sql.query`select to_json(${createPgProcedureSqlCall(fixtures, input)}) as value`)
6161
const { rows: [row] } = await client.query(query)
62-
return row ? fixtures.return.intoGqlOutput(row['value']) : null
62+
return row ? fixtures.return.intoGqlOutput(fixtures.return.type.transformPgValueIntoValue(row['value'])) : null
6363
},
6464
}]
6565
}

0 commit comments

Comments
 (0)