Skip to content

Commit

Permalink
Fix rearranged schema printing (#920)
Browse files Browse the repository at this point in the history
* Revert "Sort fields before printing to get a more stable diff"

This reverts commit 3d8faca.

* Revert "update tests"

This reverts commit e0fb703.
  • Loading branch information
leebyron authored Jun 20, 2017
1 parent 6a85e88 commit ff4338d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 77 deletions.
31 changes: 16 additions & 15 deletions src/utilities/__tests__/buildASTSchema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ describe('Schema Builder', () => {
}
type HelloScalars {
bool: Boolean
str: String
int: Int
float: Float
id: ID
int: Int
str: String
bool: Boolean
}
`;
`;

const output = cycleOutput(body);
expect(output).to.equal(body);
});
Expand Down Expand Up @@ -197,11 +198,11 @@ describe('Schema Builder', () => {
}
type HelloScalars {
listOfNonNullStrs: [String!]
nonNullStr: String!
listOfStrs: [String]
nonNullListOfNonNullStrs: [String!]!
listOfNonNullStrs: [String!]
nonNullListOfStrs: [String]!
nonNullStr: String!
nonNullListOfNonNullStrs: [String!]!
}
`;
const output = cycleOutput(body);
Expand All @@ -216,8 +217,8 @@ describe('Schema Builder', () => {
}
type Recurse {
recurse: Recurse
str: String
recurse: Recurse
}
`;
const output = cycleOutput(body);
Expand Down Expand Up @@ -251,10 +252,10 @@ describe('Schema Builder', () => {
}
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
}
`;
Expand Down Expand Up @@ -451,9 +452,9 @@ describe('Schema Builder', () => {
}
type HelloScalars {
bool: Boolean
int: Int
str: String
int: Int
bool: Boolean
}
type Mutation {
Expand All @@ -472,9 +473,9 @@ describe('Schema Builder', () => {
}
type HelloScalars {
bool: Boolean
int: Int
str: String
int: Int
bool: Boolean
}
type Subscription {
Expand Down Expand Up @@ -528,9 +529,9 @@ describe('Schema Builder', () => {
}
type Query {
enum: MyEnum
field1: String @deprecated
field2: Int @deprecated(reason: "Because I said so")
enum: MyEnum
}
`;
const output = cycleOutput(body);
Expand Down
58 changes: 29 additions & 29 deletions src/utilities/__tests__/extendSchema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ describe('extendSchema', () => {
expect(printSchema(testSchema)).to.equal(originalPrint);
expect(printSchema(extendedSchema)).to.equal(dedent`
type Bar implements SomeInterface {
foo: Foo
name: String
some: SomeInterface
foo: Foo
}
type Biz {
Expand All @@ -170,16 +170,16 @@ describe('extendSchema', () => {
type Foo implements SomeInterface {
name: String
newField: String
some: SomeInterface
tree: [Foo]!
newField: String
}
type Query {
foo: Foo
someUnion: SomeUnion
someEnum: SomeEnum
someInterface(id: ID!): SomeInterface
someUnion: SomeUnion
}
enum SomeEnum {
Expand Down Expand Up @@ -252,9 +252,9 @@ describe('extendSchema', () => {
expect(printSchema(testSchema)).to.equal(originalPrint);
expect(printSchema(extendedSchema)).to.equal(dedent`
type Bar implements SomeInterface {
foo: Foo
name: String
some: SomeInterface
foo: Foo
}
type Biz {
Expand All @@ -269,9 +269,9 @@ describe('extendSchema', () => {
type Query {
foo: Foo
someUnion: SomeUnion
someEnum: SomeEnum
someInterface(id: ID!): SomeInterface
someUnion: SomeUnion
}
enum SomeEnum {
Expand Down Expand Up @@ -310,9 +310,9 @@ describe('extendSchema', () => {
expect(printSchema(testSchema)).to.equal(originalPrint);
expect(printSchema(extendedSchema)).to.equal(dedent`
type Bar implements SomeInterface {
foo: Foo
name: String
some: SomeInterface
foo: Foo
}
type Biz {
Expand All @@ -321,9 +321,9 @@ describe('extendSchema', () => {
type Foo implements SomeInterface {
name: String
newField(arg1: String, arg2: NewInputObj!): String
some: SomeInterface
tree: [Foo]!
newField(arg1: String, arg2: NewInputObj!): String
}
input NewInputObj {
Expand All @@ -334,9 +334,9 @@ describe('extendSchema', () => {
type Query {
foo: Foo
someUnion: SomeUnion
someEnum: SomeEnum
someInterface(id: ID!): SomeInterface
someUnion: SomeUnion
}
enum SomeEnum {
Expand Down Expand Up @@ -365,9 +365,9 @@ describe('extendSchema', () => {
expect(printSchema(testSchema)).to.equal(originalPrint);
expect(printSchema(extendedSchema)).to.equal(dedent`
type Bar implements SomeInterface {
foo: Foo
name: String
some: SomeInterface
foo: Foo
}
type Biz {
Expand All @@ -376,16 +376,16 @@ describe('extendSchema', () => {
type Foo implements SomeInterface {
name: String
newField(arg1: SomeEnum!): SomeEnum
some: SomeInterface
tree: [Foo]!
newField(arg1: SomeEnum!): SomeEnum
}
type Query {
foo: Foo
someUnion: SomeUnion
someEnum: SomeEnum
someInterface(id: ID!): SomeInterface
someUnion: SomeUnion
}
enum SomeEnum {
Expand Down Expand Up @@ -415,9 +415,9 @@ describe('extendSchema', () => {
expect(printSchema(testSchema)).to.equal(originalPrint);
expect(printSchema(extendedSchema)).to.equal(dedent`
type Bar implements SomeInterface {
foo: Foo
name: String
some: SomeInterface
foo: Foo
}
type Biz implements SomeInterface {
Expand All @@ -434,9 +434,9 @@ describe('extendSchema', () => {
type Query {
foo: Foo
someUnion: SomeUnion
someEnum: SomeEnum
someInterface(id: ID!): SomeInterface
someUnion: SomeUnion
}
enum SomeEnum {
Expand Down Expand Up @@ -491,9 +491,9 @@ describe('extendSchema', () => {
expect(printSchema(testSchema)).to.equal(originalPrint);
expect(printSchema(extendedSchema)).to.equal(dedent`
type Bar implements SomeInterface {
foo: Foo
name: String
some: SomeInterface
foo: Foo
}
type Biz {
Expand All @@ -502,14 +502,14 @@ describe('extendSchema', () => {
type Foo implements SomeInterface {
name: String
newEnum: NewEnum
newInterface: NewInterface
some: SomeInterface
tree: [Foo]!
newObject: NewObject
newInterface: NewInterface
newUnion: NewUnion
newScalar: NewScalar
newEnum: NewEnum
newTree: [Foo]!
newUnion: NewUnion
some: SomeInterface
tree: [Foo]!
}
enum NewEnum {
Expand All @@ -535,9 +535,9 @@ describe('extendSchema', () => {
type Query {
foo: Foo
someUnion: SomeUnion
someEnum: SomeEnum
someInterface(id: ID!): SomeInterface
someUnion: SomeUnion
}
enum SomeEnum {
Expand Down Expand Up @@ -570,20 +570,20 @@ describe('extendSchema', () => {
expect(printSchema(testSchema)).to.equal(originalPrint);
expect(printSchema(extendedSchema)).to.equal(dedent`
type Bar implements SomeInterface {
foo: Foo
name: String
some: SomeInterface
foo: Foo
}
type Biz {
fizz: String
}
type Foo implements SomeInterface, NewInterface {
baz: String
name: String
some: SomeInterface
tree: [Foo]!
baz: String
}
interface NewInterface {
Expand All @@ -592,9 +592,9 @@ describe('extendSchema', () => {
type Query {
foo: Foo
someUnion: SomeUnion
someEnum: SomeEnum
someInterface(id: ID!): SomeInterface
someUnion: SomeUnion
}
enum SomeEnum {
Expand Down Expand Up @@ -638,18 +638,18 @@ describe('extendSchema', () => {
expect(printSchema(testSchema)).to.equal(originalPrint);
expect(printSchema(extendedSchema)).to.equal(dedent`
type Bar implements SomeInterface {
foo: Foo
name: String
some: SomeInterface
foo: Foo
}
type Biz implements NewInterface, SomeInterface {
buzz: String
fizz: String
buzz: String
name: String
some: SomeInterface
newFieldA: Int
newFieldB: Float
some: SomeInterface
}
type Foo implements SomeInterface {
Expand All @@ -664,9 +664,9 @@ describe('extendSchema', () => {
type Query {
foo: Foo
someUnion: SomeUnion
someEnum: SomeEnum
someInterface(id: ID!): SomeInterface
someUnion: SomeUnion
}
enum SomeEnum {
Expand Down Expand Up @@ -729,13 +729,13 @@ describe('extendSchema', () => {
}
type Query {
newQueryField: Int
queryField: String
newQueryField: Int
}
type Subscription {
newSubscriptionField: Int
subscriptionField: String
newSubscriptionField: Int
}
`);
});
Expand Down
Loading

0 comments on commit ff4338d

Please sign in to comment.