Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy codec description through to enum in GraphQL schema #2199

Merged
merged 4 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/quiet-phones-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"graphile-build-pg": patch
"graphile-build": patch
"postgraphile": patch
---

Database enum comments are now reflected in the schema.
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@ export const PgCodecsPlugin: GraphileConfig.Plugin = {
typeName,
{},
() => ({
description: build.wrapDescription(codec.description, "type"),
values,
}),
"PgCodecsPlugin",
Expand Down
9 changes: 6 additions & 3 deletions graphile-build/graphile-build/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,12 @@ function breakLine(line: string, maxLen: number): Array<string> {
* descriptions that contain code blocks or long inline code strings.
*/
export const wrapDescription = (
description: string,
description: string | null | undefined,
position: "root" | "type" | "field" | "arg",
): string => {
): string | null => {
if (description == null) {
return null;
}
const indentationLength =
position === "root"
? 0
Expand Down Expand Up @@ -204,7 +207,7 @@ export const wrapDescription = (
* given description/coercion.
*/
export const stringTypeSpec = (
description: string,
description: string | null,
coerce?: (input: string) => string,
name?: string,
): Omit<GraphQLScalarTypeConfig<any, any>, "name"> => ({
Expand Down
2 changes: 2 additions & 0 deletions postgraphile/postgraphile/__tests__/kitchen-sink-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ create type b.color as enum ('red', 'green', 'blue');
create type b.enum_caps as enum ('FOO_BAR', 'BAR_FOO', 'BAZ_QUX', '0_BAR');
create type b.enum_with_empty_string as enum ('', 'one', 'two');

comment on type b.color is E'Represents the colours red, green and blue.';

create type c.compound_type as (
a int,
b text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ const colorCodec = enumCodec({
name: "color",
identifier: sql.identifier("b", "color"),
values: ["red", "green", "blue"],
description: undefined,
description: "Represents the colours red, green and blue.",
extensions: {
pg: {
serviceName: "main",
Expand Down Expand Up @@ -17687,6 +17687,7 @@ type CompoundType {
fooBar: Int
}

"""Represents the colours red, green and blue."""
enum Color {
RED
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ strings and not numbers.
"""
scalar BigInt

"""Represents the colours red, green and blue."""
enum Color {
BLUE
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ const colorCodec = enumCodec({
name: "color",
identifier: sql.identifier("b", "color"),
values: ["red", "green", "blue"],
description: undefined,
description: "Represents the colours red, green and blue.",
extensions: {
pg: {
serviceName: "main",
Expand Down Expand Up @@ -17687,6 +17687,7 @@ type CompoundType {
fooBar: Int
}

"""Represents the colours red, green and blue."""
enum Color {
RED
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ strings and not numbers.
"""
scalar BigInt

"""Represents the colours red, green and blue."""
enum Color {
BLUE
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ const colorCodec = enumCodec({
name: "color",
identifier: sql.identifier("b", "color"),
values: ["red", "green", "blue"],
description: undefined,
description: "Represents the colours red, green and blue.",
extensions: {
pg: {
serviceName: "main",
Expand Down Expand Up @@ -10054,6 +10054,7 @@ type CompoundType {
fooBar: Int
}

"""Represents the colours red, green and blue."""
enum Color {
RED
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ strings and not numbers.
"""
scalar BigInt

"""Represents the colours red, green and blue."""
enum Color {
BLUE
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ const colorCodec = enumCodec({
name: "color",
identifier: sql.identifier("b", "color"),
values: ["red", "green", "blue"],
description: undefined,
description: "Represents the colours red, green and blue.",
extensions: {
pg: {
serviceName: "main",
Expand Down Expand Up @@ -10055,6 +10055,7 @@ type CompoundType {
fooBar: Int
}

"""Represents the colours red, green and blue."""
enum Color {
RED
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ strings and not numbers.
"""
scalar BigInt

"""Represents the colours red, green and blue."""
enum Color {
BLUE
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ const colorCodec = enumCodec({
name: "color",
identifier: sql.identifier("b", "color"),
values: ["red", "green", "blue"],
description: undefined,
description: "Represents the colours red, green and blue.",
extensions: {
pg: {
serviceName: "main",
Expand Down Expand Up @@ -17771,6 +17771,7 @@ type CompoundType {
fooBar: Int
}

"""Represents the colours red, green and blue."""
enum Color {
RED
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ strings and not numbers.
"""
scalar BigInt

"""Represents the colours red, green and blue."""
enum Color {
BLUE
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ const colorCodec = enumCodec({
name: "color",
identifier: sql.identifier("b", "color"),
values: ["red", "green", "blue"],
description: undefined,
description: "Represents the colours red, green and blue.",
extensions: {
pg: {
serviceName: "main",
Expand Down Expand Up @@ -17713,6 +17713,7 @@ type CompoundType {
fooBar: Int
}

"""Represents the colours red, green and blue."""
enum Color {
RED
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ strings and not numbers.
"""
scalar BigInt

"""Represents the colours red, green and blue."""
enum Color {
BLUE
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@ const colorCodec = enumCodec({
name: "color",
identifier: sql.identifier("b", "color"),
values: ["red", "green", "blue"],
description: undefined,
description: "Represents the colours red, green and blue.",
extensions: {
pg: {
serviceName: "main",
Expand Down Expand Up @@ -17704,6 +17704,7 @@ type CompoundType {
fooBar: Int
}

"""Represents the colours red, green and blue."""
enum Color {
RED
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ strings and not numbers.
"""
scalar BigInt

"""Represents the colours red, green and blue."""
enum Color {
BLUE
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ const colorCodec = enumCodec({
name: "color",
identifier: sql.identifier("b", "color"),
values: ["red", "green", "blue"],
description: undefined,
description: "Represents the colours red, green and blue.",
extensions: {
pg: {
serviceName: "main",
Expand Down Expand Up @@ -17692,6 +17692,7 @@ type CompoundType {
fooBar: Int
}

"""Represents the colours red, green and blue."""
enum Color {
RED
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ strings and not numbers.
"""
scalar BigInt

"""Represents the colours red, green and blue."""
enum Color {
BLUE
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ const colorCodec = enumCodec({
name: "color",
identifier: sql.identifier("b", "color"),
values: ["red", "green", "blue"],
description: undefined,
description: "Represents the colours red, green and blue.",
extensions: {
pg: {
serviceName: "main",
Expand Down Expand Up @@ -3351,6 +3351,7 @@ A floating point number that requires more precision than IEEE 754 binary 64
"""
scalar BigFloat

"""Represents the colours red, green and blue."""
enum Color {
RED
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ strings and not numbers.
"""
scalar BigInt

"""Represents the colours red, green and blue."""
enum Color {
BLUE
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ const colorCodec = enumCodec({
name: "color",
identifier: sql.identifier("b", "color"),
values: ["red", "green", "blue"],
description: undefined,
description: "Represents the colours red, green and blue.",
extensions: {
pg: {
serviceName: "main",
Expand Down Expand Up @@ -9925,6 +9925,7 @@ type CompoundType {
fooBar: Int
}

"""Represents the colours red, green and blue."""
enum Color {
RED
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ strings and not numbers.
"""
scalar BigInt

"""Represents the colours red, green and blue."""
enum Color {
BLUE
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ const colorCodec = enumCodec({
name: "color",
identifier: sql.identifier("b", "color"),
values: ["red", "green", "blue"],
description: undefined,
description: "Represents the colours red, green and blue.",
extensions: {
pg: {
serviceName: "main",
Expand Down Expand Up @@ -1057,6 +1057,7 @@ type DomainConstrainedCompoundType {
fooBar: Int
}

"""Represents the colours red, green and blue."""
enum Color {
RED
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ input ByDefaultAsIdentityPatch {
t: String
}

"""Represents the colours red, green and blue."""
enum Color {
BLUE
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ const colorCodec = enumCodec({
name: "color",
identifier: sql.identifier("b", "color"),
values: ["red", "green", "blue"],
description: undefined,
description: "Represents the colours red, green and blue.",
extensions: {
pg: {
serviceName: "main",
Expand Down Expand Up @@ -1066,6 +1066,7 @@ type DomainConstrainedCompoundType {
fooBar: Int
}

"""Represents the colours red, green and blue."""
enum Color {
RED
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ input ByDefaultAsIdentityPatch {
"""An IPv4 or IPv6 CIDR address."""
scalar CidrAddress

"""Represents the colours red, green and blue."""
enum Color {
BLUE
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,7 @@ const colorCodec = enumCodec({
name: "color",
identifier: sql.identifier("b", "color"),
values: ["red", "green", "blue"],
description: undefined,
description: "Represents the colours red, green and blue.",
extensions: {
pg: {
serviceName: "main",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ const colorCodec = enumCodec({
name: "color",
identifier: sql.identifier("b", "color"),
values: ["red", "green", "blue"],
description: undefined,
description: "Represents the colours red, green and blue.",
extensions: {
pg: {
serviceName: "main",
Expand Down Expand Up @@ -17687,6 +17687,7 @@ type CompoundType {
fooBar: Int
}

"""Represents the colours red, green and blue."""
enum Color {
RED
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ strings and not numbers.
"""
scalar BigInt

"""Represents the colours red, green and blue."""
enum Color {
BLUE
GREEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ const colorCodec = enumCodec({
name: "color",
identifier: sql.identifier("b", "color"),
values: ["red", "green", "blue"],
description: undefined,
description: "Represents the colours red, green and blue.",
extensions: {
pg: {
serviceName: "main",
Expand Down Expand Up @@ -9981,6 +9981,7 @@ type CompoundType {
fooBar: Int
}

"""Represents the colours red, green and blue."""
enum Color {
RED
GREEN
Expand Down
Loading
Loading