Skip to content

Commit

Permalink
Add missing deprecated input value printing for subgraph printer.
Browse files Browse the repository at this point in the history
Add tests for printing @SpecifiedBy and deprecated input values.
  • Loading branch information
trevor-scheer committed Sep 1, 2021
1 parent 084a76f commit c524cda
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
8 changes: 7 additions & 1 deletion federation-integration-testsuite-js/src/fixtures/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export const typeDefs = gql`
inheritMaxAge: Boolean
) on FIELD_DEFINITION | OBJECT | INTERFACE | UNION
scalar JSON @specifiedBy(url: "https://json-spec.dev")
schema {
query: RootQuery
mutation: Mutation
Expand Down Expand Up @@ -65,7 +67,11 @@ export const typeDefs = gql`
}
type Mutation {
login(username: String!, password: String!): User
login(
username: String!
password: String!
userId: String @deprecated(reason: "Use username instead")
): User
}
extend type Library @key(fields: "id") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ describe('printFederatedSchema', () => {
url: String!
}
scalar JSON @specifiedBy(url: \\"https://json-spec.dev\\")
type KeyValue {
key: String!
value: String!
Expand All @@ -101,7 +103,7 @@ describe('printFederatedSchema', () => {
type Mutation {
deleteReview(id: ID!): Boolean
login(password: String!, username: String!): User
login(password: String!, userId: String @deprecated(reason: \\"Use username instead\\"), username: String!): User
reviewProduct(body: String!, upc: String!): Product
updateReview(review: UpdateReviewInput!): Review
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ describe('printSupergraphSdl', () => {
REVIEWS @join__graph(name: \\"reviews\\" url: \\"https://reviews.api.com\\")
}
scalar JSON @specifiedBy(url: \\"https://json-spec.dev\\")
type KeyValue {
key: String!
value: String!
Expand All @@ -183,7 +185,7 @@ describe('printSupergraphSdl', () => {
type Mutation {
deleteReview(id: ID!): Boolean @join__field(graph: REVIEWS)
login(password: String!, username: String!): User @join__field(graph: ACCOUNTS)
login(password: String!, userId: String @deprecated(reason: \\"Use username instead\\"), username: String!): User @join__field(graph: ACCOUNTS)
reviewProduct(body: String!, upc: String!): Product @join__field(graph: REVIEWS)
updateReview(review: UpdateReviewInput!): Review @join__field(graph: REVIEWS)
}
Expand Down
2 changes: 1 addition & 1 deletion federation-js/src/service/printFederatedSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ function printInputValue(arg: GraphQLInputField) {
if (defaultAST) {
argDecl += ` = ${print(defaultAST)}`;
}
return argDecl;
return argDecl + printDeprecated(arg.deprecationReason);
}

function printDirective(directive: GraphQLDirective) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ describe('loadSupergraphSdlFromStorage', () => {
REVIEWS @join__graph(name: \\"reviews\\" url: \\"https://reviews.api.com\\")
}
scalar JSON @specifiedBy(url: \\"https://json-spec.dev\\")
type KeyValue {
key: String!
value: String!
Expand All @@ -190,7 +192,7 @@ describe('loadSupergraphSdlFromStorage', () => {
type Mutation {
deleteReview(id: ID!): Boolean @join__field(graph: REVIEWS)
login(password: String!, username: String!): User @join__field(graph: ACCOUNTS)
login(password: String!, userId: String @deprecated(reason: \\"Use username instead\\"), username: String!): User @join__field(graph: ACCOUNTS)
reviewProduct(body: String!, upc: String!): Product @join__field(graph: REVIEWS)
updateReview(review: UpdateReviewInput!): Review @join__field(graph: REVIEWS)
}
Expand Down

0 comments on commit c524cda

Please sign in to comment.