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 2, 2021
1 parent 4492fb2 commit d0eb6f7
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 @@ -22,6 +22,8 @@ describe('printSubgraphSchema', () => {
PRIVATE
}
scalar JSON @specifiedBy(url: \\"https://json-spec.dev\\")
type PasswordAccount @key(fields: \\"email\\") {
email: String!
}
Expand Down Expand Up @@ -54,7 +56,7 @@ describe('printSubgraphSchema', () => {
}
type Mutation {
login(username: String!, password: String!): User
login(username: String!, password: String!, userId: String @deprecated(reason: \\"Use username instead\\")): User
}
extend type RootQuery {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ describe('printSupergraphSdl', () => {
url: String!
}
scalar JSON @specifiedBy(url: \\"https://json-spec.dev\\")
type KeyValue {
key: String!
value: String!
Expand All @@ -160,7 +162,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/printSubgraphSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,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 @@ -148,6 +148,8 @@ describe('loadSupergraphSdlFromStorage', () => {
url: String!
}
scalar JSON @specifiedBy(url: \\"https://json-spec.dev\\")
type KeyValue {
key: String!
value: String!
Expand All @@ -167,7 +169,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 d0eb6f7

Please sign in to comment.