Skip to content

Commit

Permalink
Update README.md (#135)
Browse files Browse the repository at this point in the history
Co-authored-by: Will <[email protected]>
  • Loading branch information
tovbinm and willmarks committed May 1, 2023
1 parent 21ad82c commit 51a3d9a
Showing 1 changed file with 40 additions and 33 deletions.
73 changes: 40 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,46 @@ The QueryBuilder class is a utility to help construct GraphQL mutations from Far
Example constructing the GraphQL mutation that upserts an application and deployment.

```ts
// The QueryBuilder manages origin for you
const qb = new QueryBuilder(ORIGIN);

const application: MutationParams = {
model: 'compute_Application',
key: {
name: '<application_name>',
platform: '<application_platform>',
},
};
const deployment: MutationParams = {
model: 'cicd_Deployment',
key: {
uid: '<deployment_uid',
source: '<deployment_source>',
},
body: {
// Fields that reference another model need to be refs
application: qb.ref(application),
status: {
category: 'Success',
detail: '<status_detail>',
},
},
};

const mutations = [
qb.upsert(application),
qb.upsert(deployment)
];

// Send your mutations to Faros!
await client.sendMutations(mutations);
import {QueryBuilder, FarosClient} from "faros-js-client";

const faros = new FarosClient({
url: 'https://prod.api.faros.ai',
apiKey: '<your_faros_api_key>',
});

// The QueryBuilder manages the origin for you
const qb = new QueryBuilder('example-origin');

const application = {
model: 'compute_Application',
key: {
name: '<application_name>',
platform: '<application_platform>',
},
};
const deployment = {
model: 'cicd_Deployment',
key: {
uid: '<deployment_uid',
source: '<deployment_source>',
},
body: {
// Fields that reference another model need to be refs
application: qb.ref(application),
status: {
category: 'Success',
detail: '<status_detail>',
},
},
};

const mutations = [
qb.upsert(application),
qb.upsert(deployment)
];

// Send your mutations to Faros!
await faros.sendMutations('default', mutations);
```

Please read the [Faros documentation][farosdocs] to learn more.
Expand Down

0 comments on commit 51a3d9a

Please sign in to comment.