Introduction
What is Pragma?
Pragma is a language for building GraphQL APIs in no time, by defining data models and their associated validation, transformation, and authorization logic.
For example, you can create a Pragmafile
with the following content:
Pragma supports importing serverless functions for extending the API's functionality. In this case, hooks.js
is a JavaScript file containing:
These two functions are used to validate every user object and set its fullName
field on every CREATE
, UPDATE
, and MUTATE
operation.
Pragma has built-in support for authorization, meaning you can define access rules to specify the actions each kind of user can perform, and when.
This is all the code you need to write in order to set up a GraphQL API with user authentication and very flexible queries and mutations for creating, reading, updating, and deleting user data. For example:
This mutation returns the username
and fullName
of the newly created user. See The Generated API section for more details.
For a step-by-step tutorial on Pragma, see the Basic Todo App page.
Why Pragma?
It Saves Your Time
Pragma doesn't make you worry about networking, writing resolvers, or (when using the Pragma Cloud) deployment. It offers what we believe is the best server-side application development experience.
It's Declarative
Definitions are concise, readable, high-level, and maintainable. It keeps configuration and boilerplate you need to write and keep in mind at a minimum (no code generation, all the complexity is abstracted). You focus on your business logic and nothing else.
A simple todo app with user authentication and permissions can be expressed in under 30 lines of code.
It Integrates with Many Languages
You can define the functions used for data processing in many languages, including JavaScript (NodeJS), Go, Java, Scala, PHP, Python, Ruby, Swift, Ballerina, .NET and Rust, and seamlessly compose them using directives. This is due to Pragma being built on top of Apache Openwhisk.
It Runs Locally
You can easily install Pragma on you laptop and start development within seconds. The only two requirements for running Pragma are Docker and Docker Compose. See the Install Pragma page chapter.
One your application is ready for deployment, you can deploy it to your own servers, or any cloud platform that supports Pragma.
No Vendor Lock-In
Pragma applications are extremely easy to move from any cloud provider to another, as long as they have a Kubernetes offering.