@graphprotocol/graph-cli 0.48.0 → 0.49.0-alpha-20230427181905-94ca8fc
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 +9 -0
- package/dist/codegen/schema.js +3 -0
- package/dist/codegen/schema.test.js +27 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @graphprotocol/graph-cli
|
|
2
2
|
|
|
3
|
+
## 0.49.0-alpha-20230427181905-94ca8fc
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1306](https://github.com/graphprotocol/graph-tooling/pull/1306)
|
|
8
|
+
[`f106dbf`](https://github.com/graphprotocol/graph-tooling/commit/f106dbf7e39d9c430c255f3eaafb591080c69e86)
|
|
9
|
+
Thanks [@saihaj](https://github.com/saihaj)! - Add loadInBlock function for entities as part of
|
|
10
|
+
codegen
|
|
11
|
+
|
|
3
12
|
## 0.48.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/dist/codegen/schema.js
CHANGED
|
@@ -138,6 +138,9 @@ class SchemaCodeGenerator {
|
|
|
138
138
|
\`Entities of type ${entityName} must have an ID of type ${idField.gqlTypeName()} but the id '\${id.displayData()}' is of type \${id.displayKind()}\`)
|
|
139
139
|
store.set('${entityName}', ${idField.tsValueToString()}, this)
|
|
140
140
|
}`),
|
|
141
|
+
tsCodegen.staticMethod('loadInBlock', [tsCodegen.param('id', tsCodegen.namedType(idField.typeName()))], tsCodegen.nullableType(tsCodegen.namedType(entityName)), `
|
|
142
|
+
return changetype<${entityName} | null>(store.get_in_block('${entityName}', ${idField.tsToString()}))
|
|
143
|
+
`),
|
|
141
144
|
tsCodegen.staticMethod('load', [tsCodegen.param('id', tsCodegen.namedType(idField.typeName()))], tsCodegen.nullableType(tsCodegen.namedType(entityName)), `
|
|
142
145
|
return changetype<${entityName} | null>(store.get('${entityName}', ${idField.tsToString()}))
|
|
143
146
|
`),
|
|
@@ -128,6 +128,15 @@ describe('Schema code generator', () => {
|
|
|
128
128
|
\`Entities of type Account must have an ID of type String but the id '\${id.displayData()}' is of type \${id.displayKind()}\`)
|
|
129
129
|
store.set('Account', id.toString(), this)
|
|
130
130
|
}
|
|
131
|
+
`,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'loadInBlock',
|
|
135
|
+
static: true,
|
|
136
|
+
params: [new typescript_1.Param('id', new typescript_1.NamedType('string'))],
|
|
137
|
+
returnType: new typescript_1.NullableType(new typescript_1.NamedType('Account')),
|
|
138
|
+
body: `
|
|
139
|
+
return changetype<Account | null>(store.get_in_block('Account', id))
|
|
131
140
|
`,
|
|
132
141
|
},
|
|
133
142
|
{
|
|
@@ -307,6 +316,15 @@ describe('Schema code generator', () => {
|
|
|
307
316
|
\`Entities of type Wallet must have an ID of type String but the id '\${id.displayData()}' is of type \${id.displayKind()}\`)
|
|
308
317
|
store.set('Wallet', id.toString(), this)
|
|
309
318
|
}
|
|
319
|
+
`,
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
name: 'loadInBlock',
|
|
323
|
+
static: true,
|
|
324
|
+
params: [new typescript_1.Param('id', new typescript_1.NamedType('string'))],
|
|
325
|
+
returnType: new typescript_1.NullableType(new typescript_1.NamedType('Wallet')),
|
|
326
|
+
body: `
|
|
327
|
+
return changetype<Wallet | null>(store.get_in_block('Wallet', id))
|
|
310
328
|
`,
|
|
311
329
|
},
|
|
312
330
|
{
|
|
@@ -425,6 +443,15 @@ describe('Schema code generator', () => {
|
|
|
425
443
|
" store.set('Task', id.toBytes().toHexString(), this)\n" +
|
|
426
444
|
' }',
|
|
427
445
|
},
|
|
446
|
+
{
|
|
447
|
+
name: 'loadInBlock',
|
|
448
|
+
static: true,
|
|
449
|
+
params: [new typescript_1.Param('id', new typescript_1.NamedType('Bytes'))],
|
|
450
|
+
returnType: new typescript_1.NullableType(new typescript_1.NamedType('Task')),
|
|
451
|
+
body: '\n' +
|
|
452
|
+
" return changetype<Task | null>(store.get_in_block('Task', id.toHexString()))\n" +
|
|
453
|
+
' ',
|
|
454
|
+
},
|
|
428
455
|
{
|
|
429
456
|
name: 'load',
|
|
430
457
|
static: true,
|
package/oclif.manifest.json
CHANGED