Skip to content

Commit

Permalink
cli, common, service: include protocol network for cost model creation
Browse files Browse the repository at this point in the history
  • Loading branch information
saihaj committed Feb 13, 2024
1 parent d682744 commit f571b80
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/indexer-cli/src/commands/indexer/cost/set/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fs from 'fs'

import { loadValidatedConfig } from '../../../../config'
import { createIndexerManagementClient } from '../../../../client'
import { fixParameters } from '../../../../command-helpers'
import { extractProtocolNetworkOption, fixParameters } from '../../../../command-helpers'
import {
parseCostModel,
parseDeploymentID,
Expand All @@ -18,7 +18,7 @@ ${chalk.bold('graph indexer cost set model')} [options] <deployment-id> <file>
${chalk.bold('graph indexer cost set model')} [options] global <file>
${chalk.dim('Options:')}
-n, --network Protocol network
-h, --help Show usage information
-o, --output table|json|yaml Choose the output format: table (default), JSON, or YAML
`
Expand All @@ -31,6 +31,13 @@ module.exports = {
const { print, parameters } = toolbox

const { h, help, merged, o, output } = parameters.options

const protocolNetwork = extractProtocolNetworkOption(parameters.options, true)

if (!protocolNetwork) {
throw new Error('Protocol network is required')
}

const [deployment, filename] = fixParameters(parameters, { h, help, merged }) || []
const outputFormat = o || output || 'table'

Expand Down Expand Up @@ -69,6 +76,7 @@ module.exports = {
deployment,
model,
variables: null,
protocolNetwork,
})

try {
Expand Down
4 changes: 4 additions & 0 deletions packages/indexer-cli/src/cost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export const costModels = async (
deployment
model
variables
protocolNetwork
}
}
`)
Expand All @@ -228,6 +229,7 @@ export const costModel = async (
deployment
model
variables
protocolNetwork
}
}
`,
Expand Down Expand Up @@ -258,6 +260,7 @@ export const setCostModel = async (
deployment
model
variables
protocolNetwork
}
}
`,
Expand All @@ -284,6 +287,7 @@ export const deleteCostModels = async (
deployment
model
variables
protocolNetwork
}
}
`,
Expand Down
2 changes: 2 additions & 0 deletions packages/indexer-common/src/indexer-management/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,14 @@ const SCHEMA_SDL = gql`
deployment: String!
model: String
variables: String
protocolNetwork: String!
}
input CostModelInput {
deployment: String!
model: String
variables: String
protocolNetwork: String!
}
type Query {
Expand Down
3 changes: 3 additions & 0 deletions packages/indexer-service/src/server/cost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const createCostServer = async ({
deployment: String!
model: String
variables: String
protocolNetwork: String!
}
type Query {
Expand Down Expand Up @@ -126,6 +127,7 @@ export const createCostServer = async ({
deployment
model
variables
protocolNetwork
}
}
`,
Expand Down Expand Up @@ -172,6 +174,7 @@ export const createCostServer = async ({
deployment
model
variables
protocolNetwork
}
}
`,
Expand Down

0 comments on commit f571b80

Please sign in to comment.