|
1 | 1 | # @eddeee888/gcg-typescript-resolver-files
|
2 | 2 |
|
| 3 | +## 0.8.0 |
| 4 | + |
| 5 | +### Minor Changes |
| 6 | + |
| 7 | +- 6bf957d: Extend `resolverGeneration` functionality |
| 8 | + |
| 9 | + Allow passing in an object that to control which files to be generated. By default (i.e. `resolverGeneration: 'recommended'`), it's equivalent to the following settings: |
| 10 | + |
| 11 | + ```ts |
| 12 | + defineConfig({ |
| 13 | + resolverGeneration: { |
| 14 | + query: '*', |
| 15 | + mutation: '*', |
| 16 | + subscription: '*', |
| 17 | + scalar: '*', |
| 18 | + object: '*', |
| 19 | + union: '', |
| 20 | + interface: '', |
| 21 | + }, |
| 22 | + }); |
| 23 | + ``` |
| 24 | + |
| 25 | + Each option can take a glob pattern to tell the preset which files of a given type to be generated based on its normalized file name. |
| 26 | + |
| 27 | + *** |
| 28 | + |
| 29 | + A normalized file name has this pattern: |
| 30 | + |
| 31 | + ``` |
| 32 | + <Module name>.<Top-level type name>.<Field resolver>? |
| 33 | + ``` |
| 34 | + |
| 35 | + Consider this schema: |
| 36 | + |
| 37 | + ```graphql |
| 38 | + # src/schema/pet/schema.graphql |
| 39 | + extend type Query { |
| 40 | + pets: [Pet!]! |
| 41 | + } |
| 42 | + |
| 43 | + type Cat { |
| 44 | + id: ID! |
| 45 | + } |
| 46 | + type Dog { |
| 47 | + id: ID! |
| 48 | + } |
| 49 | + union Pet = Cat | Dog |
| 50 | + |
| 51 | + # src/schema/user/schema.graphql |
| 52 | + extend type Mutation { |
| 53 | + createUser(id: ID!): CreateUserResult! |
| 54 | + } |
| 55 | + |
| 56 | + type User { |
| 57 | + id: ID! |
| 58 | + } |
| 59 | + |
| 60 | + type CreateUserOk { |
| 61 | + result: User! |
| 62 | + } |
| 63 | + type CreateUserError { |
| 64 | + error: String! |
| 65 | + } |
| 66 | + union CreateUserResult = CreateUserOk | CreateUserError |
| 67 | + ``` |
| 68 | + |
| 69 | + Then, the generated files and normalised names are: |
| 70 | + |
| 71 | + - `src/schema/pet/resolvers/Query/pets.ts`, affected by `query` option, normalized name: `pet.Query.pets` |
| 72 | + - `src/schema/pet/resolvers/Cat.ts`, affected by `object` option, normalized name: `pet.Cat` |
| 73 | + - `src/schema/pet/resolvers/Dog.ts`, affected by `object` option, normalized name: `pet.Dog` |
| 74 | + - `src/schema/pet/resolvers/Pet.ts`, affected by `union` option, normalized name: `pet.Pet` |
| 75 | + - `src/schema/user/resolvers/Mutation/createUser.ts`, affected by `mutation` option, normalized name: `user.Mutation.createUser` |
| 76 | + - `src/schema/user/resolvers/User.ts`, affected by `object` option, normalized name: `user.User` |
| 77 | + - `src/schema/user/resolvers/CreateUserOk.ts`, affected by `object` option, normalized name: `user.CreateUserOk` |
| 78 | + - `src/schema/user/resolvers/CreateUserError.ts`, affected by `object` option, normalized name: `user.CreateUserError` |
| 79 | + - `src/schema/user/resolvers/CreateUserResult.ts`, affected by `union` option, normalized name: `user.CreateUserResult` |
| 80 | + |
| 81 | + Now, let's say we want to disable all union files, types ending with `Ok` or `Error`, the config would look like this: |
| 82 | + |
| 83 | + ```ts |
| 84 | + defineConfig({ |
| 85 | + resolverGeneration: { |
| 86 | + query: '*', |
| 87 | + mutation: '*', |
| 88 | + subscription: '*', |
| 89 | + scalar: '*', |
| 90 | + object: ['!*.*Ok', '!*.*Error'], // Disables objects ending with `Ok` or `Error` in every module |
| 91 | + union: '', // Empty string disables all file generation of relevant type in every module |
| 92 | + interface: '*', |
| 93 | + }, |
| 94 | + }); |
| 95 | + ``` |
| 96 | + |
| 97 | +- 00a80bc: Bump ts-morph to v22 which requires TypeScript 5.4 |
| 98 | + |
| 99 | +### Patch Changes |
| 100 | + |
| 101 | +- 6bf957d: Add colours to logs |
| 102 | +- de5599b: Move union and interface config from server config to server preset |
| 103 | + |
| 104 | + This config is fairly opinionated and may not make sense being on server config. However, it is definitely the default mode of operation we want to use for server preset to avoid having extra files, simplifying the setup. |
| 105 | + |
| 106 | +- Updated dependencies [de5599b] |
| 107 | + - @eddeee888/gcg-server-config@0.2.0 |
| 108 | + |
3 | 109 | ## 0.7.5
|
4 | 110 |
|
5 | 111 | ### Patch Changes
|
|
0 commit comments