Skip to content

Commit

Permalink
Add unreliable field for demoing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
timbotnik committed Oct 7, 2024
1 parent da1ca94 commit 42dee0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions subgraphs/experiences/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type InterstellarExperience @key(fields: "name") {
destinationId: ID!
"A link to NASA for more information on this experience."
nasaPosterUrl: String!
"For demo purposes, triggers an error in the subgraph"
unreliableDescription: String
}

"""
Expand Down
8 changes: 8 additions & 0 deletions subgraphs/experiences/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ const server = new ApolloServer({
Query: {
experiences: () => experiences,
},
InterstellarExperience: {
unreliableDescription: (parent: any) => {
if (Math.random() < 0.9) {
throw new Error("Something went wrong.");
}
return parent.description;
},
},
Mutation: {
submitInsightsExperienceLevel() {
return true;
Expand Down

0 comments on commit 42dee0e

Please sign in to comment.