Skip to content

Commit

Permalink
Implement http directive for join__Graph enum
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-scheer committed Mar 19, 2021
1 parent f1e0a8a commit f9f3784
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 6 additions & 6 deletions federation-js/src/service/__tests__/printCoreSchema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ describe('printCoreSchema', () => {
scalar join__FieldSet
enum join__Graph {
ACCOUNTS
BOOKS
DOCUMENTS
INVENTORY
PRODUCT
REVIEWS
ACCOUNTS @http(url: \\"https://accounts.api.com\\")
BOOKS @http(url: \\"https://books.api.com\\")
DOCUMENTS @http(url: \\"https://documents.api.com\\")
INVENTORY @http(url: \\"https://inventory.api.com\\")
PRODUCT @http(url: \\"https://product.api.com\\")
REVIEWS @http(url: \\"https://reviews.api.com\\")
}
type KeyValue {
Expand Down
10 changes: 9 additions & 1 deletion federation-js/src/service/printCoreSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,22 @@ function printEnum(type: GraphQLEnumType, options?: Options): string {
printDescription(options, value, ' ', !i) +
' ' +
value.name +
printDeprecated(value),
printDeprecated(value) +
printHttpDirective(type, value),
);

return (
printDescription(options, type) + `enum ${type.name}` + printBlock(values)
);
}

function printHttpDirective(type: GraphQLEnumType, value: GraphQLEnumValue) {
if (type.name === "join__Graph") {
return ` @http(url: "${value.value}")`
}
return '';
}

function printInputObject(
type: GraphQLInputObjectType,
options?: Options,
Expand Down

1 comment on commit f9f3784

@glasser
Copy link
Member

Choose a reason for hiding this comment

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

I know there have been some proposals around using @http but I think we should stick with only things under the @join__ namespace for now, unless we actually want to write an http core feature spec in the short term.

I'd suggest just @join__graph(endpoint: "https://foo")? That would allow us to add more arguments later if we need more bits of per-subgraph metadata.

cc @martijnwalraven

Please sign in to comment.