-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Maintain allowed legacy names when extending a schema. #1226
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,7 @@ const testSchema = new GraphQLSchema({ | |
}), | ||
}), | ||
types: [FooType, BarType], | ||
allowedLegacyNames: ['__badName'], | ||
}); | ||
|
||
describe('extendSchema', () => { | ||
|
@@ -994,6 +995,16 @@ describe('extendSchema', () => { | |
); | ||
}); | ||
|
||
it('maintains configuration of the original schema object', () => { | ||
const ast = parse(` | ||
extend type Query { | ||
__badName: String | ||
} | ||
`); | ||
const schema = extendSchema(testSchema, ast); | ||
expect(schema.__allowedLegacyNames).to.eql(['__badName']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All other tests are using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had tried that, but it looks like chai’s There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you tried There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah no, I tried |
||
}); | ||
|
||
describe('does not allow extending a non-object type', () => { | ||
it('not an interface', () => { | ||
const ast = parse(` | ||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -230,6 +230,8 @@ export function extendSchema( | |||||||
types, | ||||||||
directives: getMergedDirectives(), | ||||||||
astNode: schema.astNode, | ||||||||
allowedLegacyNames: | ||||||||
schema.__allowedLegacyNames && schema.__allowedLegacyNames.slice(0), | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need to use Line 86 in b333b30
So There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is why I needed the equality check, basically. Flow didn’t want to accept a read-only array for the config, which is typed to accept a mutable array: Line 248 in b333b30
I was surprised too, though, so not being very familiar with Flow I’ll do another sanity check. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case, graphql-js/src/language/visitor.js Line 253 in 8bd9fda
|
||||||||
}); | ||||||||
|
||||||||
// Below are functions used for producing this schema that have closed over | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it worth to add this option to common test setup
It's better to define separate minimal schema inside test-case itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that, I just figured that this file was adding all fixture data to this single schema and followed suit. Happy to revisit and create a tiny schema in the test, though 👍