Skip to content

Conversation

@ardatan
Copy link
Member

@ardatan ardatan commented Aug 3, 2021

This PR also adds loaderCache that removes the need of schemaCache and operationsCache but I didn't remove it in this PR because it seems to need more changes than removing them.

@changeset-bot
Copy link

changeset-bot bot commented Aug 3, 2021

🦋 Changeset detected

Latest commit: 5af1025

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphql-eslint/eslint-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@theguild-bot
Copy link
Collaborator

theguild-bot commented Aug 3, 2021

The latest changes of this PR are available as alpha in npm (based on the declared changesets):

@graphql-eslint/[email protected]

return null;
}

if (schemaCache.has(schemaKey)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using get once will be better for performance

if (!siblings) {
const documents = projectForFile.loadDocumentsSync(projectForFile.documents, {
skipGraphQLImport: true,
cache: loaderCache
Copy link
Member Author

@ardatan ardatan Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might improve the performance a bit as well and remove the need of schemaCache and operationsCache

node.operationTypes.forEach(collect);
},
ObjectTypeDefinition(node) {
[node, ...node.interfaces].forEach(collect);
Copy link
Member Author

@ardatan ardatan Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will reduce the number of iterations

const astNode = parse(printedSchema); // Transforms the string into ASTNode
const cache = Object.create(null);

const astNode = getDocumentNodeFromSchema(schema); // Transforms the schema into ASTNode
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

printSchemaWithDirectives also uses this function and no need to do print and parse again.

@ardatan ardatan force-pushed the refactor-graphql-tools-usage branch from 3bcc1a7 to 5af1025 Compare August 9, 2021 21:59
@ardatan ardatan requested review from dimaMachina and dotansimha and removed request for dimaMachina August 9, 2021 22:06
@ardatan ardatan merged commit 403b946 into master Aug 11, 2021
@ardatan ardatan deleted the refactor-graphql-tools-usage branch August 11, 2021 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants