-
Notifications
You must be signed in to change notification settings - Fork 109
enhance(eslint-plugin): refactor the parts using tools #564
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
Conversation
🦋 Changeset detectedLatest commit: 5af1025 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
The latest changes of this PR are available as alpha in npm (based on the declared |
| return null; | ||
| } | ||
|
|
||
| if (schemaCache.has(schemaKey)) { |
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.
Using get once will be better for performance
| if (!siblings) { | ||
| const documents = projectForFile.loadDocumentsSync(projectForFile.documents, { | ||
| skipGraphQLImport: true, | ||
| cache: loaderCache |
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.
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); |
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.
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 |
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.
printSchemaWithDirectives also uses this function and no need to do print and parse again.
3bcc1a7 to
5af1025
Compare
This PR also adds
loaderCachethat removes the need ofschemaCacheandoperationsCachebut I didn't remove it in this PR because it seems to need more changes than removing them.