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

update @requires test to verify the functionality #150

Merged
merged 3 commits into from
Aug 5, 2022

Conversation

dariuszkuc
Copy link
Member

@dariuszkuc dariuszkuc commented Aug 3, 2022

Updating users and products subgraph schemas to allow for testing the support of @requires functionality in the implementing subgraph. This is a breaking change as we modify the schema so all the existing implementations will be impacted.

Changes:

  • users subgraph
type User @key(fields:"email") {
  email:ID!
  name: String
  totalProductsCreated: Int
  yearsOfEmployment: Int! # <-- new field
}
  • products subgraph
extend type User @key(fields: "email") {
  averageProductsCreatedPerYear: Int @requires(fields: "yearsOfEmployment") # <-- test `@requires` functionality
  email: ID! @external
  name: String @override(from: "users")
  totalProductsCreated: Int @external
  yearsOfEmployment: Int! @external # <-- field from the users subgraph used by @requires
}

Implementation updates will follow in separate PRs.

Related Issues:

@dariuszkuc dariuszkuc added type: bug Something isn't working type: test Update federation compatibility tests type: schema change Change introduces change to the subgraph schemas labels Aug 3, 2022
@kdawgwilk
Copy link
Contributor

Whats the approach to adding these changes to implementations? will that be done in this PR? How can library maintainers help?

@dariuszkuc
Copy link
Member Author

@kdawgwilk 👋 I'll split the PR into the schema + test update and will have separate implementations PR. Once the test PR is merged, you will be able to update the implementations without waiting for additional changes from my side. Thanks for the help!

@dariuszkuc dariuszkuc force-pushed the requires_tests branch 3 times, most recently from 261172d to 6adf888 Compare August 4, 2022 21:12
@ddebrunner
Copy link
Contributor

Does CONTRIBUTORS.md need to be updated?

@dariuszkuc
Copy link
Member Author

@ddebrunner yes, I'll update it once the #152 is merged

Updating `users` and `products` subgraph schemas to allow for testing the support of `@requires` functionality in the implementing subgraph. This is a breaking change as we modify the schema so all the existing implementations will be impacted.

Changes:
* `users` subgraph
```graphql
type User @key(fields:"email") {
  email:ID!
  name: String
  totalProductsCreated: Int
  yearsOfEmployment: Int! # <-- new field
}
```
* `products` subgraph
```graphql
extend type User @key(fields: "email") {
  averageProductsCreatedPerYear: Int @requires(fields: "yearsOfEmployment") # <-- test `@requires` functionality
  email: ID! @external
  name: String @OverRide(from: "users")
  totalProductsCreated: Int @external
  yearsOfEmployment: Int! @external # <-- field from the users subgraph used by @requires
}
```

Related Issues:

* apollographql#128
@dariuszkuc dariuszkuc merged commit 71cf66f into apollographql:main Aug 5, 2022
@dariuszkuc dariuszkuc deleted the requires_tests branch August 5, 2022 19:31
Copy link
Member

@hwillson hwillson left a comment

Choose a reason for hiding this comment

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

Thanks for adding this @dariuszkuc!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working type: schema change Change introduces change to the subgraph schemas type: test Update federation compatibility tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants