Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit a9d5673

Browse files
committed
better name for typescript-to-graphql command
extract top level resolvers to query module
1 parent 6bd6450 commit a9d5673

File tree

7 files changed

+20
-10
lines changed

7 files changed

+20
-10
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ or
5656
- Docker: `$ docker-compose up --build`
5757

5858
Attention windows users: when `Docker for Windows` is not an option, install `yarn` and run `$ yarn && yarn docker-mount` beforehand.
59-
## Regenerate GraphQL schema TypeScript types
59+
## Generate TypeScript types for GraphQL schema
6060

61-
- npm: `$ npm run g2t`
62-
- yarn: `$ yarn g2t`
61+
- npm: `$ npm run gql-2-ts`
62+
- yarn: `$ yarn gql-2-ts`
6363

6464
## Test
6565

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"copy:graphql": "cpx \"src/**/*.{gql,graphql,graphqls}\" build",
1919
"copy:graphql:watch": "chokidar \"./src/**/*.{gql,graphql,graphqls}\" -c \"npm run clean:graphql && npm run copy:graphql && touch src/server.ts\"",
2020
"docker-mount": "docker-share mount -t",
21-
"g2t": "graphql-to-typescript src/graphql/*.graphqls src/graphql/types/index.ts "
21+
"gql-2-ts": "graphql-to-typescript src/graphql/*.graphqls src/graphql/_generated/types/index.ts "
2222
},
2323
"engines": {
2424
"node": ">= 8.1.4"
File renamed without changes.

src/graphql/models/jokes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as jokes from '../../connectors/joke';
2-
import { JokeCategoryEnum, Joke } from '../types';
2+
import { JokeCategoryEnum, Joke } from '../_generated/types';
33

44
const byCategory = async (category: JokeCategoryEnum): Promise<Joke> => {
55
const randomJokeResponse = await jokes.getRandomJokeByCategory(category);

src/graphql/resolvers/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { merge } from 'lodash';
22

3+
import query from './query';
34
import jokes from './jokes';
45

5-
export default merge(jokes);
6+
export default merge(
7+
query,
8+
jokes,
9+
);

src/graphql/resolvers/jokes.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { byCategory } from '../models/jokes';
2-
import { ByCategoryJokesArgs, Joke } from '../types';
2+
import { ByCategoryJokesArgs, Joke } from '../_generated/types';
33

44
const resolvers = {
5-
Query: {
6-
jokes: () => ({}),
7-
},
85
Jokes: {
96
byCategory: (_, { category }: ByCategoryJokesArgs): Promise<Joke> => byCategory(category!),
107
},

src/graphql/resolvers/query.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { byCategory } from '../models/jokes';
2+
3+
const resolvers = {
4+
Query: {
5+
jokes: () => ({}),
6+
},
7+
};
8+
9+
export default resolvers;

0 commit comments

Comments
 (0)