Skip to content

Commit

Permalink
docs(unions): update docs and examples with function syntax for types
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalLytek committed Aug 17, 2019
1 parent 63f480b commit b7d2e6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/unions.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { createUnionType } from "type-graphql";

const SearchResultUnion = createUnionType({
name: "SearchResult", // the name of the GraphQL union
types: [Movie, Actor], // array of object types classes
types: () => [Movie, Actor], // function that returns array of object types classes
});
```

Expand Down Expand Up @@ -69,7 +69,7 @@ However, we can also provide our own `resolveType` function implementation to th
```typescript
const SearchResultUnion = createUnionType({
name: "SearchResult",
types: [Movie, Actor],
types: () => [Movie, Actor],
// our implementation of detecting returned object type
resolveType: value => {
if ("rating" in value) {
Expand Down
2 changes: 1 addition & 1 deletion examples/enums-and-unions/search-result.union.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import { Cook } from "./cook.type";

export const SearchResult = createUnionType({
name: "SearchResult",
types: [Recipe, Cook],
types: () => [Recipe, Cook],
});

0 comments on commit b7d2e6b

Please sign in to comment.