Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set up some nice default queries in hrea-graphql-explorer #314

Merged
merged 5 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 93 additions & 10 deletions apps/holorea-graphql-explorer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,112 @@ import bindSchema, { autoConnect, VfModule } from '@valueflows/vf-graphql-holoch
import 'graphiql/graphiql.css'
import './App.css'

const DEFAULT_QUERY = `mutation CreateEconomicEvent {
/*
These defaults, by running them one-by-one from top to bottom
are intended to help the user familiarize, and overcome the
basic syntactical issues people can have when new to graphql
and the specific data formats of hREA.
*/
const DEFAULT_QUERIES = `

# Welcome to the hREA developer console!
#
# If you're new here, there are a few things to do to get you set up.
#
# These queries will run you through a few steps to setup a new
# REA Agent profile and log a test 'economic event' to setup an
# inventory for yourself.

# Step 1: create a new profile for yourself.
# You can edit it later with \`updatePerson\`.

mutation CreatePerson {
createPerson(person: { name: "place your name here" }) {
agent {
id
name
}
}
}

# Step 2: associate the profile with your current access token.
# Use the \`id\` returned from the previous query.

mutation AssociateMyAgent {
associateMyAgent(agentId: "place agent.id here")
}

# Step 3: log a new \`EconomicEvent\` to start tracking some inventory.
# Use the same Agent ID above for both \`provider\` and \`receiver\`,
# incidating that you initialised the inventory yourself.
# With the given parameters you will end up with
# an inventory for "apples" (defined in http://www.productontology.org/doc/Apple)
# that accounts for a total of 1 apple.

mutation CreateEconomicEvent {
createEconomicEvent(
event: {
action: "raise",
provider: "uhCEkW1Yp9ImB3k9vCf27YLZwD2ntahNcWZTgVNaLkDqO-V2n8v0w:uhC0k3kvf-gM4lFwZMY9fCxyMmmwVTHNAwZfKqR-Gfk2SJtjNSe-h",
receiver: "uhCEkW1Yp9ImB3k9vCf27YLZwD2ntahNcWZTgVNaLkDqO-V2n8v0w:uhC0k3kvf-gM4lFwZMY9fCxyMmmwVTHNAwZfKqR-Gfk2SJtjNSe-h",
resourceClassifiedAs: "https://fish",
resourceQuantity: {hasNumericalValue: 1},
hasPointInTime: "2022-06-09T18:51:57.105Z"}
action: "raise"
provider: "place agent.id"
receiver: "place agent.id here also"
resourceClassifiedAs: "pto:Apple"
resourceQuantity: { hasNumericalValue: 1 }
hasPointInTime: "2022-06-09T18:51:57.105Z"
}
newInventoriedResource: {
name: "My apples"
}
) {
economicEvent {
id
action {
id
}
id
resourceClassifiedAs
resourceQuantity {
hasNumericalValue
}
hasPointInTime
}
economicResource {
id
name
classifiedAs
accountingQuantity {
hasNumericalValue
}
onhandQuantity {
hasNumericalValue
}
}
}
}`
}

# Now that you have created all these records, you should be able to
# retrieve them

query GetMyAGent {
myAgent {
id
name
economicEventsAsProvider {
edges {
node {
id
resourceQuantity {
hasNumericalValue
}
resourceClassifiedAs
action {
label
}
}
}
}
# TODO: include inventoried EconomicResources
}
}
`

interface Props {}

Expand All @@ -51,7 +134,7 @@ class App extends Component<Props, State> {
schema: undefined,
link: undefined,
fetcher: undefined,
query: DEFAULT_QUERY,
query: DEFAULT_QUERIES,
explorerIsOpen: false
}

Expand Down
1 change: 0 additions & 1 deletion modules/vf-graphql-holochain/.nvmrc

This file was deleted.

2 changes: 1 addition & 1 deletion modules/vf-graphql-holochain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"buffer": "^6.0.3",
"@graphql-tools/schema": "^8.3.1",
"@graphql-tools/utils": "^8.6.1",
"@holochain/client": "0.4.0",
"@holochain/client": "0.4.3",
"@valueflows/vf-graphql": "0.9.0-alpha.6",
"dataloader": "^1.4.0",
"deep-for-each": "^3.0.0",
Expand Down
Loading