Skip to content

Conversation

@dimaMachina
Copy link
Contributor

@dimaMachina dimaMachina commented Dec 5, 2021

UPDATE: I removed all unrelated changes to this PR to make review simple

  • refactor: generate .json configs instead .ts
  • fix some broken links in docs
  • use valueFromASTUntyped from graphql-js
  • don't export functions from ./estree-parser, but export requireGraphQLSchemaFromContext and requireSiblingsOperations

@changeset-bot
Copy link

changeset-bot bot commented Dec 5, 2021

⚠️ No Changeset found

Latest commit: 875e67c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@theguild-bot
Copy link
Collaborator

theguild-bot commented Dec 5, 2021

The latest changes of this PR are not available as alpha, since there are no linked changesets for this PR.

? SafeGraphQLType<T> &
Pick<BaseNode, 'leadingComments' | 'loc' | 'range'> & {
type: T['kind'];
gqlLocation: Location;
Copy link
Contributor Author

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'>

Copy link
Contributor Author

@dimaMachina dimaMachina Dec 17, 2021

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

@dimaMachina dimaMachina marked this pull request as ready for review December 5, 2021 19:48
@dimaMachina dimaMachina marked this pull request as draft December 5, 2021 21:31
@dimaMachina dimaMachina changed the title refactor: simplify AST converter refactor: simplify AST converter, generate .json configs instead .ts Dec 6, 2021
@dimaMachina dimaMachina force-pushed the refactor-ast-converter branch from 35885f4 to 07b34cb Compare December 17, 2021 12:15
export const rule = {
create(context) {
requireGraphQLSchemaFromContext(context)
requireGraphQLSchemaFromContext('your-rule-name', context)
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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)
Copy link
Contributor Author

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).
Copy link
Contributor Author

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 {
Copy link
Contributor Author

@dimaMachina dimaMachina Dec 17, 2021

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

@dimaMachina dimaMachina marked this pull request as ready for review December 17, 2021 12:22
rules: getRulesConfig('Schema', true),
});

writeFormattedFile('configs/operations-recommended.json', {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the main purpose of this is to have configs in separate places instead of having them in index.js file.
So this will be easy to look up for debugging purposes.
image


- 🚀 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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

replaced with non-breaking space, so on mobile, this must look better

before

image

after

image

}, Object.create(null));
}

export function valueFromNode(valueNode: GraphQLESTreeNode<ValueNode>, variables?: Record<string, any>): any {
Copy link
Contributor Author

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

@dimaMachina dimaMachina force-pushed the refactor-ast-converter branch from 07b34cb to 7e3c4dd Compare January 2, 2022 15:28
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`
@dimaMachina dimaMachina force-pushed the refactor-ast-converter branch from 7e3c4dd to 875e67c Compare February 1, 2022 14:21
@dimaMachina dimaMachina merged commit b86425f into master Feb 16, 2022
@dimaMachina dimaMachina deleted the refactor-ast-converter branch February 16, 2022 21:54
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.

2 participants