What's new in GraphQL CLI 4.1

Enda Phelan
What's new in GraphQL CLI 4.1 - The Guild Blog
Looking for experts? We offer consulting and trainings.
Explore our services and get in touch.

GraphQL CLI is your one-stop shop for developing full-stack GraphQL applications in Node.js. With GraphQL CLI you can create and run a new GraphQL application in just a few seconds! Just declare your GraphQL schema and you can perform code generation, schema validation, introspection and more through intuitive CLI commands.

GraphQL CLI aggregates multiple community projects giving developers the best getting started experience. Tools included in the CLI are mature and developed over the years based on Guild's experience in pushing production ready GraphQL solutions and also through collaboration with Red Hat community projects.

This post covers a number of enhancements added in GraphQL CLI 4.1, which will further improve your GraphQL development experience. Check out our previous post GraphQL CLI is back! for a full overview of the library and its features.

Graphback

All the templates are configured with Graphback, for both runtime and generation purposes. Graphback 1.0 has recently been released, check out their blog post Announcing the Release of Graphback 1.0 that goes into deeper details of Graphback’s features and capabilities.

To generate your schema and documents with Graphback, run graphql generate from your application root. See the generate command docs for a thorough explanation of this command and usage guides.

Serve command

The serve command is now powered by graphql-serve, letting you start up an in-memory GraphQL server and playground in seconds - perfect for mocking and testing!

$ graphql serve --port 4000 ./model/datamodel.graphql

Starting server...

Listening at: http://localhost:4000/graphql

Check out the serve command docs for installation and usage guides!

Init command templates

The init command is your gateway to creating your new GraphQL application with GraphQL CLI. You will be guided through some questions and after a few seconds a tailor-made starter application will be created!

There are several improvements to all of our templates to make them cleaner and more production-ready. Additionally, we had added two new starter templates: a plain MongoDB template and a MongoDB template with out-of-the-box data synchronization support.

To start using these templates, use the init command:

graphql init

Other updates

We’ve built a new website to host the GraphQL CLI documentation! Check it out at graphql-cli.com.

GraphQL CLI 4.1 has been updated to use the latest versions of GraphQL Code Generator and GraphQL Inspector, which are included as recommended, best practice workflows for developing production-ready GraphQL applications.

Try it out

Start using GraphQL CLI today to create your GraphQL application in just a few steps!

The easiest way to get started is to initialize your new application with npx:

npx graphql-cli init

GraphQL CLI will guide you through some steps and in a few seconds your project will created and ready to use. Happy coding!

As always, we want your feedback! We would love to hear your suggestions and ideas to help make GraphQL CLI even better. Reach out to us through GitHub or join our Discord community server.