-
Notifications
You must be signed in to change notification settings - Fork 109
refactor: simplify AST converter, generate .json configs instead .ts
#822
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
|
|
The latest changes of this PR are not available as alpha, since there are no linked |
| ? SafeGraphQLType<T> & | ||
| Pick<BaseNode, 'leadingComments' | 'loc' | 'range'> & { | ||
| type: T['kind']; | ||
| gqlLocation: Location; |
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 is typo, must be Pick<Location, 'start' | 'end'>
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.
Update: I removed this field because is unused in graphql-eslint, also this info can be retrieved with range field
.json configs instead .ts
35885f4 to
07b34cb
Compare
| export const rule = { | ||
| create(context) { | ||
| requireGraphQLSchemaFromContext(context) | ||
| requireGraphQLSchemaFromContext('your-rule-name', context) |
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.
typo
| const typeInfo = node.typeInfo() | ||
|
|
||
| if (typeInfo && typeInfo.gqlType) { | ||
| if (typeInfo.gqlType) { |
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.
typeInfo is always truthy
| With this configuration, you can specify custom configurations for GraphQL's `parse` method. By default, `graphql-eslint` parser just adds `noLocation: false` to make sure all parsed AST has `location` set, since we need this for tokenizing and for converting the GraphQL AST into ESTree. | ||
|
|
||
| You can find the [complete set of options for this object here](https://github.com/graphql/graphql-js/blob/master/src/language/parser.d.ts#L7) | ||
| You can find the [complete set of options for this object here](https://github.com/graphql/graphql-js/blob/6e48d16f92b9a6df8638b1486354c6be2537033b/src/language/parser.ts#L73) |
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.
fixed broken link with permanent link
| ``` | ||
|
|
||
| > The configuration here is flexible, and will be sent to `graphql-tools` and it's loaders. So depends on the schema source, the options may vary. [You can read more about these loaders and their configuration here](https://www.graphql-tools.com/docs/api/interfaces/_loaders_graphql_file_src_index_.graphqlfileloaderoptions). | ||
| > The configuration here is flexible, and will be sent to `graphql-tools` and it's loaders. So depends on the schema source, the options may vary. [You can read more about these loaders and their configuration here](https://graphql-tools.com/docs/api/interfaces/loaders_graphql_file_src.GraphQLFileLoaderOptions#properties). |
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.
fixed broken link
| Object { | ||
| description: Object { | ||
| block: true, | ||
| gqlLocation: Object { |
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.
I don't see a reason to have gqlLocation field, currently is unused, also this info can be retrieved with range field
| rules: getRulesConfig('Schema', true), | ||
| }); | ||
|
|
||
| writeFormattedFile('configs/operations-recommended.json', { |
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.
|
|
||
| - 🚀 Integrates with ESLint core (as a ESTree parser) | ||
| - 🚀 Works on `.graphql` files, `gql` usages and `/* GraphQL */` magic comments | ||
| - 🚀 Works on `.graphql` files, `gql` usages and `/* GraphQL */` magic comments |
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.
| }, Object.create(null)); | ||
| } | ||
|
|
||
| export function valueFromNode(valueNode: GraphQLESTreeNode<ValueNode>, variables?: Record<string, any>): any { |
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.
use valueFromASTUntyped instead of copy this fn
07b34cb to
7e3c4dd
Compare
refactor: generate .json configs instead typescript fix links use `valueFromASTUntyped` from graphql-js don't export functions from `./estree-parser`, but export `requireGraphQLSchemaFromContext` and `requireSiblingsOperations`
7e3c4dd to
875e67c
Compare



UPDATE: I removed all unrelated changes to this PR to make review simple
.json configsinstead.tsvalueFromASTUntypedfromgraphql-js./estree-parser, but exportrequireGraphQLSchemaFromContextandrequireSiblingsOperations