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

schemaPrinter: preserve order of types #2411

Merged
merged 1 commit into from
Jan 29, 2020
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
10 changes: 5 additions & 5 deletions src/type/__tests__/schema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ describe('Type System: Schema', () => {
});

expect(printSchema(schema)).to.equal(dedent`
type Query {
article(id: String): Article
feed: [Article]
}

type Article {
id: String
isPublished: Boolean
Expand All @@ -117,11 +122,6 @@ describe('Type System: Schema', () => {
writeArticle: Article
}

type Query {
article(id: String): Article
feed: [Article]
}

type Subscription {
articleSubscribe(id: String): Article
}
Expand Down
60 changes: 30 additions & 30 deletions src/utilities/__tests__/extendSchema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,15 +666,15 @@ describe('extendSchema', () => {

expect(validateSchema(extendedSchema)).to.deep.equal([]);
expect(printSchemaChanges(schema, extendedSchema)).to.equal(dedent`
type SomeObject {
newField(arg1: String, arg2: NewInputObj!): String
}

input NewInputObj {
field1: Int
field2: [Float]
field3: String!
}

type SomeObject {
newField(arg1: String, arg2: NewInputObj!): String
}
`);
});

Expand Down Expand Up @@ -754,8 +754,7 @@ describe('extendSchema', () => {

scalar NewScalar

union NewUnion = NewObject
`;
union NewUnion = NewObject`;
const extendAST = parse(`
${newTypesSDL}
extend type SomeObject {
Expand All @@ -771,7 +770,6 @@ describe('extendSchema', () => {

expect(validateSchema(extendedSchema)).to.deep.equal([]);
expect(printSchemaChanges(schema, extendedSchema)).to.equal(dedent`
${newTypesSDL}
type SomeObject {
oldField: String
newObject: NewObject
Expand All @@ -781,6 +779,8 @@ describe('extendSchema', () => {
newEnum: NewEnum
newTree: [SomeObject]!
}

${newTypesSDL}
`);
});

Expand Down Expand Up @@ -811,12 +811,12 @@ describe('extendSchema', () => {

expect(validateSchema(extendedSchema)).to.deep.equal([]);
expect(printSchemaChanges(schema, extendedSchema)).to.equal(dedent`
interface NewInterface {
type SomeObject implements OldInterface & NewInterface {
oldField: String
newField: String
}

type SomeObject implements OldInterface & NewInterface {
oldField: String
interface NewInterface {
newField: String
}
`);
Expand Down Expand Up @@ -864,8 +864,7 @@ describe('extendSchema', () => {

type NewObject {
foo: String
}
`;
}`;
const extendAST = parse(`
${newTypesSDL}
extend type SomeObject implements NewInterface {
Expand Down Expand Up @@ -900,26 +899,27 @@ describe('extendSchema', () => {

expect(validateSchema(extendedSchema)).to.deep.equal([]);
expect(printSchemaChanges(schema, extendedSchema)).to.equal(dedent`
${newTypesSDL}
type SomeObject implements SomeInterface & NewInterface & AnotherNewInterface {
oldField: String
newField: String
anotherNewField: String
}

enum SomeEnum {
OLD_VALUE
NEW_VALUE
ANOTHER_NEW_VALUE
}

input SomeInput {
oldField: String
newField: String
anotherNewField: String
}
union SomeUnion = SomeObject | NewObject | AnotherNewObject

type SomeObject implements SomeInterface & NewInterface & AnotherNewInterface {
input SomeInput {
oldField: String
newField: String
anotherNewField: String
}

union SomeUnion = SomeObject | NewObject | AnotherNewObject
${newTypesSDL}
`);
});

Expand Down Expand Up @@ -958,12 +958,12 @@ describe('extendSchema', () => {

expect(validateSchema(extendedSchema)).to.deep.equal([]);
expect(printSchemaChanges(schema, extendedSchema)).to.equal(dedent`
interface AnotherInterface implements SomeInterface {
interface SomeInterface {
oldField: String
newField: String
}

interface SomeInterface {
interface AnotherInterface implements SomeInterface {
oldField: String
newField: String
}
Expand Down Expand Up @@ -1015,12 +1015,12 @@ describe('extendSchema', () => {
newField: String
}

interface NewInterface {
type SomeObject implements SomeInterface & AnotherInterface & NewInterface {
oldField: String
newField: String
}

type SomeObject implements SomeInterface & AnotherInterface & NewInterface {
oldField: String
interface NewInterface {
newField: String
}
`);
Expand Down Expand Up @@ -1120,16 +1120,16 @@ describe('extendSchema', () => {
expect(extendedSchema).to.not.equal(mutationSchema);
expect(printSchema(mutationSchema)).to.equal(originalPrint);
expect(printSchema(extendedSchema)).to.equal(dedent`
type Mutation {
mutationField: String
newMutationField: Int
}

type Query {
queryField: String
newQueryField: Int
}

type Mutation {
mutationField: String
newMutationField: Int
}

type Subscription {
subscriptionField: String
newSubscriptionField: Int
Expand Down
Loading