forked from graphprotocol/graph-tooling
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sunset of hosted (graphprotocol#1680)
* sunset of hosted * format * update snapshot * Fix missing refs * Update `init` snapshot * Remove hosted service from readme, add more relevant information * Fix lint --------- Co-authored-by: Etienne Donneger <[email protected]> Co-authored-by: YaroShkvorets <[email protected]>
- Loading branch information
1 parent
bf43cbf
commit 08914a8
Showing
9 changed files
with
53 additions
and
606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
'@graphprotocol/graph-cli': minor | ||
--- | ||
|
||
Breaking changes to the CLI to prepare for the sunset of the hosted service. | ||
|
||
- `graph auth` | ||
- Removed `--product` flag | ||
- Removed `--studio` flag | ||
- Removed `node` argument | ||
- `graph deploy` | ||
- Removed `--product` flag | ||
- Removed `--studio` flag | ||
- Removed `--from-hosted-service` flag | ||
- `graph init` | ||
- Removed `--product` flag | ||
- Removed `--studio` flag | ||
- Removed `--allow-simple-name` flag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,22 @@ | ||
import { URL } from 'url'; | ||
import { print } from 'gluegun'; | ||
import { GRAPH_CLI_SHARED_HEADERS } from '../constants'; | ||
|
||
export const SUBGRAPH_STUDIO_URL = 'https://api.studio.thegraph.com/deploy/'; | ||
const HOSTED_SERVICE_URL = 'https://api.thegraph.com/deploy/'; | ||
const HOSTED_SERVICE_INDEX_NODE_URL = 'https://api.thegraph.com/index-node/graphql'; | ||
|
||
export const validateNodeUrl = (node: string) => new URL(node); | ||
|
||
export const normalizeNodeUrl = (node: string) => new URL(node).toString(); | ||
|
||
export function chooseNodeUrl({ | ||
product, | ||
studio, | ||
node, | ||
allowSimpleName, | ||
}: { | ||
product: string | undefined; | ||
studio: boolean | undefined; | ||
node?: string; | ||
allowSimpleName?: boolean; | ||
}) { | ||
export function chooseNodeUrl({ node }: { node?: string }) { | ||
if (node) { | ||
try { | ||
validateNodeUrl(node); | ||
return { node }; | ||
} catch (e) { | ||
print.error(`Graph node "${node}" is invalid: ${e.message}`); | ||
process.exit(1); | ||
} | ||
} else { | ||
if (studio) { | ||
product = 'subgraph-studio'; | ||
} | ||
switch (product) { | ||
case 'subgraph-studio': | ||
node = SUBGRAPH_STUDIO_URL; | ||
break; | ||
case 'hosted-service': | ||
node = HOSTED_SERVICE_URL; | ||
break; | ||
} | ||
} | ||
if (node?.match(/studio/) || product === 'subgraph-studio') { | ||
allowSimpleName = true; | ||
} | ||
return { node, allowSimpleName }; | ||
} | ||
|
||
export async function getHostedServiceSubgraphId({ | ||
subgraphName, | ||
}: { | ||
subgraphName: string; | ||
}): Promise<{ | ||
subgraph: string; | ||
synced: boolean; | ||
health: 'healthy' | 'unhealthy' | 'failed'; | ||
}> { | ||
const response = await fetch(HOSTED_SERVICE_INDEX_NODE_URL, { | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
query: /* GraphQL */ ` | ||
query GraphCli_getSubgraphId($subgraphName: String!) { | ||
indexingStatusForCurrentVersion(subgraphName: $subgraphName) { | ||
subgraph | ||
synced | ||
health | ||
} | ||
} | ||
`, | ||
variables: { | ||
subgraphName, | ||
}, | ||
}), | ||
headers: { | ||
'content-type': 'application/json', | ||
...GRAPH_CLI_SHARED_HEADERS, | ||
}, | ||
}); | ||
|
||
const { data, errors } = await response.json(); | ||
|
||
if (errors) { | ||
throw new Error(errors[0].message); | ||
} | ||
|
||
if (!data.indexingStatusForCurrentVersion) { | ||
throw new Error(`Subgraph "${subgraphName}" not found on the hosted service`); | ||
} | ||
|
||
return data.indexingStatusForCurrentVersion; | ||
return { node: SUBGRAPH_STUDIO_URL }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.