@graphprotocol/graph-cli 0.52.1-alpha-20230719201219-dde01c9 → 0.53.0-alpha-20230721161547-13ba32e

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 CHANGED
@@ -1,6 +1,13 @@
1
1
  # @graphprotocol/graph-cli
2
2
 
3
- ## 0.52.1-alpha-20230719201219-dde01c9
3
+ ## 0.53.0-alpha-20230721161547-13ba32e
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
- [`dde01c9`](https://github.com/graphprotocol/graph-tooling/commit/dde01c95527b6473e0eda6a533aa524d83f41e7c)
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
 
@@ -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')!.toString(), '${name}')
258
+ return new ${returnType}('${entityName}', this.get('id')!${toValueString}, '${name}')
249
259
  `);
250
260
  }
251
261
  _returnTypeForDervied(gqlType) {
@@ -428,11 +428,13 @@ 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
  employee: Employee!
437
+ workers: [Worker!] @derivedFrom(field: "tasks")
436
438
  worker: Worker!
437
439
  }
438
440
  `);
@@ -530,6 +532,12 @@ describe('Schema code generator', () => {
530
532
  returnType: undefined,
531
533
  body: "\n this.set('worker', Value.fromBytes(value))\n ",
532
534
  },
535
+ {
536
+ name: 'get workers',
537
+ params: [],
538
+ returnType: new typescript_1.NamedType('WorkerLoader'),
539
+ body: "\n return new WorkerLoader('Task', this.get('id')!.toBytes().toHexString(), 'workers')\n ",
540
+ },
533
541
  ],
534
542
  });
535
543
  });
@@ -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
- self.error(errorMessage, { exit: 1 });
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)({ url: (0, compiler_1.appendApiVersionForGraph)(ipfs.toString()), headers });
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 = '';
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.52.1-alpha-20230719201219-dde01c9",
2
+ "version": "0.53.0-alpha-20230721161547-13ba32e",
3
3
  "commands": {
4
4
  "add": {
5
5
  "id": "add",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.52.1-alpha-20230719201219-dde01c9",
3
+ "version": "0.53.0-alpha-20230721161547-13ba32e",
4
4
  "description": "CLI for building for and deploying to The Graph",
5
5
  "license": "(Apache-2.0 OR MIT)",
6
6
  "engines": {