apollographql / federation-hotchocolate

HotChocolate support for Apollo Federation
https://www.apollographql.com/docs/federation/
MIT License
16 stars 8 forks source link

feat: Add IRequestExecutorBuilder extension for adding contact information #45

Closed damienpontifex closed 1 year ago

damienpontifex commented 1 year ago

It would be nice to have a convenience/extension method for adding contact info instead of the custom schema object as referenced in the README.

Proposal

//
// Summary:
//     Adds contact information and @contact decorator to schema
//
// Parameters:
//   name:
//     Contact title of the subgraph owner
//
//   url:
//     URL where the subgraph's owner can be reached
//
//   description:
//     Other relevant contact notes; supports markdown links
public static IRequestExecutorBuilder AddContact(this IRequestExecutorBuilder builder, string name, string? url = null, string? description = null);

This would make configuration inline with other graphql configuration and avoid needing to define a custom schema type only to add this attribute.

dariuszkuc commented 1 year ago

This would be great... but it looks like HotChocolate API does not allow for this :( Since schema builder mechanism is considered "deprecated", I'm guessing it won't be fixed (I'll open up an issue) and we'll have to wait for the new "skimmed" API to stabilize.

My attempt -> https://github.com/apollographql/federation-hotchocolate/pull/47

The underlying issue is that we cannot apply multiple SetSchema lambdas as instead of doing cumulative updates from all applied lambdas, only the last one is applied. This is the behavior I'd expect from SetSchema(object) and sounds like a miss on the lambda front.

dariuszkuc commented 1 year ago

Opened up https://github.com/ChilliCream/graphql-platform/issues/6651

damienpontifex commented 1 year ago

Maybe a Action argument to the AddApolloFederationV2 method then might work better? Then it can be configured as the federated schema is configured?

dariuszkuc commented 1 year ago

Good idea. This could work -> https://github.com/apollographql/federation-hotchocolate/pull/47/commits/b93b2249ee0acc8c3e97d3c70fb2ffb83ce25cf7

damienpontifex commented 1 year ago

@dariuszkuc looks good. What's the ComposeDirective bit...might be just a method in hot chocolate I haven't used before? It's just the same to setup contact directive in a similar way I assume

dariuszkuc commented 1 year ago

👋 @composeDirective is a federation directive that allows you to preserve your directives in the supergraph (by default they got stripped out), see docs

Both @contact and @composeDirective are applicable on a schema.