tailcall icon indicating copy to clipboard operation
tailcall copied to clipboard

Validate schema using linters

Open tusharmath opened this issue 11 months ago • 44 comments

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

Case styles

  • Field names should use camelCase.
  • Type names should use PascalCase.
  • Enum names should use PascalCase.
  • Enum values should use ALL_CAPS, because they are similar to constants.

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 avatar Mar 08 '24 08:03 tusharmath

/bounty 300$

tusharmath avatar Mar 08 '24 08:03 tusharmath

💎 $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
🔴 @parth-gr Jul 9, 2024, 7:17:07 PM WIP
🔴 @zeul22 Jul 29, 2024, 3:40:09 PM WIP
🔴 @Sadaf-A Aug 10, 2024, 4:51:14 AM WIP
🟢 @beelchester #2827

algora-pbc[bot] avatar Mar 08 '24 08:03 algora-pbc[bot]

I'll like to give it a try

ssddOnTop avatar Mar 08 '24 08:03 ssddOnTop

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.

webbdays avatar Mar 08 '24 14:03 webbdays

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

tusharmath avatar Mar 09 '24 03:03 tusharmath

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 avatar Mar 09 '24 04:03 webbdays

@ssddOnTop Are you still working on this?

webbdays avatar Mar 10 '24 15:03 webbdays

@ssddOnTop Are you still working on this?

Yessir

ssddOnTop avatar Mar 10 '24 15:03 ssddOnTop

ok

webbdays avatar Mar 10 '24 15:03 webbdays

I am dropping this off as of now

ssddOnTop avatar Mar 30 '24 11:03 ssddOnTop

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

webbdays avatar Mar 30 '24 12:03 webbdays

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

Options

webbdays avatar Mar 30 '24 12:03 webbdays

@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

ssddOnTop avatar Mar 30 '24 12:03 ssddOnTop

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

algora-pbc[bot] avatar Mar 31 '24 12:03 algora-pbc[bot]

/attempt #1322

Options

varshith257 avatar Apr 25 '24 19:04 varshith257

[!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.

algora-pbc[bot] avatar Apr 25 '24 19:04 algora-pbc[bot]

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

varshith257 avatar Apr 25 '24 19:04 varshith257

@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 avatar Apr 26 '24 01:04 webbdays

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

webbdays avatar Apr 26 '24 01:04 webbdays

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 avatar Apr 26 '24 01:04 webbdays

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.

webbdays avatar Apr 26 '24 01:04 webbdays

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

varshith257 avatar Apr 26 '24 02:04 varshith257

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.

webbdays avatar Apr 26 '24 03:04 webbdays

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

algora-pbc[bot] avatar Apr 26 '24 19:04 algora-pbc[bot]

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

varshith257 avatar Apr 27 '24 01:04 varshith257

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

webbdays avatar Apr 27 '24 01:04 webbdays

/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

Shylock-Hg avatar May 29 '24 10:05 Shylock-Hg

[!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.

algora-pbc[bot] avatar May 29 '24 10:05 algora-pbc[bot]

Sounds good. You need a stable identifier.

tusharmath avatar May 29 '24 12:05 tusharmath

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

algora-pbc[bot] avatar May 30 '24 10:05 algora-pbc[bot]