Skip to content

Commit 4745880

Browse files
authored
Merge pull request #582 from supabase/fix-581
fix #581 - missing description in schema
2 parents 8258bd3 + 7340864 commit 4745880

File tree

4 files changed

+214
-0
lines changed

4 files changed

+214
-0
lines changed

src/builder.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,6 +1945,7 @@ pub struct __DirectiveBuilder {
19451945
#[allow(dead_code)]
19461946
#[serde(untagged)]
19471947
pub enum __SchemaField {
1948+
Description,
19481949
Types(Vec<__TypeBuilder>),
19491950
QueryType(__TypeBuilder),
19501951
MutationType(Option<__TypeBuilder>),
@@ -1961,6 +1962,7 @@ pub struct __SchemaSelection {
19611962

19621963
#[derive(Clone)]
19631964
pub struct __SchemaBuilder {
1965+
pub description: String,
19641966
pub selections: Vec<__SchemaSelection>,
19651967
}
19661968

@@ -2516,6 +2518,7 @@ impl __Schema {
25162518
builder_fields.push(__SchemaSelection {
25172519
alias: alias_or_name(&selection_field),
25182520
selection: match f.name().as_str() {
2521+
"description" => __SchemaField::Description,
25192522
"types" => {
25202523
let builders = self
25212524
.types()
@@ -2601,6 +2604,7 @@ impl __Schema {
26012604
}
26022605

26032606
Ok(__SchemaBuilder {
2607+
description: "Represents the GraphQL schema of the database".to_string(),
26042608
selections: builder_fields,
26052609
})
26062610
}

src/transpile.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,9 @@ impl Serialize for __SchemaBuilder {
16601660

16611661
for selection in &self.selections {
16621662
match &selection.selection {
1663+
__SchemaField::Description => {
1664+
map.serialize_entry(&selection.alias, &self.description)?;
1665+
}
16631666
__SchemaField::Types(type_builders) => {
16641667
map.serialize_entry(&selection.alias, &type_builders)?;
16651668
}

test/expected/issue_581_missing_desc_on_schema.out

Lines changed: 105 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
begin;
2+
3+
select graphql.resolve($$
4+
query IntrospectionQuery {
5+
__schema {
6+
description
7+
queryType { name }
8+
mutationType { name }
9+
subscriptionType { name }
10+
types {
11+
...FullType
12+
}
13+
directives {
14+
name
15+
description
16+
17+
locations
18+
args(includeDeprecated: true) {
19+
...InputValue
20+
}
21+
}
22+
}
23+
}
24+
25+
fragment FullType on __Type {
26+
kind
27+
name
28+
description
29+
30+
fields(includeDeprecated: true) {
31+
name
32+
description
33+
args(includeDeprecated: true) {
34+
...InputValue
35+
}
36+
type {
37+
...TypeRef
38+
}
39+
isDeprecated
40+
deprecationReason
41+
}
42+
inputFields(includeDeprecated: true) {
43+
...InputValue
44+
}
45+
interfaces {
46+
...TypeRef
47+
}
48+
enumValues(includeDeprecated: true) {
49+
name
50+
description
51+
isDeprecated
52+
deprecationReason
53+
}
54+
possibleTypes {
55+
...TypeRef
56+
}
57+
}
58+
59+
fragment InputValue on __InputValue {
60+
name
61+
description
62+
type { ...TypeRef }
63+
defaultValue
64+
isDeprecated
65+
deprecationReason
66+
}
67+
68+
fragment TypeRef on __Type {
69+
kind
70+
name
71+
ofType {
72+
kind
73+
name
74+
ofType {
75+
kind
76+
name
77+
ofType {
78+
kind
79+
name
80+
ofType {
81+
kind
82+
name
83+
ofType {
84+
kind
85+
name
86+
ofType {
87+
kind
88+
name
89+
ofType {
90+
kind
91+
name
92+
}
93+
}
94+
}
95+
}
96+
}
97+
}
98+
}
99+
}
100+
$$, NULL, 'IntrospectionQuery');
101+
102+
rollback;

0 commit comments

Comments
 (0)