rishabh3112 / graphql-tag-swc-plugin

SWC plugin to expand gql template literal during build itself
https://www.npmjs.com/package/graphql-tag-swc-plugin
MIT License
15 stars 3 forks source link

Add Checks for Operation Definition in GraphQL Query #18

Closed desout closed 3 months ago

desout commented 4 months ago

This PR addresses missing checks for operation definitions in GraphQL queries.

Changes include:

  1. Added condition to check if definition name is present then insert it into the props vector.
  2. For cases where no operation type is provided, it defaults to "query".
  3. Added logic to create all_definitions vector, and a check for presence of more than one definition. In case where a name is absent for any of these definitions, an appropriate error is thrown.

Lay the groundwork for further validation checks in GraphQL query processing based on the behavior of 'gajus/babel-plugin-graphql-tag' project.

While extensive testing has been done locally, it has not been fully covered by automated tests due to Rust experience constraints. Specifically, error/panic scenarios demand more test coverage.

This effort has mimicked necessary logic from an existing solution found at https://github.com/gajus/babel-plugin-graphql-tag/blob/master/test/fixtures/graphql-tag. The current changes seek to ensure similar, comprehensive validation checks in Rust implementation.

21

desout commented 4 months ago

@rishabh3112 Hello, could you, please, take a look on this changes?

rishabh3112 commented 3 months ago

@desout Thanks for PR! Left few comments.

desout commented 3 months ago

@rishabh3112 Hello, Where i can check your comments? :)

desout commented 3 months ago

@rishabh3112 Please review

rishabh3112 commented 3 months ago

@desout will check and merge this weekend, thanks for contributions! Also, can you please change commits by using same email address as you have with github account? (for clearer commit history)

desout commented 3 months ago

@rishabh3112 Updated commits with proper email