Open MichalLytek opened 6 years ago
Will it generate typescript definition files like graphql-code-generator or apollo-codegen?
Typescript definition files of what? All the schema is defined by code, for all your client queries you can use apollo-codegen
.
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:
commander: A complete solution for node.js command-line interfaces.
inquirer: A collection of common interactive command line user interfaces.
ShellJS: Portable implementation of Unix shell
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?
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
Another idea : add the ability to export the graphql schema from classes.
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.
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.
There are two ways of how to make CLI works:
resolvers
and other options and could be automatically implicitly use by CLI and buildSchema
GraphQLSchema
They both have pros and cons so it might be better to implement them all, so users could choose which options fit them best 😉 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.
Are there any updates about this? I would like to give some help, maybe starting proposing a prototype
+1 interested in the crud mainly for the CRUD boilerplate
I am not very experienced with building CLIs but I'd be happy to help any way I can
I am thinking about creating a CLI tool - its features, capabilities and usefulness. Few ideas are in my head right now:
Basic:
init
command to create base configured app skeleton from boilerplate repoinit
command with more detailed config (folder per type/feature, etc.)Advanced:
schema.gql
file with SDL:speech_balloon: Other proposals: