Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Strapi GraphQL an implementing service for Federation #6146

Merged
merged 11 commits into from Jul 16, 2020

Conversation

shaheinm
Copy link
Contributor

@shaheinm shaheinm commented May 9, 2020

Description of what you did:

Fix #4870
Added federation flag to GraphQL plugin config.

  • If disabled, works exactly as before.
  • If enabled, the Upload scalar created by Strapi is not removed, as a Federated schema requires the use of @apollo/federation package's buildFederatedSchema() function, and that function uses makeExecutableSchema under the hood, requiring the inclusion of the scalar Upload.

NOTE: I purposely did not include anything related to the @key directive, which sets up the ability to extend types in other services included in Federation. You can use Strapi's custom GraphQL schema definition to do this, though.

No tests were added or changed, but all are passing. Documentation was updated accordingly.

@codecov
Copy link

codecov bot commented May 9, 2020

Codecov Report

Merging #6146 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6146      +/-   ##
==========================================
- Coverage   19.99%   19.98%   -0.01%     
==========================================
  Files         858      858              
  Lines       12095    12094       -1     
  Branches     1965     1965              
==========================================
- Hits         2418     2417       -1     
  Misses       8092     8092              
  Partials     1585     1585              
Flag Coverage Δ
#front 14.67% <ø> (ø)
#unit 41.69% <100.00%> (-0.03%) ⬇️
Impacted Files Coverage Δ
packages/strapi-plugin-upload/services/Upload.js 17.03% <100.00%> (-0.62%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94e031e...696fb40. Read the comment docs.

Signed-off-by: Shahein Moussavi <shaheinm@gmail.com>
Signed-off-by: Shahein Moussavi <shaheinm@gmail.com>
Signed-off-by: Shahein Moussavi <shaheinm@gmail.com>
Signed-off-by: Shahein Moussavi <shaheinm@gmail.com>
Signed-off-by: Shahein Moussavi <shaheinm@gmail.com>
@shaheinm
Copy link
Contributor Author

shaheinm commented May 19, 2020

Any updates on this @alexandrebodin ?

@alexandrebodin
Copy link
Member

Hey @shaheinm can you give more context / example as to what you can do with this added ?

@bamne123
Copy link

bamne123 commented May 26, 2020

When it will be in Release?
@alexandrebodin I m planning to Use Strapi in Microservices environment, with Apollo Federation setup.

@shaheinm
Copy link
Contributor Author

shaheinm commented Jun 3, 2020

Hey @shaheinm can you give more context / example as to what you can do with this added ?

@alexandrebodin One example is simply running Strapi as a microservice with Apollo Federation. My team is planning to customize the Strapi GraphQL schema to allow it to be extended in a versioning and indexing service, which will act as a sort of single source of truth, while Strapi provides the data on the client. We're also handling file uploads outside of Strapi, and simply plugging links into the content, and wanted that service at the same url for the client side application to access.

@efstajas
Copy link

👀 Would love to see this. We're also running a microservice environment with Federation and having our blog content alongside other service's data would be sweet. Please let me know if we can assist with getting this merged in any way.

@alexandrebodin
Copy link
Member

Right now the PR has conflicts. I would like to see if we can avoid having the dependency installed for everyone though 🤔 using some customization to add it programmaticaly maybe

@ntsvetkova-fcse
Copy link
Contributor

We also would like to use Federation instead of creating a Strapi connector in our middleware. Would be really nice to have this PR merged ASAP.

@shaheinm
Copy link
Contributor Author

Right now the PR has conflicts. I would like to see if we can avoid having the dependency installed for everyone though using some customization to add it programmaticaly maybe

I can try to resolve the conflicts in yarn.lock but I don't believe there is any way to avoid adding the dependency in package.json. Moreover, the @apollo/federation package is only 606 kb unpacked, so it isn't a major addition.

@alexandrebodin
Copy link
Member

@lauriejim Can you review the doc section ?

@maxbause
Copy link

maxbause commented Jul 3, 2020

We would also like to use the federation feature since it will allow us to "glue" multiple GraphQL servers (strapi, service 1, service 2, etc...) together which would be really handy. 💯

Let me know if anyone needs help to release this feature

@alexandrebodin alexandrebodin added this to the 3.0.6 milestone Jul 16, 2020
@alexandrebodin alexandrebodin added source: plugin:graphql Source is plugin/graphql package issue: enhancement Issue suggesting an enhancement to an existing feature labels Jul 16, 2020
Copy link
Member

@alexandrebodin alexandrebodin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ! In the future we will certainly make this modularized to avoid installing every possible extension of apollo :)

@alexandrebodin alexandrebodin merged commit 580102f into strapi:master Jul 16, 2020
gilfernandes pushed a commit to onepointconsulting/strapi that referenced this pull request Aug 13, 2020
* Add Strapi GraphQL to Apollo Federation as implementation

Signed-off-by: Shahein Moussavi <shaheinm@gmail.com>

* updated graphql plugin documentation for federation

Signed-off-by: Shahein Moussavi <shaheinm@gmail.com>

* Creating separate package while waiting for Strapi PR acceptance

Signed-off-by: Shahein Moussavi <shaheinm@gmail.com>

* v3.1.0-beta.0

Signed-off-by: Shahein Moussavi <shaheinm@gmail.com>

* Accidentally pushed bad changes

Signed-off-by: Shahein Moussavi <shaheinm@gmail.com>

* used lodash for config variable for consistency, updated comment to be more descriptive

Signed-off-by: Shahein Moussavi <shaheinm@gmail.com>
Signed-off-by: Gil Fernandes <gil.fernandes@onepointltd.com>
@benoj
Copy link

benoj commented Feb 22, 2021

Hi,

I saw this was merged... but can't seem to see these changes in the code / docs (3.5.0) did this get removed?

@benoj
Copy link

benoj commented Feb 22, 2021

in-fact - i have seen the changes to the config locations...

However when I run an apollo federation gateway I see the following:

Error checking for changes to service definitions: Couldn't load service definitions for "shop" at http://localhost:1337/graphql: 400: Bad Request
This data graph is missing a valid configuration. Couldn't load service definitions for "shop" at http://localhost:1337/graphql: 400: Bad Request

@AdrianOrlow
Copy link

@benoj It wasn't removed, but someone changed flag name from federation to isFederated

@alexandrebodin
Copy link
Member

Nice catch I'm going to make a fix for this but you can use isFederated as a workaround for now.

@derrickmehaffy
Copy link
Member

This pull request has been mentioned on Strapi Community Forum. There might be relevant details there:

https://forum.strapi.io/t/is-it-possible-to-use-the-apollo-federation-specification/4334/3

@Tommo56700
Copy link

Tommo56700 commented Jan 10, 2023

@alexandrebodin, @shaheinm, the documentation around this for Strapi v4 seems to be lacking. Are there any resources for how to set this up? Specifically, relating to the @key directive, which sets up the ability to extend types in other services included in Federation?

@dbsmck
Copy link

dbsmck commented Apr 17, 2023

This doesn't seem to be implemented in v4 unfortunately - would be great if it was 👀

@stephane-segning
Copy link

Is this feature planned to be implemented in v4 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: enhancement Issue suggesting an enhancement to an existing feature source: plugin:graphql Source is plugin/graphql package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GraphQL Federation (schema stitching)