pos-script-node is a Node based script to execution pOS graphQL statements locally by utilizing the pos-cli gui serve port. This also allows the developers to chain or invoke graphQL queries multiply times through scripting.
Install Node in your machine, to have NPM
Using NPM, install pos-kit CLI
Start your command-line tool (e.g. Terminal on a Mac, or Git Bash on Windows), and enter:
npm install -g @platform-os/pos-cli
If your Node.js is installed for all users you might need to use sudo to install NPM packages globally:
sudo npm install -g @platform-os/pos-cli
You have to get access to Partner Portal
pos-cli env add [environment] --email [your email] --url [your Instance URL]
Navigate to root directory of the project on the your command-line tool and install dependencies using the following command:
npm install
NOTE: Depending on how you setup your machine, you might need to use
sudoto perform this operation
Copy the content of the .env-sample and save it as .env. The content should be the same as below.
POS_DIRECTORY=path-to-pos-project-directory
ENVIRONMENT=staging
PORT=3333
PER_PAGE=20
SERVER_PORT=4700
- POS_DIRECTORY - the path to the pOS project or directory which contains the
.posor .marketplace-kitfile - ENVIRONMENT - the name of the pOS environment (instance) for the graphQL queries to be executed.
- PORT - the graphQL gui port to serve. (optional | default: 3333)
- PER_PAGE - the default per_page value when running the build-in
models.getfunction of the graphQL instance/class. (optional | default: 20) - SERVER_PORT - the port in which the public content will be loaded. Initially this contains the formatted
README.mdcontent. (optional | default: 4700)
Create and save the graphQL file(s) under app/graphql. Open index.js and modify the file unto the desired output and behaviour, use graphQL.execute to invoke graphQL statements.
NOTE: The content of the graphQL files (query statements) would be available on the script via GrahphQL class instance property
query(ex.graphQL.query.filename).
Navigate to root directory of the project on your command-line tool and enter the following command:
npm start