@graphprotocol/graph-cli 0.52.1-alpha-20230719201219-dde01c9 → 0.53.0-alpha-20230721154144-34030b5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -2
- package/dist/codegen/schema.js +11 -1
- package/dist/codegen/schema.test.js +8 -18
- package/dist/commands/deploy.js +9 -4
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# @graphprotocol/graph-cli
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.53.0-alpha-20230721154144-34030b5
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1406](https://github.com/graphprotocol/graph-tooling/pull/1406)
|
|
8
|
+
[`34030b5`](https://github.com/graphprotocol/graph-tooling/commit/34030b5808f0f3996d8ea2133eedf19a0b3d9548)
|
|
9
|
+
Thanks [@incrypto32](https://github.com/incrypto32)! - Fix derived loaders not working failing for
|
|
10
|
+
entities with Bytes as ID's
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
6
13
|
|
|
@@ -9,8 +16,13 @@
|
|
|
9
16
|
Thanks [@saihaj](https://github.com/saihaj)! - only update `network.json` file during `graph add`
|
|
10
17
|
if it exists
|
|
11
18
|
|
|
19
|
+
- [#1402](https://github.com/graphprotocol/graph-tooling/pull/1402)
|
|
20
|
+
[`f0ce6c0`](https://github.com/graphprotocol/graph-tooling/commit/f0ce6c00e8adab94847ee3f9fde187513583b86c)
|
|
21
|
+
Thanks [@saihaj](https://github.com/saihaj)! - show a descriptive error message and do not hang if
|
|
22
|
+
there is a deploy key issue
|
|
23
|
+
|
|
12
24
|
- [#1403](https://github.com/graphprotocol/graph-tooling/pull/1403)
|
|
13
|
-
[`
|
|
25
|
+
[`dfa9ee1`](https://github.com/graphprotocol/graph-tooling/commit/dfa9ee1184bb1af499289baa92eb8c3b3cf37f85)
|
|
14
26
|
Thanks [@saihaj](https://github.com/saihaj)! - do not ask for local path when trying to add more
|
|
15
27
|
contracts during init
|
|
16
28
|
|
package/dist/codegen/schema.js
CHANGED
|
@@ -244,8 +244,18 @@ class SchemaCodeGenerator {
|
|
|
244
244
|
const name = fieldDef.name.value;
|
|
245
245
|
const gqlType = fieldDef.type;
|
|
246
246
|
const returnType = this._returnTypeForDervied(gqlType);
|
|
247
|
+
const obj = this.schema.ast.definitions.find(def => {
|
|
248
|
+
if (def.kind == 'ObjectTypeDefinition') {
|
|
249
|
+
const defobj = def;
|
|
250
|
+
return defobj.name.value == this._baseType(gqlType);
|
|
251
|
+
}
|
|
252
|
+
return false;
|
|
253
|
+
});
|
|
254
|
+
const idf = IdField.fromTypeDef(obj);
|
|
255
|
+
const idIsBytes = idf.typeName() == 'Bytes';
|
|
256
|
+
const toValueString = idIsBytes ? '.toBytes().toHexString()' : '.toString()';
|
|
247
257
|
return tsCodegen.method(`get ${name}`, [], returnType, `
|
|
248
|
-
return new ${returnType}('${entityName}', this.get('id')
|
|
258
|
+
return new ${returnType}('${entityName}', this.get('id')!${toValueString}, '${name}')
|
|
249
259
|
`);
|
|
250
260
|
}
|
|
251
261
|
_returnTypeForDervied(gqlType) {
|
|
@@ -428,11 +428,12 @@ describe('Schema code generator', () => {
|
|
|
428
428
|
type Worker implements Employee @entity {
|
|
429
429
|
id: Bytes!
|
|
430
430
|
name: String!
|
|
431
|
+
tasks: [Task!]
|
|
431
432
|
}
|
|
432
433
|
|
|
433
434
|
type Task @entity {
|
|
434
435
|
id: Bytes!
|
|
435
|
-
|
|
436
|
+
employees: [Worker!] @derivedFrom(field: "tasks")
|
|
436
437
|
worker: Worker!
|
|
437
438
|
}
|
|
438
439
|
`);
|
|
@@ -496,23 +497,6 @@ describe('Schema code generator', () => {
|
|
|
496
497
|
returnType: undefined,
|
|
497
498
|
body: "\n this.set('id', Value.fromBytes(value))\n ",
|
|
498
499
|
},
|
|
499
|
-
{
|
|
500
|
-
name: 'get employee',
|
|
501
|
-
params: [],
|
|
502
|
-
returnType: new typescript_1.NamedType('Bytes'),
|
|
503
|
-
body: `let value = this.get('employee')
|
|
504
|
-
if (!value || value.kind == ValueKind.NULL) {
|
|
505
|
-
throw new Error("Cannot return null for a required field.")
|
|
506
|
-
} else {
|
|
507
|
-
return value.toBytes()
|
|
508
|
-
}`,
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
name: 'set employee',
|
|
512
|
-
params: [new typescript_1.Param('value', new typescript_1.NamedType('Bytes'))],
|
|
513
|
-
returnType: undefined,
|
|
514
|
-
body: "\n this.set('employee', Value.fromBytes(value))\n ",
|
|
515
|
-
},
|
|
516
500
|
{
|
|
517
501
|
name: 'get worker',
|
|
518
502
|
params: [],
|
|
@@ -530,6 +514,12 @@ describe('Schema code generator', () => {
|
|
|
530
514
|
returnType: undefined,
|
|
531
515
|
body: "\n this.set('worker', Value.fromBytes(value))\n ",
|
|
532
516
|
},
|
|
517
|
+
{
|
|
518
|
+
name: 'get employees',
|
|
519
|
+
params: [],
|
|
520
|
+
returnType: new typescript_1.NamedType('WorkerLoader'),
|
|
521
|
+
body: "\n return new WorkerLoader('Task', this.get('id')!.toBytes().toHexString(), 'employees')\n ",
|
|
522
|
+
},
|
|
533
523
|
],
|
|
534
524
|
});
|
|
535
525
|
});
|
package/dist/commands/deploy.js
CHANGED
|
@@ -107,8 +107,6 @@ class DeployCommand extends core_1.Command {
|
|
|
107
107
|
required: true,
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias -- request needs it
|
|
111
|
-
const self = this;
|
|
112
110
|
const deploySubgraph = async (ipfsHash) => {
|
|
113
111
|
const spinner = gluegun_1.print.spin(`Deploying to Graph node ${requestUrl}`);
|
|
114
112
|
client.request('subgraph_deploy', {
|
|
@@ -137,7 +135,11 @@ class DeployCommand extends core_1.Command {
|
|
|
137
135
|
$ graph create --node ${node} ${subgraphName}`;
|
|
138
136
|
}
|
|
139
137
|
}
|
|
140
|
-
|
|
138
|
+
if (jsonRpcError.message.match(/auth failure/)) {
|
|
139
|
+
errorMessage += '\nYou may need to authenticate first.';
|
|
140
|
+
}
|
|
141
|
+
spinner.fail(errorMessage);
|
|
142
|
+
this.exit(1);
|
|
141
143
|
}
|
|
142
144
|
else if (requestError) {
|
|
143
145
|
spinner.fail(`HTTP error deploying the subgraph ${requestError.code}`);
|
|
@@ -171,7 +173,10 @@ class DeployCommand extends core_1.Command {
|
|
|
171
173
|
// we are provided the IPFS hash, so we deploy directly
|
|
172
174
|
if (ipfsHash) {
|
|
173
175
|
// Connect to the IPFS node (if a node address was provided)
|
|
174
|
-
const ipfsClient = (0, ipfs_http_client_1.create)({
|
|
176
|
+
const ipfsClient = (0, ipfs_http_client_1.create)({
|
|
177
|
+
url: (0, compiler_1.appendApiVersionForGraph)(ipfs.toString()),
|
|
178
|
+
headers,
|
|
179
|
+
});
|
|
175
180
|
// Fetch the manifest from IPFS
|
|
176
181
|
const manifestBuffer = ipfsClient.cat(ipfsHash);
|
|
177
182
|
let manifestFile = '';
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED