piral-urql
Advanced tools
Comparing version 0.10.0-pre.846 to 0.10.0-pre.853
{ | ||
"name": "piral-urql", | ||
"version": "0.10.0-pre.846", | ||
"version": "0.10.0-pre.853", | ||
"description": "Plugin for providing a GraphQL client in Piral.", | ||
@@ -42,3 +42,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"piral-core": "^0.10.0-pre.846" | ||
"piral-core": "^0.10.0-pre.853" | ||
}, | ||
@@ -55,3 +55,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "bf161f59f5b0b218f7443a4cf61534edd2aef929" | ||
"gitHead": "840155ef91a8f43f65ded5e18985ad25074bdc63" | ||
} |
@@ -27,4 +27,67 @@ [![Piral Logo](https://github.com/smapiot/piral/raw/master/docs/assets/logo.png)](https://piral.io) | ||
## Usage | ||
> For authors of pilets | ||
You can use the `query` function from the Pilet API to execute a GraphQL query against the defined GraphQL server. | ||
Example use: | ||
```ts | ||
import { PiletApi } from '<name-of-piral-instance>'; | ||
export function setup(piral: PiletApi) { | ||
const gql = `query { | ||
myResource(id: "example") { | ||
name | ||
age | ||
whatever | ||
} | ||
}`; | ||
const promise = piral.query(gql).then(({ name, age, whatever }) => {}); | ||
} | ||
``` | ||
You can use the `mutate` function from the Pilet API to run a GraphQL mutation against the defined GraphQL server. | ||
Example use: | ||
```ts | ||
import { PiletApi } from '<name-of-piral-instance>'; | ||
export function setup(piral: PiletApi) { | ||
const gql = `mutation { | ||
changeMyResource(id: "example", name: "foo") { | ||
name | ||
age | ||
whatever | ||
} | ||
}`; | ||
const promise = piral.mutate(gql).then(({ name, age, whatever }) => {}); | ||
} | ||
``` | ||
You can use the `subscribe` function from the Pilet API to create a GraphQL subscription to the defined GraphQL server. | ||
Example use: | ||
```ts | ||
import { PiletApi } from '<name-of-piral-instance>'; | ||
export function setup(piral: PiletApi) { | ||
const gql = `subscription { | ||
onMyResourceChange(id: "example") { | ||
name | ||
age | ||
whatever | ||
} | ||
}`; | ||
const unsubscribe = piral.subscribe(gql, ({ name, age, whatever }) => {}); | ||
} | ||
``` | ||
## Setup and Bootstrapping | ||
> For Piral instance developers | ||
The provided library only brings API extensions for pilets to a Piral instance. | ||
@@ -31,0 +94,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23278
133