Skip to content

Commit

Permalink
test(graphql-printer): Ensure that generated schemas is valid.
Browse files Browse the repository at this point in the history
  • Loading branch information
LastDragon-ru committed Mar 13, 2024
1 parent 95c540c commit 334d3dc
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 57 deletions.
9 changes: 8 additions & 1 deletion packages/graphql-printer/src/PrinterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public function testPrint(
$actual = $printer->print($printable, $level, $used, $type);

$this->assertGraphQLPrintableEquals($expected, $actual);

if ($printable instanceof Schema) {
$printable->assertValid();
}
}

/**
Expand Down Expand Up @@ -89,6 +93,10 @@ public function testExport(
$actual = $printer->export($exportable, $level, $used, $type);

$this->assertGraphQLPrintableEquals($expected, $actual);

if ($exportable instanceof Schema) {
$exportable->assertValid();
}
}
// </editor-fold>

Expand Down Expand Up @@ -549,7 +557,6 @@ static function (TestCase $test, Schema $schema): Type {
'Int',
'Float',
'InterfaceA',
'InterfaceB',
'InterfaceC',
'InputHidden',
'TypeHidden',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
interface InterfaceC
implements
& InterfaceA
& InterfaceB
{
a: Int
b: [String!]
Expand Down Expand Up @@ -60,21 +59,6 @@
a: Int
}

interface InterfaceB
implements
& InterfaceA
{
"""
Field description.
"""
a: Int

b: [String!]
@directive(
location: "field"
)
}

type TypeHidden {
a: Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Type description.
"""
type TypeA
implements
& InterfaceA
& InterfaceB
& InterfaceC
@directive(
Expand All @@ -21,8 +22,14 @@ implements
b: [String!]

c: [Float!]!
d: TypeHidden!

e(
a: Int
b: InputHidden
): Int

d: [String!]
f: [String!]
@directive(
location: "extend"
)
Expand Down Expand Up @@ -92,7 +99,6 @@ implements
interface InterfaceC
implements
& InterfaceA
& InterfaceB
{
a: Int
b: [String!]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ implements
interface InterfaceC
implements
& InterfaceA
& InterfaceB
{
a: Int
b: [String!]
Expand All @@ -83,6 +82,7 @@ Type description.
"""
type TypeA
implements
& InterfaceA
& InterfaceB
& InterfaceC
@directive(
Expand All @@ -101,8 +101,14 @@ implements
b: [String!]

c: [Float!]!
d: TypeHidden!

e(
a: Int
b: InputHidden
): Int

d: [String!]
f: [String!]
@directive(
location: "extend"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
interface InterfaceC
implements
& InterfaceA
& InterfaceB
{
a: Int
b: [String!]
Expand All @@ -83,6 +82,7 @@
"""
type TypeA
implements
& InterfaceA
& InterfaceB
& InterfaceC
@directive(
Expand All @@ -101,8 +101,14 @@
b: [String!]

c: [Float!]!
d: TypeHidden!

e(
a: Int
b: InputHidden
): Int

d: [String!]
f: [String!]
@directive(
location: "extend"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ implements
interface InterfaceC
implements
& InterfaceA
& InterfaceB
{
a: Int
b: [String!]
Expand Down Expand Up @@ -182,6 +181,7 @@ Type description.
"""
type TypeA
implements
& InterfaceA
& InterfaceB
& InterfaceC
@directive(
Expand All @@ -200,8 +200,14 @@ implements
b: [String!]

c: [Float!]!
d: TypeHidden!

e(
a: Int
b: InputHidden
): Int

d: [String!]
f: [String!]
@directive(
location: "extend"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ interface InterfaceB implements InterfaceA {
b: [String!]
}

interface InterfaceC implements InterfaceA & InterfaceB {
interface InterfaceC implements InterfaceA {
b: [String!]
c: [Float!]!
a: Int
Expand Down Expand Up @@ -92,7 +92,7 @@ type Subscription {
"""
Type description.
"""
type TypeA implements InterfaceC & InterfaceB {
type TypeA implements InterfaceA & InterfaceC & InterfaceB {
"""
Field description.
"""
Expand All @@ -103,7 +103,9 @@ type TypeA implements InterfaceC & InterfaceB {
a: Int
@deprecated

d: [String!]
d: TypeHidden!
e(a: Int, b: InputHidden): Int
f: [String!]
}

type TypeB {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ implements
interface InterfaceC
implements
& InterfaceA
& InterfaceB
{
a: Int
b: [String!]
Expand Down Expand Up @@ -169,6 +168,7 @@ Type description.
"""
type TypeA
implements
& InterfaceA
& InterfaceB
& InterfaceC
@directive(
Expand All @@ -187,8 +187,14 @@ implements
b: [String!]

c: [Float!]!
d: TypeHidden!

e(
a: Int
b: InputHidden
): Int

d: [String!]
f: [String!]
@directive(
location: "extend"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ implements
interface InterfaceC
implements
& InterfaceA
& InterfaceB
{
a: Int
b: [String!]
Expand Down Expand Up @@ -217,6 +216,7 @@ Type description.
"""
type TypeA
implements
& InterfaceA
& InterfaceB
& InterfaceC
@directive(
Expand All @@ -235,8 +235,14 @@ implements
b: [String!]

c: [Float!]!
d: TypeHidden!

e(
a: Int
b: InputHidden
): Int

d: [String!]
f: [String!]
@directive(
location: "extend"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ implements
interface InterfaceC
implements
& InterfaceA
& InterfaceB
{
a: Int
b: [String!]
Expand Down Expand Up @@ -154,6 +153,7 @@ Type description.
"""
type TypeA
implements
& InterfaceA
& InterfaceB
& InterfaceC
@directive(
Expand All @@ -172,8 +172,14 @@ implements
b: [String!]

c: [Float!]!
d: TypeHidden!

e(
a: Int
b: InputHidden
): Int

d: [String!]
f: [String!]
@directive(
location: "extend"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ enum Enum
"""
Type description.
"""
type TypeA implements InterfaceC & InterfaceB
type TypeA implements InterfaceA & InterfaceC & InterfaceB
@directive(
location: "type"
)
Expand All @@ -179,7 +179,14 @@ type TypeA implements InterfaceC & InterfaceB
a: Int
@deprecated

d: [String!]
d: TypeHidden!

e(
a: Int
b: InputHidden
): Int

f: [String!]
@directive(
location: "extend"
)
Expand All @@ -197,6 +204,18 @@ interface InterfaceB implements InterfaceA {
)
}

interface InterfaceC implements InterfaceA {
b: [String!]
c: [Float!]!
a: Int
d: TypeHidden!

e(
a: Int
b: InputHidden
): Int
}

"""
Interface description.
"""
Expand All @@ -210,15 +229,3 @@ interface InterfaceA
{
a: Int
}

interface InterfaceC implements InterfaceA & InterfaceB {
b: [String!]
c: [Float!]!
a: Int
d: TypeHidden!

e(
a: Int
b: InputHidden
): Int
}
Loading

0 comments on commit 334d3dc

Please sign in to comment.