Skip to content

Commit

Permalink
chore(docs): syntax hint
Browse files Browse the repository at this point in the history
  • Loading branch information
vicary committed Oct 12, 2022
1 parent 06aaeaf commit 2c3d9f6
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const handler = async (req: Request, ctx: HandlerContext) => {
```ts
// ./graphql/Query/joke.ts

export const schema = `
export const schema = /* GraphQL */ `
extend type Query {
joke: String!
}
Expand All @@ -124,32 +124,30 @@ const JOKES = [
"An SEO expert walked into a bar, pub, inn, tavern, hostelry, public house.",
];

export const resolver = () => {
return JOKES[Math.floor(Math.random() * JOKES.length)];
};
export const resolver = () => JOKES[Math.floor(Math.random() * JOKES.length)];
```

Schema level types, `Query`, `Mutation` and `Subscription`, will be
automatically created when such a corresponding extension statement is found.

Resolver object will be wrapped according to the directory structure, i.e.
`{ Query: { foo: resolver } }`. To override this behavior, export an object
`{ Query: { joke: resolver } }`. To override this behavior, export an object
instead.

```ts
export const resolver = {
Query: {
bar: () => "Hello world!";
foo: () => "bar";
}
};
```

### Subscriptions

```ts
// graphql/Subscription/countdown.ts
// ./graphql/Subscription/countdown.ts

export const schema = `
export const schema = /* GraphQL */ `
extend type Subscription {
countdown(from: Int = 0): Int!
}
Expand Down

0 comments on commit 2c3d9f6

Please sign in to comment.