diff --git a/.babelrc.js b/.babelrc.js index 387d74220c..209874aab7 100644 --- a/.babelrc.js +++ b/.babelrc.js @@ -12,7 +12,6 @@ module.exports = { }]], "plugins": [ "./resources/inline-invariant", - "@babel/plugin-proposal-class-properties", "@babel/plugin-transform-flow-strip-types", ["@babel/plugin-transform-classes", {"loose": true}], ["@babel/plugin-transform-destructuring", {"loose": true}], diff --git a/package.json b/package.json index b60378c6b6..93e0de2ba0 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,6 @@ "devDependencies": { "@babel/cli": "7.2.0", "@babel/core": "7.2.2", - "@babel/plugin-proposal-class-properties": "7.2.1", "@babel/plugin-transform-flow-strip-types": "7.2.0", "@babel/polyfill": "7.0.0", "@babel/preset-env": "7.2.0", diff --git a/src/type/schema.js b/src/type/schema.js index 439a6a5543..9f55442e63 100644 --- a/src/type/schema.js +++ b/src/type/schema.js @@ -93,7 +93,7 @@ export class GraphQLSchema { _directives: $ReadOnlyArray; _typeMap: TypeMap; _implementations: ObjMap>; - _possibleTypeMap: ?ObjMap>; + _possibleTypeMap: ObjMap>; // Used as a cache for validateSchema(). __validationErrors: ?$ReadOnlyArray; // Referenced by validateSchema(). @@ -105,6 +105,8 @@ export class GraphQLSchema { if (config && config.assumeValid) { this.__validationErrors = []; } else { + this.__validationErrors = undefined; + // Otherwise check for common mistakes during construction to produce // clear and early error messages. invariant( @@ -161,6 +163,8 @@ export class GraphQLSchema { // Storing the resulting map for reference by the schema. this._typeMap = typeMap; + this._possibleTypeMap = Object.create(null); + // Keep track of all implementations by interface name. this._implementations = Object.create(null); for (const typeName of Object.keys(this._typeMap)) { @@ -215,10 +219,7 @@ export class GraphQLSchema { abstractType: GraphQLAbstractType, possibleType: GraphQLObjectType, ): boolean { - let possibleTypeMap = this._possibleTypeMap; - if (!possibleTypeMap) { - this._possibleTypeMap = possibleTypeMap = Object.create(null); - } + const possibleTypeMap = this._possibleTypeMap; if (!possibleTypeMap[abstractType.name]) { const possibleTypes = this.getPossibleTypes(abstractType); diff --git a/src/validation/ValidationContext.js b/src/validation/ValidationContext.js index e6c924c124..170cb36787 100644 --- a/src/validation/ValidationContext.js +++ b/src/validation/ValidationContext.js @@ -46,7 +46,7 @@ type VariableUsage = {| export class ASTValidationContext { _ast: DocumentNode; _errors: Array; - _fragments: ObjMap; + _fragments: ?ObjMap; _fragmentSpreads: Map>; _recursivelyReferencedFragments: Map< OperationDefinitionNode, @@ -56,6 +56,7 @@ export class ASTValidationContext { constructor(ast: DocumentNode): void { this._ast = ast; this._errors = []; + this._fragments = undefined; this._fragmentSpreads = new Map(); this._recursivelyReferencedFragments = new Map(); } diff --git a/yarn.lock b/yarn.lock index 9b6229e1d3..0ccd48e364 100644 --- a/yarn.lock +++ b/yarn.lock @@ -81,17 +81,6 @@ "@babel/traverse" "^7.1.0" "@babel/types" "^7.0.0" -"@babel/helper-create-class-features-plugin@^7.2.1": - version "7.2.2" - resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.2.2.tgz#aac79552e41c94716a804d371e943f20171df0c5" - integrity sha512-Q4qZE5wS3NWpOS6UV9yhIS/NmSyf2keF0E0IwDvx8WxTheVopVIY6BSQ/0vz72OTTruz0cOA2yIUh6Kdg3qprA== - dependencies: - "@babel/helper-function-name" "^7.1.0" - "@babel/helper-member-expression-to-functions" "^7.0.0" - "@babel/helper-optimise-call-expression" "^7.0.0" - "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-replace-supers" "^7.1.0" - "@babel/helper-define-map@^7.1.0": version "7.1.0" resolved "https://registry.yarnpkg.com/@babel/helper-define-map/-/helper-define-map-7.1.0.tgz#3b74caec329b3c80c116290887c0dd9ae468c20c" @@ -255,14 +244,6 @@ "@babel/helper-remap-async-to-generator" "^7.1.0" "@babel/plugin-syntax-async-generators" "^7.2.0" -"@babel/plugin-proposal-class-properties@7.2.1": - version "7.2.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.2.1.tgz#c734a53e0a1ec40fe5c22ee5069d26da3b187d05" - integrity sha512-/4FKFChkQ2Jgb8lBDsvFX496YTi7UWTetVgS8oJUpX1e/DlaoeEK57At27ug8Hu2zI2g8bzkJ+8k9qrHZRPGPA== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.2.1" - "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-proposal-json-strings@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.2.0.tgz#568ecc446c6148ae6b267f02551130891e29f317"