Mhret Aatifa

Mhret Aatifa

1609336200

A Domain-specific Language for Building GraphQL Servers in No Time

Introduction

What is Pragma?

Pragma is a language for building beautiful and extensible GraphQL APIs in no time. Within a single file, you can define your data models and authorization rules (roles and permissions), and import serverless functions for data validation, transformation, authorization, or any custom logic. With a single command, Pragma generates a fully functional API, ready to be consumed from your front-end application.

Who is Pragma for?

Pragma is for developers who want to build, iterate, and ship as fast as possible and focus on user-facing features instead of dealing with resolvers, endpoints, migrations, authentication, authorization, scaling, queries, and all the headache that comes with building and maintaining an API.

Pragma is a perfect fit for startups. In fact, the original motivation behind it was testing new ideas in hours or days instead of weeks or months. It is designed to help you move quickly.

Pragma helps you focus on your users and primary business/domain logic, deliver a lot faster (10-100x faster than traditional frameworks), iterate and try new ideas with minimal technical cost.

Pragma is great for building internal tools too. You don’t want to spend too much time building an internal tool, you just want it to work; Pragma is a great fit for such situations.

Pragma is for developers who want to materialize their ideas quickly, and share them with the world.

Pragma is for builders.

Tell People About This

Hyped? Tweet about this project and tell your followers how interesting this is.

You can also join our Discord server to meet other developers, get community support, and have fun!

Tweet Discord

Documentation

Visit the documentation to learn Pragma in a few minutes.

Install Pragma

Linux

Requirements

To make sure you have them and that they work, run:

docker run hello-world
docker-compose --help

If any of the above commands fail, make sure it works before proceeding with the installation of Pragma.

Installation

To install Pragma, run:

curl https://raw.githubusercontent.com/pragmalang/pragma/master/scripts/install-universal.sh | sh

The script will ask for root access, so make sure to enter your password when prompted.

If you’re on Ubuntu/Debian, you can download the .deb package from releases.

Run Pragma

Once Pragma is downloaded and installed, you can see if it works by running the following command:

pragma help

macOS

Requirements

To make sure you have them and that they work, run:

docker run hello-world
docker-compose --help
java -version

If any of the above commands fail, make sure it works before proceeding with the installation of Pragma.

Note: When installing Java, make sure to use the macOS Installer. The macOS version of Pragma is the only one that doesn’t come with a bundled Java runtime, due to the latest security features in macOS Catalina+. :::

Run Pragma

Once Pragma is downloaded and installed, you can see if it works by running the following command from the terminal:

pragma help

Windows

Requirements

To make sure you have them and that they work, run:

docker run hello-world
docker-compose --help

If any of the above commands fail, make sure it works before proceeding with the installation of Pragma.

Installation

First, we need to install the Pragma CLI:

Note: If Microsoft Defender tells you it prevented an unrecognized app from starting, click on “More info”, then click on “Run anyway”.

Run Pragma

Once Pragma is downloaded and installed, you can see if it works by running the following command from PowerShell:

pragma help

Getting Started

After Pragma has been successfully installed, visit this page of the documentation for a step-by-step tutorial on building a simple Todo application.

Community & Support

If you have any questions or feedback, you can join our Discord server or post to r/pragmalang. We would love to hear from you!

Contributing

Pragma is a Scala 2.13 project built using SBT. It’s divided into three subprojects:

  • core: where the domain abstractions and parsing logic is kept alongside any shared logic between other subprojects. All other subprojects depend on the core.
  • daemon: where the serving and project management logic lives. It needs instances for Postgres and Openwhisk to be running; it’s meant to be running alongside them in the background while using Pragma during development and in production.
  • cli: where the communication with the daemon and the loading of user files is done.

It’s highly recommended to be familiar with Cats and Cats Effect before starting to work on the daemon.

Setup

Pragma has been developed using VSCode with the Metals extension on Linux. For it all to work, it requires a JDK, Scala, SBT, and Ammonite for some scripts. Use this script to quickly install them:

curl -Lo cs https://git.io/coursier-cli-linux && chmod +x cs && ./cs setup

Docker and Docker Compose are also used for conveniently running Postgres and Openwhisk locally.

Testing

The recommended way to work on the daemon is to run it using SBT and run Postgres and Openwhisk from docker-compose.

To run Postgres and Openwhisk:

cd daemon/src/main/resources/ && docker-compose up

Make sure to run this before running sbt 'daemon/test'.

Running the daemon using sbt 'daemon/run' requires the following environment variables to be exported:

export DAEMON_HOSTNAME=localhost && \
export DAEMON_PORT=9584 && \
export DAEMON_PG_HOST='localhost' && \
export DAEMON_PG_PORT=5433 && \
export DAEMON_PG_DB_NAME='test' && \
export DAEMON_PG_USER='test'  && \
export DAEMON_WSK_API_URL='http://localhost:3233'  && \
export DAEMON_WSK_AUTH_TOKEN='23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP'  && \
export DAEMON_PG_PASSWORD='test'  && \
export DAEMON_WSK_API_VERSION=1

You can run the daemon alongside Postgres and Openwhisk with:

# In the root of the project
docker-compose up

NOTE: If the docker containers cannot be started it’s most likely because the port 5433 is already in use. Run docker ps and then run docker kill <postgres-containe-id> to kill the Postgres container to fix it.

Docker Build

Docker builds are performed using SBT Native Packager. To build the Pragma daemon Docker image:

sbt "daemon/docker:publishLocal"

CLI Packaging

NOTE: Generating the packages for each platform requires running the build on that very platform, in addition to some dependencies installed locally. See the requirements of each platform’s plugin.

These packages should NOT require a local JDK installation, or have any dependencies since the Jlink plugin is used.

To build Linux packages:

sbt 'cli/debian:packageBin; cli/rpm:packageBin'

To build Windows installer (.msi):

sbt 'cli/windows:packageBin'

To build MacOS .dmg:

sbt 'cli/universal:packageOsxDmg'

Apache Bench benchmark

Run the ammonite script in test/benchmark:

amm PragmaBench.sc

Make sure the daemon is running before running the benchmark (run docker-compose up in the root of the project).

NOTE: Apache Bench must be installed:

sudo apt install apache2-utils

Documentation

The user documentation lives in website/docs and is built using Docusaurus 2. It’s hosted on http://docs.pragmalang.com.

Download Details:

Author: pragmalang

Demo: https://pragmalang.com/

Source Code: https://github.com/pragmalang/pragma

#react-native #react #mobile-apps

What is GEEK

Buddha Community

A Domain-specific Language for Building GraphQL Servers in No Time
Eleo Nona

Eleo Nona

1600219097

How to Build Apollo GraphQL Server From Scratch

What is GraphQL

GraphQL is a query language and a server-side runtime that is used to request data from the server. The first thing that comes to mind when hearing the term “query language” is SQL. Just as SQL is used for querying databases, GraphQL is a bit like SQL but for querying web APIs as it eliminates the need to repeatedly develop or change existing end-points. GraphQL also enables the client/front-end to retrieve exactly the data they have requested and no more. This means that, within a single request of GraphQL, you can traverse from the entry point to the related data (whereas in RESTful API you have to call multiple endpoints to fetch similar results).

The following example will help you to understand this better. Let us consider an object person which has the attributes name, age, email, and contactNumber. Suppose the front-end only needs the name and age of the person. If we design a REST API, the endpoint will look like api/persons, which will end up fetching all the fields for the person object. The issue arises here because there is no easy way to communicate that I am interested in some fields and not others (which causes REST API to over fetch the data).

#graphql #nodejs #apollo-server #graphql-apollo-server

Delbert  Ferry

Delbert Ferry

1622279628

React + GraphQL Tutorial — The Server

Setting up
We’re going to use Express in this tutorial, because that’s what most people are currently using, but you should be able to follow along even if you’re using hapi or Koa, because the GraphQL part of this tutorial is largely identical.

For starters, let’s clone the tutorial GitHub repo, which has a few resources we’ll need later. If you’ve already done that in Part 1, you can skip this step.

#graphql #react #server #graphql server

Ray  Patel

Ray Patel

1625843760

Python Packages in SQL Server – Get Started with SQL Server Machine Learning Services

Introduction

When installing Machine Learning Services in SQL Server by default few Python Packages are installed. In this article, we will have a look on how to get those installed python package information.

Python Packages

When we choose Python as Machine Learning Service during installation, the following packages are installed in SQL Server,

  • revoscalepy – This Microsoft Python package is used for remote compute contexts, streaming, parallel execution of rx functions for data import and transformation, modeling, visualization, and analysis.
  • microsoftml – This is another Microsoft Python package which adds machine learning algorithms in Python.
  • Anaconda 4.2 – Anaconda is an opensource Python package

#machine learning #sql server #executing python in sql server #machine learning using python #machine learning with sql server #ml in sql server using python #python in sql server ml #python packages #python packages for machine learning services #sql server machine learning services

How to Install and Configure Chrony

It is essential to keep the correct time on a server. This is especially true when it comes to processing financial transactions or other vital functions which need to be handled in a specific order. Using the Network Time Protocol (or NTP), computers can synchronize their internal clock times with the internet standard reference clocks. In essence, NTP is a hierarchy of servers. The higher the Stratum number of a server, the more accurate the timing is and the lower the Stratum number of a server is, the lower the accuracy and time stability. Stratus are defined by the distance from the initial reference clock.

#tutorials #atomic clock #centos #chrony #clock #drift #internal time clock #network time protocol #ntp #offset #peers #pool.ntp.org #server time #stratum #system clock #time #time drift #timekeeping #ubuntu #utc

Eleo Nona

Eleo Nona

1592898402

How to Build a Simple GraphQL Server

With the zeitgeist of programming ever-changing, it can be difficult to determine what is a fad and what is going to last. One of the tools that has survived is GraphQL, an alternative to the standard RESTful route’s approach for queries and manipulating data. I decided to tackle the fundamentals of the open source project last week and I can see why it is so popular.

  • GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data.
  • GraphQL was developed internally by Facebook in 2012 before being publicly released in 2015.
  • GraphQL supports reading, writing (mutating), and subscribing to changes to data (realtime updates — most commonly implemented using WebHooks).

GraphQL provides an approach to developing web APIs and has been contrasted with REST architectural style. It allows clients to define the structure of the data required, and the same structure of the data is returned from the server, therefore preventing excessively large amounts of data from being returned.

#graphql #graphql server