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

Export supergraph as SDL #96

Merged
merged 1 commit into from
Dec 2, 2023
Merged

Export supergraph as SDL #96

merged 1 commit into from
Dec 2, 2023

Conversation

gmac
Copy link
Owner

@gmac gmac commented Dec 2, 2023

⚠️ Minor breaking change

This replaces the supergraph.export and Supergraph.from_export methods with supergraph.to_definition and Supergraph.from_definition.

Where the old export methods would return/receive multiple export artifacts (SDL + JSON), this new serialization/deserialization process writes everything as one annotated SDL file, ex:

directive @resolver(
  arg: String!, 
  federation: Boolean, 
  field: String!, 
  key: String!, 
  list: Boolean, 
  location: String!
) repeatable on INTERFACE | OBJECT | UNION

directive @source(location: String!) repeatable on FIELD_DEFINITION

type Query {
  a(id: ID!): T @source(location: "alpha")
  b(id: ID!): T @source(location: "bravo")
}

type T 
  @resolver(location: "alpha", key: "id", field: "a", arg: "id") 
  @resolver(location: "bravo", key: "id", field: "b", arg: "id") {
  a: String @source(location: "alpha")
  b: String @source(location: "bravo")
  id: ID! @source(location: "alpha") @source(location: "bravo")
}

Migration steps

  • See revised documentation.
  • Replace supergraph.export with supergraph.to_definition. This now generates a single SDL string with all data rather than multiple artifacts.
  • Replace Supergraph.from_export with Supergraph.from_definition, passing in only the composed SDL string and executables map.

@gmac gmac force-pushed the gmac/export_supergraph_sdl branch from 2aaa35f to f1a4b73 Compare December 2, 2023 03:52
@gmac gmac force-pushed the gmac/export_supergraph_sdl branch from f1a4b73 to 1bac116 Compare December 2, 2023 03:57
@gmac gmac merged commit 43dc887 into main Dec 2, 2023
4 checks passed
@gmac gmac deleted the gmac/export_supergraph_sdl branch December 2, 2023 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant