mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-06 15:59:24 +03:00
Remove redundancy in schema printer tests
This commit is contained in:
parent
227f0b867d
commit
f123e5c954
@ -29,7 +29,7 @@ class SchemaPrinterTest extends TestCase
|
|||||||
private function printSingleFieldSchema($fieldConfig)
|
private function printSingleFieldSchema($fieldConfig)
|
||||||
{
|
{
|
||||||
$query = new ObjectType([
|
$query = new ObjectType([
|
||||||
'name' => 'Root',
|
'name' => 'Query',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'singleField' => $fieldConfig
|
'singleField' => $fieldConfig
|
||||||
]
|
]
|
||||||
@ -46,11 +46,7 @@ class SchemaPrinterTest extends TestCase
|
|||||||
'type' => Type::string()
|
'type' => Type::string()
|
||||||
]);
|
]);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
singleField: String
|
singleField: String
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -65,11 +61,7 @@ type Root {
|
|||||||
'type' => Type::listOf(Type::string())
|
'type' => Type::listOf(Type::string())
|
||||||
]);
|
]);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
singleField: [String]
|
singleField: [String]
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -84,11 +76,7 @@ type Root {
|
|||||||
'type' => Type::nonNull(Type::string())
|
'type' => Type::nonNull(Type::string())
|
||||||
]);
|
]);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
singleField: String!
|
singleField: String!
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -103,11 +91,7 @@ type Root {
|
|||||||
'type' => Type::nonNull(Type::listOf(Type::string()))
|
'type' => Type::nonNull(Type::listOf(Type::string()))
|
||||||
]);
|
]);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
singleField: [String]!
|
singleField: [String]!
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -122,11 +106,7 @@ type Root {
|
|||||||
'type' => Type::listOf(Type::nonNull(Type::string()))
|
'type' => Type::listOf(Type::nonNull(Type::string()))
|
||||||
]);
|
]);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
singleField: [String!]
|
singleField: [String!]
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -141,18 +121,14 @@ type Root {
|
|||||||
'type' => Type::nonNull(Type::listOf(Type::nonNull(Type::string())))
|
'type' => Type::nonNull(Type::listOf(Type::nonNull(Type::string())))
|
||||||
]);
|
]);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
singleField: [String!]!
|
singleField: [String!]!
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @it Prints Object Field
|
* @it Print Object Field
|
||||||
*/
|
*/
|
||||||
public function testPrintObjectField()
|
public function testPrintObjectField()
|
||||||
{
|
{
|
||||||
@ -162,22 +138,18 @@ type Root {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$root = new ObjectType([
|
$root = new ObjectType([
|
||||||
'name' => 'Root',
|
'name' => 'Query',
|
||||||
'fields' => ['foo' => ['type' => $fooType]]
|
'fields' => ['foo' => ['type' => $fooType]]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$schema = new Schema(['query' => $root]);
|
$schema = new Schema(['query' => $root]);
|
||||||
$output = $this->printForTest($schema);
|
$output = $this->printForTest($schema);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Foo {
|
type Foo {
|
||||||
str: String
|
str: String
|
||||||
}
|
}
|
||||||
|
|
||||||
type Root {
|
type Query {
|
||||||
foo: Foo
|
foo: Foo
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -193,11 +165,7 @@ type Root {
|
|||||||
'args' => ['argOne' => ['type' => Type::int()]]
|
'args' => ['argOne' => ['type' => Type::int()]]
|
||||||
]);
|
]);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
singleField(argOne: Int): String
|
singleField(argOne: Int): String
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -213,11 +181,7 @@ type Root {
|
|||||||
'args' => ['argOne' => ['type' => Type::int(), 'defaultValue' => 2]]
|
'args' => ['argOne' => ['type' => Type::int(), 'defaultValue' => 2]]
|
||||||
]);
|
]);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
singleField(argOne: Int = 2): String
|
singleField(argOne: Int = 2): String
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -233,11 +197,7 @@ type Root {
|
|||||||
'args' => ['argOne' => ['type' => Type::string(), 'defaultValue' => "tes\t de\fault"]],
|
'args' => ['argOne' => ['type' => Type::string(), 'defaultValue' => "tes\t de\fault"]],
|
||||||
]);
|
]);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
singleField(argOne: String = "tes\t de\fault"): String
|
singleField(argOne: String = "tes\t de\fault"): String
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -253,11 +213,7 @@ type Root {
|
|||||||
'args' => ['argOne' => ['type' => Type::int(), 'defaultValue' => null]]
|
'args' => ['argOne' => ['type' => Type::int(), 'defaultValue' => null]]
|
||||||
]);
|
]);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
singleField(argOne: Int = null): String
|
singleField(argOne: Int = null): String
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -273,11 +229,7 @@ type Root {
|
|||||||
'args' => ['argOne' => ['type' => Type::nonNull(Type::int())]]
|
'args' => ['argOne' => ['type' => Type::nonNull(Type::int())]]
|
||||||
]);
|
]);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
singleField(argOne: Int!): String
|
singleField(argOne: Int!): String
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -296,11 +248,7 @@ type Root {
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
singleField(argOne: Int, argTwo: String): String
|
singleField(argOne: Int, argTwo: String): String
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -320,11 +268,7 @@ type Root {
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
singleField(argOne: Int = 1, argTwo: String, argThree: Boolean): String
|
singleField(argOne: Int = 1, argTwo: String, argThree: Boolean): String
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -344,11 +288,7 @@ type Root {
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
singleField(argOne: Int, argTwo: String = "foo", argThree: Boolean): String
|
singleField(argOne: Int, argTwo: String = "foo", argThree: Boolean): String
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -368,16 +308,38 @@ type Root {
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
singleField(argOne: Int, argTwo: String, argThree: Boolean = false): String
|
singleField(argOne: Int, argTwo: String, argThree: Boolean = false): String
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @it Prints custom query root type
|
||||||
|
*/
|
||||||
|
public function testPrintsCustomQueryRootType()
|
||||||
|
{
|
||||||
|
$customQueryType = new ObjectType([
|
||||||
|
'name' => 'CustomQueryType',
|
||||||
|
'fields' => ['bar' => ['type' => Type::string()]],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$schema = new Schema([
|
||||||
|
'query' => $customQueryType,
|
||||||
|
]);
|
||||||
|
$output = $this->printForTest($schema);
|
||||||
|
$expected = '
|
||||||
|
schema {
|
||||||
|
query: CustomQueryType
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomQueryType {
|
||||||
|
bar: String
|
||||||
|
}
|
||||||
|
';
|
||||||
|
$this->assertEquals($expected, $output);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @it Print Interface
|
* @it Print Interface
|
||||||
*/
|
*/
|
||||||
@ -394,21 +356,17 @@ type Root {
|
|||||||
'interfaces' => [$fooType]
|
'interfaces' => [$fooType]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$root = new ObjectType([
|
$query = new ObjectType([
|
||||||
'name' => 'Root',
|
'name' => 'Query',
|
||||||
'fields' => ['bar' => ['type' => $barType]]
|
'fields' => ['bar' => ['type' => $barType]]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$schema = new Schema([
|
$schema = new Schema([
|
||||||
'query' => $root,
|
'query' => $query,
|
||||||
'types' => [$barType]
|
'types' => [$barType]
|
||||||
]);
|
]);
|
||||||
$output = $this->printForTest($schema);
|
$output = $this->printForTest($schema);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Bar implements Foo {
|
type Bar implements Foo {
|
||||||
str: String
|
str: String
|
||||||
}
|
}
|
||||||
@ -417,7 +375,7 @@ interface Foo {
|
|||||||
str: String
|
str: String
|
||||||
}
|
}
|
||||||
|
|
||||||
type Root {
|
type Query {
|
||||||
bar: Bar
|
bar: Bar
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -447,21 +405,17 @@ type Root {
|
|||||||
'interfaces' => [$fooType, $baazType]
|
'interfaces' => [$fooType, $baazType]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$root = new ObjectType([
|
$query = new ObjectType([
|
||||||
'name' => 'Root',
|
'name' => 'Query',
|
||||||
'fields' => ['bar' => ['type' => $barType]]
|
'fields' => ['bar' => ['type' => $barType]]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$schema = new Schema([
|
$schema = new Schema([
|
||||||
'query' => $root,
|
'query' => $query,
|
||||||
'types' => [$barType]
|
'types' => [$barType]
|
||||||
]);
|
]);
|
||||||
$output = $this->printForTest($schema);
|
$output = $this->printForTest($schema);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Baaz {
|
interface Baaz {
|
||||||
int: Int
|
int: Int
|
||||||
}
|
}
|
||||||
@ -475,7 +429,7 @@ interface Foo {
|
|||||||
str: String
|
str: String
|
||||||
}
|
}
|
||||||
|
|
||||||
type Root {
|
type Query {
|
||||||
bar: Bar
|
bar: Bar
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -506,21 +460,17 @@ type Root {
|
|||||||
'types' => [$fooType, $barType]
|
'types' => [$fooType, $barType]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$root = new ObjectType([
|
$query = new ObjectType([
|
||||||
'name' => 'Root',
|
'name' => 'Query',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'single' => ['type' => $singleUnion],
|
'single' => ['type' => $singleUnion],
|
||||||
'multiple' => ['type' => $multipleUnion]
|
'multiple' => ['type' => $multipleUnion]
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$schema = new Schema(['query' => $root]);
|
$schema = new Schema(['query' => $query]);
|
||||||
$output = $this->printForTest($schema);
|
$output = $this->printForTest($schema);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Bar {
|
type Bar {
|
||||||
str: String
|
str: String
|
||||||
}
|
}
|
||||||
@ -531,7 +481,7 @@ type Foo {
|
|||||||
|
|
||||||
union MultipleUnion = Foo | Bar
|
union MultipleUnion = Foo | Bar
|
||||||
|
|
||||||
type Root {
|
type Query {
|
||||||
single: SingleUnion
|
single: SingleUnion
|
||||||
multiple: MultipleUnion
|
multiple: MultipleUnion
|
||||||
}
|
}
|
||||||
@ -550,8 +500,8 @@ union SingleUnion = Foo
|
|||||||
'fields' => ['int' => ['type' => Type::int()]]
|
'fields' => ['int' => ['type' => Type::int()]]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$root = new ObjectType([
|
$query = new ObjectType([
|
||||||
'name' => 'Root',
|
'name' => 'Query',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'str' => [
|
'str' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
@ -560,18 +510,14 @@ union SingleUnion = Foo
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$schema = new Schema(['query' => $root]);
|
$schema = new Schema(['query' => $query]);
|
||||||
$output = $this->printForTest($schema);
|
$output = $this->printForTest($schema);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
input InputType {
|
input InputType {
|
||||||
int: Int
|
int: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Root {
|
type Query {
|
||||||
str(argOne: InputType): String
|
str(argOne: InputType): String
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -589,23 +535,19 @@ type Root {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$root = new ObjectType([
|
$query = new ObjectType([
|
||||||
'name' => 'Root',
|
'name' => 'Query',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'odd' => ['type' => $oddType]
|
'odd' => ['type' => $oddType]
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$schema = new Schema(['query' => $root]);
|
$schema = new Schema(['query' => $query]);
|
||||||
$output = $this->printForTest($schema);
|
$output = $this->printForTest($schema);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
scalar Odd
|
scalar Odd
|
||||||
|
|
||||||
type Root {
|
type Query {
|
||||||
odd: Odd
|
odd: Odd
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
@ -625,18 +567,18 @@ type Root {
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$root = new ObjectType([
|
$query = new ObjectType([
|
||||||
'name' => 'Root',
|
'name' => 'Query',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'rgb' => ['type' => $RGBType]
|
'rgb' => ['type' => $RGBType]
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$schema = new Schema(['query' => $root]);
|
$schema = new Schema(['query' => $query]);
|
||||||
$output = $this->printForTest($schema);
|
$output = $this->printForTest($schema);
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
rgb: RGB
|
||||||
}
|
}
|
||||||
|
|
||||||
enum RGB {
|
enum RGB {
|
||||||
@ -644,10 +586,6 @@ enum RGB {
|
|||||||
GREEN
|
GREEN
|
||||||
BLUE
|
BLUE
|
||||||
}
|
}
|
||||||
|
|
||||||
type Root {
|
|
||||||
rgb: RGB
|
|
||||||
}
|
|
||||||
', $output);
|
', $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,17 +635,13 @@ type Query {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
"""This field is awesome"""
|
"""This field is awesome"""
|
||||||
singleField: String
|
singleField: String
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
|
|
||||||
$recreatedRoot = BuildSchema::build($output)->getTypeMap()['Root'];
|
$recreatedRoot = BuildSchema::build($output)->getTypeMap()['Query'];
|
||||||
$recreatedField = $recreatedRoot->getFields()['singleField'];
|
$recreatedField = $recreatedRoot->getFields()['singleField'];
|
||||||
$this->assertEquals($description, $recreatedField->description);
|
$this->assertEquals($description, $recreatedField->description);
|
||||||
}
|
}
|
||||||
@ -724,11 +658,7 @@ type Root {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
"""
|
"""
|
||||||
This field is "awesome"
|
This field is "awesome"
|
||||||
"""
|
"""
|
||||||
@ -736,7 +666,7 @@ type Root {
|
|||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
|
|
||||||
$recreatedRoot = BuildSchema::build($output)->getTypeMap()['Root'];
|
$recreatedRoot = BuildSchema::build($output)->getTypeMap()['Query'];
|
||||||
$recreatedField = $recreatedRoot->getFields()['singleField'];
|
$recreatedField = $recreatedRoot->getFields()['singleField'];
|
||||||
$this->assertEquals($description, $recreatedField->description);
|
$this->assertEquals($description, $recreatedField->description);
|
||||||
}
|
}
|
||||||
@ -753,18 +683,14 @@ type Root {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertEquals('
|
$this->assertEquals('
|
||||||
schema {
|
type Query {
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
type Root {
|
|
||||||
""" This field is "awesome"
|
""" This field is "awesome"
|
||||||
"""
|
"""
|
||||||
singleField: String
|
singleField: String
|
||||||
}
|
}
|
||||||
', $output);
|
', $output);
|
||||||
|
|
||||||
$recreatedRoot = BuildSchema::build($output)->getTypeMap()['Root'];
|
$recreatedRoot = BuildSchema::build($output)->getTypeMap()['Query'];
|
||||||
$recreatedField = $recreatedRoot->getFields()['singleField'];
|
$recreatedField = $recreatedRoot->getFields()['singleField'];
|
||||||
$this->assertEquals($description, $recreatedField->description);
|
$this->assertEquals($description, $recreatedField->description);
|
||||||
}
|
}
|
||||||
@ -774,20 +700,16 @@ type Root {
|
|||||||
*/
|
*/
|
||||||
public function testPrintIntrospectionSchema()
|
public function testPrintIntrospectionSchema()
|
||||||
{
|
{
|
||||||
$root = new ObjectType([
|
$query = new ObjectType([
|
||||||
'name' => 'Root',
|
'name' => 'Query',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'onlyField' => ['type' => Type::string()]
|
'onlyField' => ['type' => Type::string()]
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$schema = new Schema(['query' => $root]);
|
$schema = new Schema(['query' => $query]);
|
||||||
$output = SchemaPrinter::printIntrosepctionSchema($schema);
|
$output = SchemaPrinter::printIntrosepctionSchema($schema);
|
||||||
$introspectionSchema = <<<'EOT'
|
$introspectionSchema = <<<'EOT'
|
||||||
schema {
|
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Directs the executor to include this field or fragment only when the `if` argument is true.
|
Directs the executor to include this field or fragment only when the `if` argument is true.
|
||||||
"""
|
"""
|
||||||
@ -1019,26 +941,22 @@ EOT;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @it Print Introspection Schema with comment description
|
* @it Print Introspection Schema with comment descriptions
|
||||||
*/
|
*/
|
||||||
public function testPrintIntrospectionSchemaWithCommentDescription()
|
public function testPrintIntrospectionSchemaWithCommentDescriptions()
|
||||||
{
|
{
|
||||||
$root = new ObjectType([
|
$query = new ObjectType([
|
||||||
'name' => 'Root',
|
'name' => 'Query',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'onlyField' => ['type' => Type::string()]
|
'onlyField' => ['type' => Type::string()]
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$schema = new Schema(['query' => $root]);
|
$schema = new Schema(['query' => $query]);
|
||||||
$output = SchemaPrinter::printIntrosepctionSchema($schema, [
|
$output = SchemaPrinter::printIntrosepctionSchema($schema, [
|
||||||
'commentDescriptions' => true
|
'commentDescriptions' => true
|
||||||
]);
|
]);
|
||||||
$introspectionSchema = <<<'EOT'
|
$introspectionSchema = <<<'EOT'
|
||||||
schema {
|
|
||||||
query: Root
|
|
||||||
}
|
|
||||||
|
|
||||||
# Directs the executor to include this field or fragment only when the `if` argument is true.
|
# Directs the executor to include this field or fragment only when the `if` argument is true.
|
||||||
directive @include(
|
directive @include(
|
||||||
# Included when true.
|
# Included when true.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user