tailcall icon indicating copy to clipboard operation
tailcall copied to clipboard

Add a `@link` operator

Open tusharmath opened this issue 1 year ago • 11 comments
trafficstars

Overview

Introducing the @link operator for linking and importing of external files in configurations.

Proposed GraphQL Schema Definition

schema 
  @link(type: GraphQL, src: "https://abc.com/graphql")
  @link(type: Config, src: "https://abc.com/application.yml")
  @link(type: Config, src: "https://abc.com/application.graphql") {
  query: Query
}

Proposed Update in .tailcallrc.graphql

directive @link(type: LinkType!, src: URL!) repeatable on SCHEMA

Proposed Rust Type Definitions

#[derive(Debug, Clone)]
enum LinkType {
  Config,
  GraphQL,
  Protobuf, //
  Data, // Just pure data that can be used in @const
  // Extendable for more types
}

#[derive(Debug)]
struct Link {  
  type_of: LinkType,  // Type of the link
  src: String,  // Source URL for linked files
  id: Option<String>, // Id is used to refer at different places in the config
  content: Option<String>, // Stores raw content
}
  • Enhanced Debugging and Cloning: Utilizing #[derive(Debug, Clone)] for ease of debugging and cloning capabilities.

ConfigResolver Module

  • Parallel Processing with Error Handling: Employs Rust's async features for parallel HTTP calls. Implements a fail-fast strategy for error handling, leveraging the existing logging framework.

  • Detailed Logging: Each HTTP operation will be logged, including URL access and operation status, using the existing features of the http-client. This is already implemented inside the http-client.

  • Resolve over HTTP & File: Each link can be resolved using both HTTP and Disk IO, so long as we have access to read the file.

  • Fail-Fast Strategy: Immediate error return upon the first failure encountered, preventing unnecessary processing.

  • Focused Module: The ConfigResolver is dedicated to fetching and aggregating content. Content parsing is handled in the config-to-blueprint step, ensuring modularity.

  • Documentation and Code Comments: Comprehensive documentation and comments within the code and .tailcallrc.graphql for clear understanding of module behaviour.

  • Security: Current implementation should only read files that are publicly accesseble.

Practical Application of @link

  • Initial Implementation: The @link operator will first be used to execute a merge_right operation for any {type: Config} files linked. The merge_right method already exists on Config.

tusharmath avatar Dec 18 '23 08:12 tusharmath

/bounty 150$

tusharmath avatar Dec 18 '23 11:12 tusharmath

💎 $150 bounty created by tailcallhq 🙋 If you'd like to work on this issue, comment below to get assigned 👉 To claim this bounty, submit a pull request that includes the text /claim #760 somewhere in its body

📝 Before proceeding, please make sure you can receive payouts in your country. 💵 Payment arrives in your account 2-5 days after the bounty is rewarded. 💯 You keep 100% of the bounty award. 👍 If you go above and beyond by cleaning up or enhancing aspects beyond the scope of the PR, a tip may be awarded as a token of appreciation. 🙏 Thank you for contributing to tailcallhq/tailcall!. 🙋‍♂️ Join our discord channel if you need help.

👉 Add a bountyShare on socials

algora-pbc[bot] avatar Dec 18 '23 11:12 algora-pbc[bot]

@Ameer-officials: The Tailcall Inc. team prefers to assign a single contributor to the issue rather than let anyone attempt it right away. We recommend waiting for a confirmation from a member before getting started.

algora-pbc[bot] avatar Dec 18 '23 12:12 algora-pbc[bot]

/claim #760

b4s36t4 avatar Dec 18 '23 12:12 b4s36t4

Would love to work on this.

b4s36t4 avatar Dec 18 '23 12:12 b4s36t4

@Ashu999: The Tailcall Inc. team prefers to assign a single contributor to the issue rather than let anyone attempt it right away. We recommend waiting for a confirmation from a member before getting started.

algora-pbc[bot] avatar Dec 19 '23 05:12 algora-pbc[bot]

next in line, if need to reassign

Ashu999 avatar Dec 25 '23 07:12 Ashu999

@b4s36t4 Should we reassign this?

amitksingh1490 avatar Dec 26 '23 06:12 amitksingh1490

Releasing this issue for everyone to attempt. @Ashu999 let me know if you'd want me to assign it to you.

tusharmath avatar Dec 27 '23 06:12 tusharmath

@tusharmath yes please, assign it to me

Ashu999 avatar Dec 27 '23 06:12 Ashu999

Happy to do this if a need comes up.

SourikAdhikary avatar Dec 29 '23 09:12 SourikAdhikary

I'd like to work on this, can I be assigned?

guhitb avatar Jan 03 '24 05:01 guhitb

💡 @ologbonowiwi submitted a pull request that claims the bounty. You can visit your bounty board to reward.

algora-pbc[bot] avatar Feb 02 '24 13:02 algora-pbc[bot]

@ologbonowiwi: Your claim has been rewarded! We'll notify you once it is processed.

algora-pbc[bot] avatar Feb 06 '24 10:02 algora-pbc[bot]

🎉🎈 @ologbonowiwi has been awarded $150! 🎈🎊

algora-pbc[bot] avatar Feb 06 '24 17:02 algora-pbc[bot]