tailcall icon indicating copy to clipboard operation
tailcall copied to clipboard

Feature Request: Support for Apollo Federation in Tailcall

Open amitksingh1490 opened this issue 1 year ago • 5 comments
trafficstars

Summary

Enable Tailcall to support Apollo Federation by adding a flag in the @server directive. When enabled, this flag will support the _entities query, allowing Tailcall to function as a subgraph in a federated architecture.

Detailed Description

To integrate Apollo Federation with Tailcall, we propose the following enhancements:

  1. Flag Addition in @server:

    • Introduce a new flag within the @server directive to enable federation support.
    • When this flag is activated, Tailcall will automatically handle the _entities query, essential for Apollo Federation's distributed schema architecture.
  2. Support for Resolver Directives on Types:

    • Enable resolver directives like @http, @grpc, @const, and others to be applied directly on Types.
    • This will allow Tailcall to infer the key fields required for federation based on the resolver configuration.
  3. Key Inference:

    • Analyze the resolvers attached to Types and automatically infer the appropriate @key directive.
    • Example:
      • For @http(path: "/users/{{.value.id}}"), the inferred key would be @key(fields: "id").
      • For the query:
        @http(path: "/users/", query: [
          {key: "id", value: "{{.value.id}}"},
          {key: "name", value: "{{.value.name}}"},
          {key: "org_id", value: "{{.value.organisation.id}}"},
          {key: "org_name", value: "{{.value.organisation.name}}"}
        ])
        
        The inferred key would be @key(fields: "id name organisation {id, name}").
    • If multiple resolvers are attached to the same type, multiple keys will be inferred and handled accordingly.
  4. Support for _entities Query:

    • Implement the _entities query required by Apollo Federation.
    • Example of how the query to the subgraph would look:
      type Query {
        _entities(representations: [_Any!]!): [_Entity]!
      }
      
      • Example query:
        query ($representations: [_Any!]!) {
          _entities(representations: $representations) {
            ... on User {
              id
              username
            }
          }
        }
        
        • Corresponding variable:
          {
            "representations": [
              {
                "__typename": "User",
                "id": "5"
              }
            ]
          }
          

References

Technical Requirements

  • Integration & Unit Tests are required.
  • Update the documentation on website

amitksingh1490 avatar Aug 10 '24 12:08 amitksingh1490

/bounty 380$

amitksingh1490 avatar Aug 10 '24 13:08 amitksingh1490

💎 $380 bounty • Tailcall Inc.

Steps to solve:

  1. Start working: Comment /attempt #2639 with your implementation plan
  2. Submit work: Create a pull request including /claim #2639 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
🔴 @onyedikachi-david Aug 10, 2024, 7:00:15 PM WIP
🟢 @meskill #2693

algora-pbc[bot] avatar Aug 10 '24 13:08 algora-pbc[bot]

/attempt #2639

Algora profile Completed bounties Tech Active attempts Options
@onyedikachi-david    3 tailcallhq bounties
+ 2 bounties from 1 project
JavaScript, Shell
Cancel attempt

onyedikachi-david avatar Aug 10 '24 19:08 onyedikachi-david

please provide some working config

ssddOnTop avatar Aug 11 '24 07:08 ssddOnTop

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

algora-pbc[bot] avatar Aug 11 '24 19:08 algora-pbc[bot]

The bounty is up for grabs! Everyone is welcome to /attempt #2639 🙌

algora-pbc[bot] avatar Aug 12 '24 19:08 algora-pbc[bot]

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

algora-pbc[bot] avatar Aug 14 '24 15:08 algora-pbc[bot]

Action required: Issue inactive for 30 days. Status update or closure in 7 days.

github-actions[bot] avatar Sep 21 '24 08:09 github-actions[bot]

🎉🎈 @meskill has been awarded $380! 🎈🎊

algora-pbc[bot] avatar Sep 24 '24 14:09 algora-pbc[bot]