diff --git a/packages/import/src/index.ts b/packages/import/src/index.ts index bcf814c3dd4..fbfc6e5693a 100644 --- a/packages/import/src/index.ts +++ b/packages/import/src/index.ts @@ -102,7 +102,9 @@ function visitFile( const fileDefinitionMap = new Map>(); // To prevent circular dependency visitedFiles.set(filePath, fileDefinitionMap); - const document = parse(new Source(otherLines, filePath)); + const document = parse(new Source(otherLines, filePath), { + noLocation: true, + }); for (const definition of document.definitions) { if ('name' in definition || definition.kind === Kind.SCHEMA_DEFINITION) { const definitionName = 'name' in definition ? definition.name.value : 'schema'; diff --git a/packages/relay-operation-optimizer/src/index.ts b/packages/relay-operation-optimizer/src/index.ts index e99a802b93a..58db1d75253 100644 --- a/packages/relay-operation-optimizer/src/index.ts +++ b/packages/relay-operation-optimizer/src/index.ts @@ -20,6 +20,10 @@ export function optimizeDocuments( documents: DocumentNode[], options: OptimizeDocumentsOptions = {} ) { + options = { + noLocation: true, + ...options, + }; // @TODO way for users to define directives they use, otherwise relay will throw an unknown directive error // Maybe we can scan the queries and add them dynamically without users having to do some extra stuff // transformASTSchema creates a new schema instance instead of mutating the old one diff --git a/packages/webpack-loader/package.json b/packages/webpack-loader/package.json index 95df3fee369..6b718f3c891 100644 --- a/packages/webpack-loader/package.json +++ b/packages/webpack-loader/package.json @@ -20,10 +20,14 @@ "dependencies": { "@graphql-tools/load": "6.0.10", "@graphql-tools/graphql-file-loader": "6.0.10", + "loader-utils": "2.0.0", "tslib": "~2.0.0" }, + "devDependencies": { + "@types/loader-utils": "1.1.3" + }, "publishConfig": { "access": "public", "directory": "dist" } -} \ No newline at end of file +} diff --git a/packages/webpack-loader/src/index.ts b/packages/webpack-loader/src/index.ts index 5a45b9025d7..a7cd003264f 100644 --- a/packages/webpack-loader/src/index.ts +++ b/packages/webpack-loader/src/index.ts @@ -1,17 +1,22 @@ import { loadTypedefs } from '@graphql-tools/load'; import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader'; import { concatAST } from 'graphql'; +import { getOptions } from 'loader-utils'; export default function (this: any, path: string) { const callback = this.async(); this.cacheable(); + const options = getOptions(this); + loadTypedefs(path, { loaders: [new GraphQLFileLoader()], + noLocation: true, + ...options, }).then(sources => { const documents = sources.map(source => source.document); const mergedDoc = concatAST(documents); - return callback(null, `module.exports = ${JSON.stringify(mergedDoc)}`); + return callback(null, `export default ${JSON.stringify(mergedDoc)}`); }); } diff --git a/yarn.lock b/yarn.lock index 516d56f16d1..ac9f6bda274 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2051,6 +2051,14 @@ "@types/koa-compose" "*" "@types/node" "*" +"@types/loader-utils@1.1.3": + version "1.1.3" + resolved "https://registry.yarnpkg.com/@types/loader-utils/-/loader-utils-1.1.3.tgz#82b9163f2ead596c68a8c03e450fbd6e089df401" + integrity sha512-euKGFr2oCB3ASBwG39CYJMR3N9T0nanVqXdiH7Zu/Nqddt6SmFRxytq/i2w9LQYNQekEtGBz+pE3qG6fQTNvRg== + dependencies: + "@types/node" "*" + "@types/webpack" "*" + "@types/lodash@4.14.156": version "4.14.156" resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.156.tgz#cbe30909c89a1feeb7c60803e785344ea0ec82d1" @@ -2204,6 +2212,18 @@ "@types/source-list-map" "*" source-map "^0.6.1" +"@types/webpack@*": + version "4.41.17" + resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.41.17.tgz#0a69005e644d657c85b7d6ec1c826a71bebd1c93" + integrity sha512-6FfeCidTSHozwKI67gIVQQ5Mp0g4X96c2IXxX75hYEQJwST/i6NyZexP//zzMOBb+wG9jJ7oO8fk9yObP2HWAw== + dependencies: + "@types/anymatch" "*" + "@types/node" "*" + "@types/tapable" "*" + "@types/uglify-js" "*" + "@types/webpack-sources" "*" + source-map "^0.6.0" + "@types/webpack@^4.41.0", "@types/webpack@^4.41.8": version "4.41.13" resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.41.13.tgz#988d114c8913d039b8a0e0502a7fe4f1f84f3d5e" @@ -8236,6 +8256,15 @@ loader-utils@1.2.3: emojis-list "^2.0.0" json5 "^1.0.1" +loader-utils@2.0.0, loader-utils@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0" + integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ== + dependencies: + big.js "^5.2.2" + emojis-list "^3.0.0" + json5 "^2.1.2" + loader-utils@^1.1.0, loader-utils@^1.2.3, loader-utils@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.0.tgz#c579b5e34cb34b1a74edc6c1fb36bfa371d5a613" @@ -8245,15 +8274,6 @@ loader-utils@^1.1.0, loader-utils@^1.2.3, loader-utils@^1.4.0: emojis-list "^3.0.0" json5 "^1.0.1" -loader-utils@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0" - integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ== - dependencies: - big.js "^5.2.2" - emojis-list "^3.0.0" - json5 "^2.1.2" - locate-path@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e"