tailcall icon indicating copy to clipboard operation
tailcall copied to clipboard

refactor: clean up `apollo_federation::compile_service`

Open tusharmath opened this issue 1 year ago • 4 comments

Minor clean ups required:

Current Implementation

pub fn compile_service(config: &ConfigModule) -> Valid<IR, String> {
    let mut sdl =
        crate::core::document::print(filter_conflicting_directives(config.config().into()));

    writeln!(sdl).ok();
    // Add tailcall specific definitions to the sdl output
    writeln!(
        sdl,
        "{}",
        crate::core::document::print(filter_conflicting_directives(Config::graphql_schema()))
    )
    .ok();
    writeln!(sdl).ok();
    // Mark subgraph as Apollo federation v2 compatible according to [docs](https://www.apollographql.com/docs/apollo-server/using-federation/apollo-subgraph-setup/#2-opt-in-to-federation-2)
    // (borrowed from async_graphql)
    writeln!(sdl, "extend schema @link(").ok();
    writeln!(sdl, "\turl: \"https://specs.apollo.dev/federation/v2.3\",").ok();
    writeln!(sdl, "\timport: [\"@key\", \"@tag\", \"@shareable\", \"@inaccessible\", \"@override\", \"@external\", \"@provides\", \"@requires\", \"@composeDirective\", \"@interfaceObject\"]").ok();
    writeln!(sdl, ")").ok();

    Valid::succeed(IR::Service(sdl))
}

Technical Requirements

  • Add new snapshot tests for compile_service before making the change.
  • Ensure there is only one writeln! statement and one call to document::print.
  • Create one ServiceDocument and modify it with definititions that are required or need to be dropped.
  • Ensure the new tests pass with the new change.
  • NOTE: rename file apollo_federation to federation

tusharmath avatar Sep 25 '24 02:09 tusharmath

/bounty $50

tusharmath avatar Sep 25 '24 02:09 tusharmath

~~## 💎 $50 bounty • Tailcall Inc.~~

~~### Steps to solve:~~ ~~1. Start working: Comment /attempt #2904 with your implementation plan~~ ~~2. Submit work: Create a pull request including /claim #2904 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
🟢 @ayusham001 Sep 25, 2024, 3:47:10 AM WIP

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

/attempt #2904

Algora profile Completed bounties Tech Active attempts Options
@ayusham001    1 tailcallhq bounty
+ 8 bounties from 3 projects
Cancel attempt

ayusham001 avatar Sep 25 '24 03:09 ayusham001

@ayusham001 is this still on shall i work on it too?

Abiji-2020 avatar Oct 17 '24 09:10 Abiji-2020

@ayusham001 is this still on shall i work on it too?

Yep, you can start working on it

ayusham001 avatar Oct 17 '24 19:10 ayusham001

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

github-actions[bot] avatar Nov 16 '24 20:11 github-actions[bot]

Issue closed after 7 days of inactivity.

github-actions[bot] avatar Nov 24 '24 01:11 github-actions[bot]