mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-25 14:26:08 +03:00
SchemaPrinter: reverted sorting of fields in printed version (as it breaks s = parse(print(s))
rule)
This commit is contained in:
parent
ea94ee7515
commit
24bcc65314
@ -204,7 +204,7 @@ class SchemaPrinter
|
||||
|
||||
private static function printInputObject(InputObjectType $type)
|
||||
{
|
||||
$fields = self::sortFields($type->getFields());
|
||||
$fields = array_values($type->getFields());
|
||||
return self::printDescription($type) .
|
||||
"input {$type->name} {\n" .
|
||||
implode("\n", array_map(function($f, $i) {
|
||||
@ -215,7 +215,7 @@ class SchemaPrinter
|
||||
|
||||
private static function printFields($type)
|
||||
{
|
||||
$fields = self::sortFields($type->getFields());
|
||||
$fields = array_values($type->getFields());
|
||||
return implode("\n", array_map(function($f, $i) {
|
||||
return self::printDescription($f, ' ', !$i) . ' ' .
|
||||
$f->name . self::printArgs($f->args, ' ') . ': ' .
|
||||
@ -302,10 +302,4 @@ class SchemaPrinter
|
||||
return trim($part);
|
||||
}, $parts);
|
||||
}
|
||||
|
||||
private static function sortFields(array $fields)
|
||||
{
|
||||
ksort($fields);
|
||||
return array_values($fields);
|
||||
}
|
||||
}
|
@ -71,11 +71,11 @@ schema {
|
||||
}
|
||||
|
||||
type HelloScalars {
|
||||
bool: Boolean
|
||||
str: String
|
||||
int: Int
|
||||
float: Float
|
||||
id: ID
|
||||
int: Int
|
||||
str: String
|
||||
bool: Boolean
|
||||
}
|
||||
';
|
||||
$output = $this->cycleOutput($body);
|
||||
@ -194,11 +194,11 @@ schema {
|
||||
}
|
||||
|
||||
type HelloScalars {
|
||||
listOfNonNullStrs: [String!]
|
||||
listOfStrs: [String]
|
||||
nonNullListOfNonNullStrs: [String!]!
|
||||
nonNullListOfStrs: [String]!
|
||||
nonNullStr: String!
|
||||
listOfStrs: [String]
|
||||
listOfNonNullStrs: [String!]
|
||||
nonNullListOfStrs: [String]!
|
||||
nonNullListOfNonNullStrs: [String!]!
|
||||
}
|
||||
';
|
||||
$output = $this->cycleOutput($body);
|
||||
@ -216,8 +216,8 @@ schema {
|
||||
}
|
||||
|
||||
type Recurse {
|
||||
recurse: Recurse
|
||||
str: String
|
||||
recurse: Recurse
|
||||
}
|
||||
';
|
||||
$output = $this->cycleOutput($body);
|
||||
@ -259,10 +259,10 @@ schema {
|
||||
}
|
||||
|
||||
type Hello {
|
||||
booleanToStr(bool: Boolean): String
|
||||
str(int: Int): String
|
||||
floatToStr(float: Float): String
|
||||
idToStr(id: ID): String
|
||||
str(int: Int): String
|
||||
booleanToStr(bool: Boolean): String
|
||||
strToStr(bool: String): String
|
||||
}
|
||||
';
|
||||
@ -479,9 +479,9 @@ schema {
|
||||
}
|
||||
|
||||
type HelloScalars {
|
||||
bool: Boolean
|
||||
int: Int
|
||||
str: String
|
||||
int: Int
|
||||
bool: Boolean
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
@ -504,9 +504,9 @@ schema {
|
||||
}
|
||||
|
||||
type HelloScalars {
|
||||
bool: Boolean
|
||||
int: Int
|
||||
str: String
|
||||
int: Int
|
||||
bool: Boolean
|
||||
}
|
||||
|
||||
type Subscription {
|
||||
@ -572,9 +572,9 @@ enum MyEnum {
|
||||
}
|
||||
|
||||
type Query {
|
||||
enum: MyEnum
|
||||
field1: String @deprecated
|
||||
field2: Int @deprecated(reason: "Because I said so")
|
||||
enum: MyEnum
|
||||
}
|
||||
';
|
||||
$output = $this->cycleOutput($body);
|
||||
|
@ -445,8 +445,8 @@ interface Baaz {
|
||||
}
|
||||
|
||||
type Bar implements Foo, Baaz {
|
||||
int: Int
|
||||
str: String
|
||||
int: Int
|
||||
}
|
||||
|
||||
interface Foo {
|
||||
@ -512,8 +512,8 @@ type Foo {
|
||||
union MultipleUnion = Foo | Bar
|
||||
|
||||
type Root {
|
||||
multiple: MultipleUnion
|
||||
single: SingleUnion
|
||||
multiple: MultipleUnion
|
||||
}
|
||||
|
||||
union SingleUnion = Foo
|
||||
@ -677,13 +677,13 @@ directive @deprecated(
|
||||
# skipping a field. Directives provide this by describing additional information
|
||||
# to the executor.
|
||||
type __Directive {
|
||||
args: [__InputValue!]!
|
||||
name: String!
|
||||
description: String
|
||||
locations: [__DirectiveLocation!]!
|
||||
name: String!
|
||||
onField: Boolean! @deprecated(reason: "Use `locations`.")
|
||||
onFragment: Boolean! @deprecated(reason: "Use `locations`.")
|
||||
args: [__InputValue!]!
|
||||
onOperation: Boolean! @deprecated(reason: "Use `locations`.")
|
||||
onFragment: Boolean! @deprecated(reason: "Use `locations`.")
|
||||
onField: Boolean! @deprecated(reason: "Use `locations`.")
|
||||
}
|
||||
|
||||
# A Directive can be adjacent to many parts of the GraphQL language, a
|
||||
@ -748,52 +748,53 @@ enum __DirectiveLocation {
|
||||
# placeholder for a string or numeric value. However an Enum value is returned in
|
||||
# a JSON response as a string.
|
||||
type __EnumValue {
|
||||
deprecationReason: String
|
||||
name: String!
|
||||
description: String
|
||||
isDeprecated: Boolean!
|
||||
name: String!
|
||||
deprecationReason: String
|
||||
}
|
||||
|
||||
# Object and Interface types are described by a list of Fields, each of which has
|
||||
# a name, potentially a list of arguments, and a return type.
|
||||
type __Field {
|
||||
args: [__InputValue!]!
|
||||
deprecationReason: String
|
||||
description: String
|
||||
isDeprecated: Boolean!
|
||||
name: String!
|
||||
description: String
|
||||
args: [__InputValue!]!
|
||||
type: __Type!
|
||||
isDeprecated: Boolean!
|
||||
deprecationReason: String
|
||||
}
|
||||
|
||||
# Arguments provided to Fields or Directives and the input fields of an
|
||||
# InputObject are represented as Input Values which describe their type and
|
||||
# optionally a default value.
|
||||
type __InputValue {
|
||||
name: String!
|
||||
description: String
|
||||
type: __Type!
|
||||
|
||||
# A GraphQL-formatted string representing the default value for this input value.
|
||||
defaultValue: String
|
||||
description: String
|
||||
name: String!
|
||||
type: __Type!
|
||||
}
|
||||
|
||||
# A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all
|
||||
# available types and directives on the server, as well as the entry points for
|
||||
# query, mutation, and subscription operations.
|
||||
type __Schema {
|
||||
# A list of all directives supported by this server.
|
||||
directives: [__Directive!]!
|
||||
|
||||
# If this server supports mutation, the type that mutation operations will be rooted at.
|
||||
mutationType: __Type
|
||||
# A list of all types supported by this server.
|
||||
types: [__Type!]!
|
||||
|
||||
# The type that query operations will be rooted at.
|
||||
queryType: __Type!
|
||||
|
||||
# If this server supports mutation, the type that mutation operations will be rooted at.
|
||||
mutationType: __Type
|
||||
|
||||
# If this server support subscription, the type that subscription operations will be rooted at.
|
||||
subscriptionType: __Type
|
||||
|
||||
# A list of all types supported by this server.
|
||||
types: [__Type!]!
|
||||
# A list of all directives supported by this server.
|
||||
directives: [__Directive!]!
|
||||
}
|
||||
|
||||
# The fundamental unit of any GraphQL Schema is the type. There are many kinds of
|
||||
@ -805,15 +806,15 @@ type __Schema {
|
||||
# they describe. Abstract types, Union and Interface, provide the Object types
|
||||
# possible at runtime. List and NonNull types compose other types.
|
||||
type __Type {
|
||||
description: String
|
||||
enumValues(includeDeprecated: Boolean = false): [__EnumValue!]
|
||||
fields(includeDeprecated: Boolean = false): [__Field!]
|
||||
inputFields: [__InputValue!]
|
||||
interfaces: [__Type!]
|
||||
kind: __TypeKind!
|
||||
name: String
|
||||
ofType: __Type
|
||||
description: String
|
||||
fields(includeDeprecated: Boolean = false): [__Field!]
|
||||
interfaces: [__Type!]
|
||||
possibleTypes: [__Type!]
|
||||
enumValues(includeDeprecated: Boolean = false): [__EnumValue!]
|
||||
inputFields: [__InputValue!]
|
||||
ofType: __Type
|
||||
}
|
||||
|
||||
# An enum describing what kind of type a given `__Type` is.
|
||||
|
Loading…
Reference in New Issue
Block a user