Skip to content

Commit

Permalink
fix: docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-scheers-lemon committed Oct 24, 2024
1 parent 93a8b22 commit ab07fed
Showing 1 changed file with 5 additions and 26 deletions.
31 changes: 5 additions & 26 deletions website/docs/03_architecture/08_queries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -131,28 +131,15 @@ Booster supports returning graphql union types. For example, this `SearchMedia`


```typescript
export class BookMedia {
title!: string
pages!: number
constructor(book: BookMedia) {
;(this.title = book.title), (this.pages = book.pages)
}
}

export class MovieMedia {
title!: string
constructor(movie: MovieMedia) {
this.title = movie.title
}
}
export type MediaValue = BookReadModel | MovieReadModel

export type MediaValue = BookMedia | MovieMedia
class SearchResult {
readonly results!: MediaValue[]
constructor(results: MediaValue[]) {
this.results = results
}
}

@Query({
authorize: 'all',
})
Expand All @@ -179,13 +166,7 @@ export class SearchMedia {
const response = [...books, ...movies]

return {
results: response.map((media) => {
if (media instanceof BookReadModel) {
return new BookMedia({ title: media.title, pages: media.pages })
} else {
return new MovieMedia({ title: media.title })
}
}),
results: response,
}
}
}
Expand All @@ -204,16 +185,14 @@ The GraphQL union querying functionality can then be used. An example for the qu
SearchMedia(input: { searchword: "Oppenheimer" }) {
results {
__typename

... on BookMedia {
... on BookReadModel {
title
pages
}
... on MovieMedia {
... on MovieReadModel {
title
}
}
}
}

```

0 comments on commit ab07fed

Please sign in to comment.