Skip to content

Commit

Permalink
Add example (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddeee888 authored Sep 11, 2023
1 parent ab6a9e7 commit f0686d7
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .changeset/flat-countries-rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,59 @@
---

Support extending non-root object types

For example, given this schema:

```graphql
# user/schema.graphql
type User {
id: ID!
}

# car/schema.graphql
extend type User {
cars: [Car!]!
}

# house/schema.graphql
extend type User {
housesOwned: [House!]!
housesSold: [House!]!
}
```

It'd generate these files:

```ts
// user/resolvers/User.ts
export const User: Pick<UserResolvers, 'id'> = {
// ...
};

// car/resolvers/User.ts
export const User: Pick<UserResolvers, 'cars'> = {
// ...
};

// house/resolvers/User.ts
export const User: Pick<UserResolvers, 'housesOwned' | 'housesSold'> = {
// ...
};
```

And the main resolver file:

```ts
// resolvers.generated.ts
import { User as user_User } from './user/resolvers/User';
import { User as car_User } from './car/resolvers/User';
import { User as house_User } from './house/resolvers/User';

export const resolvers: Resolvers = {
User: {
...user_User,
...car_User,
...house_User,
},
};
```

0 comments on commit f0686d7

Please sign in to comment.