graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

[WIP] Small Fixes: typescript-oclif plugin

Open kalzoo opened this issue 4 years ago • 6 comments

Hey team! 👋

I wrote the oclif plugin back in October and it was merged in March 2020, which surprised me since I still had some pending questions on the MR. Happily, it all works, and you all have done good work keeping it integrated with all of your changes! There are a couple loose ends IMO worth tying off.

Of the questions in that PR, I'm still most interested in the one about the import paths (question # 2). Presets receive information about where they are in the generated-file tree, but plugins do not appear to (or didn't at the time). This means that this plugin is fragile, and we can't have a file structure like this out-of-the-box:

src/commands/hello.ts
src/commands/foo/bar.ts

# ... with handler ...
src/handler.ts

^ Since the plugin doesn't know how deep it is in the tree, it doesn't know whether to import '../../handler' or import '../handler'. We can use a tsconfig.json baseUrl to work around this issue, or put handler.ts export files everywhere in the tree, but is it possible for a plugin to know its relative file path to the root? If it's not a simple change or lookup, I'll just add a line to the docs about using baseUrl (that's what the MR "WIP" is for), although that may not work in all situations.

This also includes some other housekeeping:

  • Remove development comments related to the above ^
  • Remove the default value for handlerPath and require it to be set deliberately. While this is a breaking change, I expect that this is specified in most consuming projects since it's in the docs and example. Setting the default as ../../handler assumes that users will be generating a two-level, "multi"-form CLI, which is not necessarily the expected or common case.
  • A fix in the docs

kalzoo avatar Jul 13 '20 04:07 kalzoo

Hi @kalzoo ! The initial oclif PR was great, and the changes here seems to make it simpler to use. Thank you! Can you please check CI? it seems to break.

dotansimha avatar Jul 13 '20 08:07 dotansimha

@kalzoo let me know when this PR is ready for review ;)

dotansimha avatar Jul 21 '20 14:07 dotansimha

Hey @dotansimha , it's ready (for review, not merge), just been hoping for input on that question 🙂

kalzoo avatar Aug 02 '20 20:08 kalzoo

@kalzoo I know long time has passes, but I don't see any reason not to merge it. You are the owner of the plugin, so I completely trust you on this one. Let me know if you want to get this merged and released.

dotansimha avatar Dec 23 '20 14:12 dotansimha

@kalzoo Is there anything we can help to get this merged?

ardatan avatar Feb 10 '21 12:02 ardatan

Yes, I need answers to the questions I posed here and in the original PR. These are not questions about my plugin, they're about the interaction of the plugin with the framework, and how to get the behavior one sees in a preset. I haven't looked at this recently and so I can't say if plugins have more capabilities/information than they did at the time I made this PR, but at that time it wasn't possible for a near-operation-file-invoked plugin to know the depth to use for its import paths.

kalzoo avatar Feb 10 '21 22:02 kalzoo

Hi!

All community plugins (see list below) have been moved to a new dotansimha/graphql-code-generator-community.

Community plugins:
  • @graphql-codegen/typescript-react-apollo
  • @graphql-codegen/typescript-graphql-request
  • @graphql-codegen/typescript-apollo-angular
  • @graphql-codegen/typescript-apollo-client-helpers
  • @graphql-codegen/typescript-react-query
  • @graphql-codegen/typescript-urql
  • @graphql-codegen/named-operations-object
  • @graphql-codegen/urql-introspection
  • @graphql-codegen/flow-resolvers
  • @graphql-codegen/typescript-vue-apollo
  • @graphql-codegen/typescript-rtk-query
  • @graphql-codegen/flow-operations
  • @graphql-codegen/typescript-msw
  • @graphql-codegen/typescript-mongodb
  • @graphql-codegen/typescript-type-graphql
  • @graphql-codegen/jsdoc
  • @graphql-codegen/typescript-vue-urql
  • @graphql-codegen/kotlin
  • @graphql-codegen/typescript-vue-apollo-smart-ops
  • @graphql-codegen/java
  • @graphql-codegen/c-sharp-operations
  • @graphql-codegen/hasura-allow-list
  • @graphql-codegen/typescript-stencil-apollo
  • @graphql-codegen/relay-operation-optimizer
  • @graphql-codegen/typescript-oclif
  • @graphql-codegen/java-resolvers
  • @graphql-codegen/java-apollo-android
  • @graphql-codegen/flutter-freezed

Please move your PR by following these steps:

From your current PR branch:

  • Fork the https://github.com/dotansimha/graphql-code-generator-community repository
  • git remote add codegen-community <GIT_URL_OF_YOUR_COMMUNITY_REPO_FORK>
  • git fetch codegen-community
  • git push codegen-community

Open the PR on dotansimha/graphql-code-generator-community and close this PR.

Thank you!

charlypoly avatar Nov 07 '22 10:11 charlypoly

thanks for the great work here @kalzoo we have moved this plugin to community repo so let's move it there and then we can consider publishing a canary for you test with https://github.com/dotansimha/graphql-code-generator/pull/4357#issuecomment-1305396802

saihaj avatar Jan 30 '23 18:01 saihaj