Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Refactor package #117

Merged
merged 131 commits into from
Jul 17, 2017
Merged

WIP: Refactor package #117

merged 131 commits into from
Jul 17, 2017

Conversation

dotansimha
Copy link
Owner

@dotansimha dotansimha commented Jun 28, 2017

Progress: 99.999%

The goals are:

  • Move codegen core to a package and don't use fs
  • Move generators to separate package
  • Refactor directories structure and use Lerna to manage package's dependencies
  • Refactor GraphQL Schema template context builder and object
  • Handle fields and types in a better way (related to Mutation with only a string return. #96 and input types are not emitted (typescript, noSchema===true) #84) - my idea is to use expose the schema template context the same way GraphQL treat it's types (separate arrays for enum, type, input, union, interface, scalar)
  • Treat Query and Mutation just like any other type
  • Fix CI
  • Refactor operations builder with flatten feature
  • Reimplement typescript-single-file
  • Reimplement imports builder for multiple files
  • Reimplement typescript-multi-file
  • Move and refactor CLI util to a separate package (use fs only here)
  • Add support for input/output of a whole project (to generate apps)
  • Fix lerna dependencies
  • Add support for magic comments to easier integration in existing project (/*gqlgen {{#each types }} */
  • Move generators to separate packages with compilation package
  • Add support for directives (Add support for directives applied on IDL & Schema graphql/graphql-js#746)
  • Update README

After merging to master:

  • Reimplement flow-single-file
  • Reimplement swift-single-file
  • 100% code coverage for core & compiler packages
  • Blog post

Ideas:

  • Consider implementing the flatten types map in a better way - maybe just add a reference inside the template context to the actual type along the type name.

@dotansimha
Copy link
Owner Author

dotansimha commented Jun 28, 2017

@DxCx @zephraph @eitanfr @davidyaha any thoughts?

@dotansimha dotansimha changed the title Refactor package WIP: Refactor package Jun 28, 2017
@zephraph
Copy link
Contributor

Whew... this is a huge change. Okay, I'll comment as I can go through it...

@dotansimha
Copy link
Owner Author

dotansimha commented Jun 28, 2017

@zephraph my goal is to simplify the schema handler first.
I am almost done, and you can find it here: https://github.com/dotansimha/graphql-code-generator/blob/refactor/all/packages/graphql-codegen-core/src/schema/schema-to-template-context.ts
Also, I changed the schema template context object to be: https://github.com/dotansimha/graphql-code-generator/blob/refactor/all/packages/graphql-codegen-core/src/types.ts#L59-L72

This is much simpler implementation for the Schema handling, the difference is that I'm creating an array for each GraphQL base type (scalar/enum/type/input...), instead of a single array for all of them together.

I also separated it to 3 packages:

  • core (GraphQLSchema and operations string => template context object)
  • generators (combines template and template context, also in charge of converting primitives to language primitives, eg. String => string and Int to number in case of TS)
  • cli (Find, read, introspect and execute core with generators package)

@zephraph
Copy link
Contributor

It might be a good idea to generate a copy of dev-test from master (on all supported variations) and have a test just for comparing final generated outputs.

@dotansimha dotansimha merged commit 5f66a99 into master Jul 17, 2017
@dotansimha dotansimha deleted the refactor/all branch July 17, 2017 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants