Skip to content

Commit

Permalink
Use noLocation to reduce document size
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Jun 21, 2020
1 parent f6f616d commit 76914a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/import/src/index.ts
Expand Up @@ -102,7 +102,9 @@ function visitFile(
const fileDefinitionMap = new Map<string, Set<DefinitionNode>>();
// 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';
Expand Down
4 changes: 4 additions & 0 deletions packages/relay-operation-optimizer/src/index.ts
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/webpack-loader/src/index.ts
Expand Up @@ -9,6 +9,7 @@ export default function (this: any, path: string) {

loadTypedefs(path, {
loaders: [new GraphQLFileLoader()],
noLocation: true,
}).then(sources => {
const documentStrs = sources.map(source => source.rawSDL).join('\n');
const mergedDoc = parse(documentStrs, { noLocation: true });
Expand Down

0 comments on commit 76914a4

Please sign in to comment.