MichalLytek / type-graphql

Create GraphQL schema and resolvers with TypeScript, using classes and decorators!
https://typegraphql.com
MIT License
8.03k stars 676 forks source link

CLI tool #66

Open MichalLytek opened 6 years ago

MichalLytek commented 6 years ago

I am thinking about creating a CLI tool - its features, capabilities and usefulness. Few ideas are in my head right now:

Basic:

Advanced:

:speech_balloon: Other proposals:

laukaichung commented 6 years ago

Will it generate typescript definition files like graphql-code-generator or apollo-codegen?

MichalLytek commented 6 years ago

Typescript definition files of what? All the schema is defined by code, for all your client queries you can use apollo-codegen.

useless-stuff commented 6 years ago

Hello! type-graphql it's exactly what I was looking for, nice project! :) A couple of days ago I've started a project for managing AWS AppSync with Serverless and Typescript. I'd like to use type-graphl as core package for managing code and I'd like to be involved in your project :)

I've invested a bit of time to figure out which libraries and tools people are using out there in order to create a solid and cross-platform CLI.

Basically, this is the packages stack:

If you think that I can help somehow, just let me know I'll be happy to work on the CLI or other stuff.

You can find a very basic example that I did last night:

https://github.com/useless-stuff/lakitu/blob/feature/cli/src/lakitu.js

Do you have any Slack channel for this project?

MichalLytek commented 6 years ago

Thanks for the research about tools for creating the CLI 😉 I will definitely take a look at them when I start working on this, for now I have to think and collect CLI feature ideas.

There is gitter for questions and discussions not related to issues, mostly due to nice github integration: https://gitter.im/type-graphql

omatrot commented 6 years ago

Another idea : add the ability to export the graphql schema from classes.

MichalLytek commented 6 years ago

Right, it might be an option. It's just calling printSchema from graphql after buildSchema from type-graphql but it would impose specific folder/files project structure.

kn0ll commented 6 years ago

i saw similar comments in https://github.com/19majkel94/type-graphql/issues/81- regarding printSchema.

i think a decent solution might be to expose the printSchema example you provided as a command line tool-- except allow it to accept a module path and output locations as arguments (and that module path would resolve to a schema). something like (pseudocode... not thinking too hard...)

// createSchema.ts (created by user)
export function createSchema() {
  return buildSchema({
    // ...
  }
}

// print-graphql-schema.ts (exposed as type-graphql command line tool)
const createSchema = require(process.argv[0]);

(async () => {
  const schema = await createSchema();
  const sdl = printSchema(schema);
  // or stdout...
  await fs.writeFile(process.argv[1], sdl);
})();

// then i can do...
$ print-graphql-schema ./createSchema.ts ./graphql.schema

i suppose you could argue that despite it's size this could still really just be it's own separate NPM module-- but it does seem like something most users of type-graphql will require (assuming they are writing their own clients).

if you're interested in a PR it's straight forward / isolated enough that i'd be comfortable giving it a shot.

MichalLytek commented 6 years ago

There are two ways of how to make CLI works:

Thanks for your suggestion, I will take it into account in the future when the base CLI core will be ready - I will provide some docs how to add custom plugins/commands in own project or as a PR to the main repository.

ematipico commented 5 years ago

Are there any updates about this? I would like to give some help, maybe starting proposing a prototype

fullofcaffeine commented 4 years ago

+1 interested in the crud mainly for the CRUD boilerplate

sebasalines commented 3 years ago

I am not very experienced with building CLIs but I'd be happy to help any way I can