graphql-dotnet icon indicating copy to clipboard operation
graphql-dotnet copied to clipboard

How to implement federated schemas?

Open luzannew opened this issue 4 years ago • 13 comments

First of all, thanks for the initial implementation for federated schemas.

Summary

I have a question about how to implement federated schemas with the graphql-dotnet package. I saw a small example in the PR https://github.com/graphql-dotnet/graphql-dotnet/pull/1233 but I'm not sure how to implement this in a GraphType codebase.

Relevant information

I tried it with this approach, but I have no clue how to use it? There is a For() which can be used to reference a type, but what type do I need to pass?

public class AccountsFederatedSchema : FederatedSchema { }

Environment (if relevant)

Package versions:

<PackageReference Include="GraphQL" Version="3.0.0-preview-1268" />
<PackageReference Include="GraphQL.Server.Transports.AspNetCore" Version="3.5.0-alpha0027" />
<PackageReference Include="GraphQL.Server.Ui.Playground" Version="3.2.0" />

Could you provide an example how to use the federated schemas? Thanks!

luzannew avatar Sep 19 '19 16:09 luzannew

Seems like at moment it will not work for code first aproach (aka graphtype first) wondering for maintainers perspective of view what will be a good decision here, to make it easier in future to migrate things, lets imagine that we wish to start new project with few entities, we wish to split them upfront into different services and combine altogether in a gateway, e.g.:

ideal world

At moment we can not do it and there is few posible workarounds

workaround1

  • easy to start from dotnet perspective (no graphql and new tech here)
  • will be harder to make both dotnet and node schemas in sync
  • will be harder to have a bullet prof ci/cd
  • unnecessary layer of rest
  • in future node wrapper can be removed and dotnet graphql used instead
  • clients wont see change when things will swap

Update: there is a swagger-to-graphql which is capable to create federation compatible graph server on the fly based on existing swagger api which makes this approach little bit easier

workaround2

  • will not have issues with ci/cd
  • will be harder for multiple people to work together instead of own services they will work on little monolith
  • data may be retrieved directly from different storages - will be harder to split in future
  • when we will be able to split everything up all we gonna need from clients to change url from dotnet graphql to gateway

I'm just trying to figure out what other posible options and pros/cons might be here

mac2000 avatar Nov 11 '19 19:11 mac2000

Hi there, Any news about this ? It's becoming hugely important as schema stitching is depreciated

CyrilleFormont avatar Dec 11 '19 05:12 CyrilleFormont

Unfortunately, I have not watched at the federated schemas yet, I can not advise anything. @joemcbride was the one who added support for federated schemas.

sungam3r avatar Dec 11 '19 06:12 sungam3r

Is there any movement on this front? I'm basically blocked from using graphql-dotnet because of this

SamuelCox avatar Mar 31 '21 08:03 SamuelCox

Nope 😞

sungam3r avatar Mar 31 '21 10:03 sungam3r

Is there any way to help or an amount of sponsoring that would allow for this to happen? I appreciate it's really difficult given you're open source and don't necessarily have the resources

SamuelCox avatar Mar 31 '21 10:03 SamuelCox

#1669 it will become available here, probably after releasing the new version of graphql-dotnet, gonna need to figure out what has been changed and return to it, but at the moment guys are working on a new version hardly so federation is out of scope

mac2000 avatar Mar 31 '21 11:03 mac2000

BTW @sungam3r it seems that this ticket may be closed in favor to code first proposal ticket

mac2000 avatar Mar 31 '21 11:03 mac2000

@SamuelCox If you mean financial sponsorship, I don't think it will have some kind of effect. Mostly two people now work constantly over the project. We work when there is a desire and time. Yes, as always in the OSS our time resources are very scarce and backlog is rather big.

sungam3r avatar Mar 31 '21 11:03 sungam3r

I do not close the tickets that I do not understand. Let it be open until the feature is implemented.

sungam3r avatar Mar 31 '21 11:03 sungam3r

probably after releasing the new version of graphql-dotnet, gonna need to figure out what has been changed and return to it, but at the moment guys are working on a new version hardly so federation is out of scope

Already done https://www.nuget.org/packages/GraphQL/

sungam3r avatar Mar 31 '21 11:03 sungam3r

@sungam3r that is awesome news! glad to see that, so probably there is a chance that we might return back to code first approach

mac2000 avatar Mar 31 '21 11:03 mac2000

related https://github.com/graphql-dotnet/graphql-dotnet/pull/3144

Mithras avatar May 19 '22 17:05 Mithras