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 products subgraph with additional entities to test out @key
directive use cases
#149
Labels
type: enhancement
New feature or request
type: schema change
Change introduces change to the subgraph schemas
Comments
dariuszkuc
added
type: enhancement
New feature or request
type: schema change
Change introduces change to the subgraph schemas
labels
Aug 3, 2022
dariuszkuc
added a commit
to dariuszkuc/apollo-federation-subgraph-compatibility
that referenced
this issue
Aug 11, 2022
Update `product` subgraph with additional entites to separate testing for various `@key` test cases. Previously we were testing single entity that was supposed to define multiple `@key` directives. This was problematic as not all implementations support repeatable directives and we never checked whether given `@key` test case was actually present in the schema (test was executing `_entities` query only). Schema changes (existing fields and types are omitted for clarity): ```graphql type Product @key(fields: "id") @key(fields: "sku package") @key(fields: "sku variation { id }") { # new field research: [ProductResearch!]! } type DeprecatedProduct @key(fields: "sku package") { sku: String! package: String! reason: String createdBy: User } type ProductResearch @key(fields: "study { caseNumber }") { study: CaseStudy! outcome: String } type CaseStudy { caseNumber: ID! description: String } extend type Query { # new query deprecatedProduct(sku: String!, package: String!): DeprecatedProduct @deprecated(reason: "Use product query instead") } ``` Update `@key` tests cases to verify: * single field `@key` functionality against `User` type * multiple field `@key` functionality against `DeprecatedProduct` type * composite object `@key` functionality against `ProductResearch` type * repeatable `@key` functionality against `Product` type (this test combines old tests into a single one) Related Issues: * resolves apollographql#144 * resolves apollographql#149
dariuszkuc
added a commit
to dariuszkuc/apollo-federation-subgraph-compatibility
that referenced
this issue
Aug 11, 2022
Update `product` subgraph with additional entites to separate testing for various `@key` test cases. Previously we were testing single entity that was supposed to define multiple `@key` directives. This was problematic as not all implementations support repeatable directives and we never checked whether given `@key` test case was actually present in the schema (test was executing `_entities` query only). Schema changes (existing fields and types are omitted for clarity): ```graphql type Product @key(fields: "id") @key(fields: "sku package") @key(fields: "sku variation { id }") { # new field research: [ProductResearch!]! } type DeprecatedProduct @key(fields: "sku package") { sku: String! package: String! reason: String createdBy: User } type ProductResearch @key(fields: "study { caseNumber }") { study: CaseStudy! outcome: String } type CaseStudy { caseNumber: ID! description: String } extend type Query { # new query deprecatedProduct(sku: String!, package: String!): DeprecatedProduct @deprecated(reason: "Use product query instead") } ``` Update `@key` tests cases to verify: * single field `@key` functionality against `User` type * multiple field `@key` functionality against `DeprecatedProduct` type * composite object `@key` functionality against `ProductResearch` type * repeatable `@key` functionality against `Product` type (this test combines old tests into a single one) Related Issues: * resolves apollographql#144 * resolves apollographql#149
dariuszkuc
added a commit
to dariuszkuc/apollo-federation-subgraph-compatibility
that referenced
this issue
Aug 11, 2022
Update `product` subgraph with additional entites to separate testing for various `@key` test cases. Previously we were testing single entity that was supposed to define multiple `@key` directives. This was problematic as not all implementations support repeatable directives and we never checked whether given `@key` test case was actually present in the schema (test was executing `_entities` query only). Schema changes (existing fields and types are omitted for clarity): ```graphql type Product @key(fields: "id") @key(fields: "sku package") @key(fields: "sku variation { id }") { # new field research: [ProductResearch!]! } type DeprecatedProduct @key(fields: "sku package") { sku: String! package: String! reason: String createdBy: User } type ProductResearch @key(fields: "study { caseNumber }") { study: CaseStudy! outcome: String } type CaseStudy { caseNumber: ID! description: String } extend type Query { # new query deprecatedProduct(sku: String!, package: String!): DeprecatedProduct @deprecated(reason: "Use product query instead") } ``` Update `@key` tests cases to verify: * single field `@key` functionality against `User` type * multiple field `@key` functionality against `DeprecatedProduct` type * composite object `@key` functionality against `ProductResearch` type * repeatable `@key` functionality against `Product` type (this test combines old tests into a single one) Related Issues: * resolves apollographql#144 * resolves apollographql#149
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
type: enhancement
New feature or request
type: schema change
Change introduces change to the subgraph schemas
Currently
products
subgraph definesProduct
entity with multiple@key
directives. Various@key
use cases (single field, multiple field, composite object keys) are tested directly against the target subgraph by passing_entities
query and various representations.This testing approach is somewhat problematic as not every implementation supports repeatable directives, which means that while entity resolution logic might be fine there will be only a single
@key
directive present in the schema. Gateway will not be able to query the entities using other keys as they will not exist in the supergraph schema.Proposed changes:
Product
with multiple@key
directives but use it to verify single field key and repeatable directive use case@key
foo { bar }
)@key
The text was updated successfully, but these errors were encountered: