tailcallhq / tailcall

High Performance GraphQL Runtime
https://tailcall.run
Apache License 2.0
1.18k stars 209 forks source link

Validate schema using linters #1322

Open tusharmath opened 3 months ago

tusharmath commented 3 months ago

Tailcall should ensure consistency in building the final GraphQL schema. This is the standard it should follow:

Case styles

There are two approaches to solve this problem:

  1. When the setting is enabled, we can throw a validation error that the developer see and fix using the @modify operator.
  2. We can automatically fix it for the user.

Proposal

schema @server(lint: {field: true, type: true, enum: true, enumValue: true, autoFix: false}) {
  query: Query
}

Technical Requirements Use the ConfigOptimizer API defined over here https://github.com/tailcallhq/tailcall/issues/1653

tusharmath commented 3 months ago

/bounty 300$

algora-pbc[bot] commented 3 months ago

💎 $300 bounty • Tailcall Inc.

Steps to solve:

  1. Start working: Comment /attempt #1322 with your implementation plan
  2. Submit work: Create a pull request including /claim #1322 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

🙏 Thank you for contributing to tailcallhq/tailcall! 🧐 Checkout our guidelines before you get started. 💵 More about our bounty program.

Attempt Started (GMT+0) Solution
🟡 @webbdays Mar 30, 2024, 12:25:13 PM WIP
🔴 @varshith257 Apr 25, 2024, 7:53:27 PM WIP
🔴 @Shylock-Hg May 29, 2024, 10:58:04 AM WIP
ssddOnTop commented 3 months ago

I'll like to give it a try

webbdays commented 3 months ago

Please let me know the place where we parse the file and get final representation of the file for all .graphql, .yml,.json files. When the start command is executed. Thank you.

tusharmath commented 3 months ago

@webbdays check the blueprint module. All the validations are done there. Create a new file called lint.rs which performs these validations.

webbdays commented 3 months ago

Oh OK. I didn't properly understand the project structure.

I have directly used config struct. I think blueprint get info from config struct right.

Created a linter. Working fine. Pushing code changes now. Please look at it once to find any issues. Thank you.

webbdays commented 3 months ago

@ssddOnTop Are you still working on this?

ssddOnTop commented 3 months ago

@ssddOnTop Are you still working on this?

Yessir

webbdays commented 3 months ago

ok

ssddOnTop commented 3 months ago

I am dropping this off as of now

webbdays commented 3 months ago

@ssddOnTop What is your progress on this until now and what are pending things to work?

webbdays commented 3 months ago

I will try to finish what i have started before. /attempt

ssddOnTop commented 3 months ago

@ssddOnTop What is your progress on this until now and what are pending things to work?

Almost everything is pending.. I didn't get much time to focus on this issue. You can check #1329

algora-pbc[bot] commented 3 months ago

@webbdays: Reminder that in 1 days the bounty will become up for grabs, so please submit a pull request before then 🙏

varshith257 commented 2 months ago

/attempt #1322

algora-pbc[bot] commented 2 months ago

[!NOTE] The user @webbdays is already attempting to complete issue #1322 and claim the bounty. We recommend checking in on @webbdays's progress, and potentially collaborating, before starting a new solution.

varshith257 commented 2 months ago

@tusharmath If I am right, we need strict linting. Approach 1 seems good to me. What are your thoughts on this?

webbdays commented 2 months ago

@varshith257 the first part is almost done. I am having problem with auto fixing the lint issues. So, i am looking at different approaches to it. You are welcomed to build on the work i have done in the PR #1671 #1795.

webbdays commented 2 months ago

Here is the code for different way i am trying; in the pr #1795

webbdays commented 2 months ago

There are many cases we have to handle when auto fixing. Because, some of the things like type or the field or the enum can be used in other parts of graphql schema. which we need to correct based of lint requirements. Which we cannot predict some times.

webbdays commented 2 months ago

There is this tool for graphql lint checker: https://github.com/cjoudrey/graphql-schema-linter User can use this while developing graphql schema. or we can compile it to web assembly and run with wasm runtime. Also giving the user the cli option to lint. But i think this is overhead to tailcall cli.

varshith257 commented 2 months ago

Are you going with approach 2? I will give a try with approach 1. Approach 1 seems good for LTS

webbdays commented 2 months ago

Hi, @varshith257, seems confused with approach word. I have already done it. (except that i have warned.) we can throw validation error. Only problem is with autofixing.

1795 is different way of doing it so that it might be easy for autofixing the schema.

algora-pbc[bot] commented 2 months ago

@varshith257: Reminder that in 1 days the bounty will become up for grabs, so please submit a pull request before then 🙏

varshith257 commented 2 months ago

@algora-pbc Someone is working there. Wouldn't it get conflict?

webbdays commented 2 months ago

@varshith257 You can make a pr. I am out of ideas.

Shylock-Hg commented 1 month ago

/attempt To resolve the problem of referencing identifiers, I plan to introduce an intermediate representation of identifier (maybe a unique number). So, we change the name of identifier and don't modify the original unique number. @tusharmath How do you think about it?

Algora profile Completed bounties Tech Active attempts Options
@Shylock-Hg    7 tailcallhq bounties
+ 3 bounties from 3 projects
C++, C,
Shell & more
Cancel attempt
algora-pbc[bot] commented 1 month ago

[!NOTE] The user @webbdays is already attempting to complete issue #1322 and claim the bounty. We recommend checking in on @webbdays's progress, and potentially collaborating, before starting a new solution.

tusharmath commented 1 month ago

Sounds good. You need a stable identifier.

algora-pbc[bot] commented 1 month ago

@Shylock-Hg: Reminder that in 1 days the bounty will become up for grabs, so please submit a pull request before then 🙏

menkotoglou commented 2 weeks ago

Hey @tusharmath, is this still up?

tusharmath commented 2 weeks ago

Yes. Check out the transformer modules for inspiration

menkotoglou commented 2 weeks ago

Good to know. Thank you @tusharmath, I'll give it a try next week that I'll be having more time :)