Closed YutaUra closed 10 months ago
Latest commit: c1d9e7387cb08632e6a3f7dc49d8f0ef8dadd8a9
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Thanks @YutaUra ! It's looking pretty good already!
I feel that the processing, especially around isScalar, is not beautiful. If you have any good ideas, I would be glad to hear them.
This could be an issue with the current setup. Let me take a closer look. I'll get back to you soon.
(Also, sorry for the conflicts 🙇♂️ However, most of them are in e2e so they can be merged and regenned )
I feel that the processing, especially around isScalar, is not beautiful. If you have any good ideas, I would be glad to hear them.
Currently, when we prepare "virtual" files, we are marking each type with __filetype
which could one one of the following values:
file
: a general file that we create. Example: resolvers.generated.ts
filesobjectType
: a file that contains a GraphQL object type e.g. Book
, User
rootObjectTypeFieldResolver
: a file that contains root object field resolvers e.g. Query.user
, Mutation.deleteBook
, etc.generalResolver
: a file that contains all other resolvers e.g. GraphQL Interfaces, GraphQL Union, GraphQL Scalars.If we want to treat GraphQL Scalars in a different way (like this situation), we would have to do the following:
Separate a new type for Scalar here. It may look like this:
export interface ScalarTypeFile extends BaseVirtualFile {
__filetype: 'scalarType';
meta: {
moduleName: string;
variableStatement: string;
normalizedResolverName: string;
};
}
Add scalarTypes
to this FileDetails
Create an if
block here that checks file.__filetype === 'sclarType'
and add import line and push scalar to the type
Handle scalar around here, like what you are already doing 🙂
see: https://github.com/eddeee888/graphql-code-generator-plugins/pull/168
:memo:
Fix to spread and place Main Type resolvers to apply individual resolvers other than RootObjectType in the future.
It's hard to touch the AST 😓 :)
I feel that the processing, especially around isScalar, is not beautiful. If you have any good ideas, I would be glad to hear them.