@graphprotocol/graph-cli 0.64.0-alpha-20231215205836-6d9a26b → 0.64.0
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 +1 -8
- package/dist/codegen/schema.test.js +28 -29
- package/dist/codegen/types/index.test.js +430 -431
- package/dist/codegen/util.test.js +10 -11
- package/dist/command-helpers/abi.test.js +3 -4
- package/dist/command-helpers/compiler.test.js +15 -16
- package/dist/command-helpers/network.test.js +15 -16
- package/dist/command-helpers/scaffold.d.ts +10 -10
- package/dist/command-helpers/scaffold.js +5 -5
- package/dist/command-helpers/version.test.js +52 -45
- package/dist/protocols/ethereum/codegen/abi.test.js +32 -33
- package/dist/protocols/ethereum/type-generator.js +3 -3
- package/dist/scaffold/cosmos.test.js +7 -8
- package/dist/scaffold/ethereum.test.js +19 -20
- package/dist/scaffold/index.d.ts +21 -21
- package/dist/scaffold/index.js +30 -31
- package/dist/scaffold/near.test.js +7 -8
- package/dist/scaffold/tests.d.ts +3 -3
- package/dist/scaffold/tests.js +3 -3
- package/dist/type-generator.js +2 -2
- package/dist/validation/schema.test.js +25 -26
- package/oclif.manifest.json +1 -1
- package/package.json +9 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @graphprotocol/graph-cli
|
|
2
2
|
|
|
3
|
-
## 0.64.0
|
|
3
|
+
## 0.64.0
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -11,13 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
### Patch Changes
|
|
13
13
|
|
|
14
|
-
- [#1536](https://github.com/graphprotocol/graph-tooling/pull/1536)
|
|
15
|
-
[`3d4108e`](https://github.com/graphprotocol/graph-tooling/commit/3d4108e40a3f37f1468eaad01398112ffe441506)
|
|
16
|
-
Thanks [@saihaj](https://github.com/saihaj)! - dependencies updates:
|
|
17
|
-
|
|
18
|
-
- Updated dependency [`prettier@3.0.3` ↗︎](https://www.npmjs.com/package/prettier/v/3.0.3) (from
|
|
19
|
-
`1.19.1`, in `dependencies`)
|
|
20
|
-
|
|
21
14
|
- [#1545](https://github.com/graphprotocol/graph-tooling/pull/1545)
|
|
22
15
|
[`1cfc8ce`](https://github.com/graphprotocol/graph-tooling/commit/1cfc8ce67388ebb9c6dcb1195119959ecd9be325)
|
|
23
16
|
Thanks [@saihaj](https://github.com/saihaj)! - dependencies updates:
|
|
@@ -29,33 +29,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
const assert_1 = __importDefault(require("assert"));
|
|
30
30
|
const graphql = __importStar(require("graphql/language"));
|
|
31
31
|
const prettier_1 = __importDefault(require("prettier"));
|
|
32
|
-
const vitest_1 = require("vitest");
|
|
33
32
|
const schema_1 = __importDefault(require("../schema"));
|
|
34
33
|
const schema_2 = __importDefault(require("./schema"));
|
|
35
34
|
const typescript_1 = require("./typescript");
|
|
36
|
-
const formatTS =
|
|
35
|
+
const formatTS = (code) => prettier_1.default.format(code, { parser: 'typescript', semi: false });
|
|
37
36
|
const createSchemaCodeGen = (schema) => new schema_2.default(new schema_1.default('', schema, graphql.parse(schema)));
|
|
38
|
-
const testEntity =
|
|
37
|
+
const testEntity = (generatedTypes, expectedEntity) => {
|
|
39
38
|
const entity = generatedTypes.find(type => type.name === expectedEntity.name);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
expect(entity instanceof typescript_1.Class).toBe(true);
|
|
40
|
+
expect(entity.extends).toBe('Entity');
|
|
41
|
+
expect(entity.export).toBe(true);
|
|
43
42
|
const { members, methods } = entity;
|
|
44
|
-
|
|
43
|
+
expect(members).toStrictEqual(expectedEntity.members);
|
|
45
44
|
for (const expectedMethod of expectedEntity.methods) {
|
|
46
45
|
const method = methods.find((method) => method.name === expectedMethod.name);
|
|
47
46
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
48
47
|
expectedMethod.static
|
|
49
|
-
?
|
|
50
|
-
:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
? expect(method instanceof typescript_1.StaticMethod).toBe(true)
|
|
49
|
+
: expect(method instanceof typescript_1.Method).toBe(true);
|
|
50
|
+
expect(method.params).toStrictEqual(expectedMethod.params);
|
|
51
|
+
expect(method.returnType).toStrictEqual(expectedMethod.returnType);
|
|
52
|
+
expect(formatTS(method.body)).toBe(formatTS(expectedMethod.body));
|
|
54
53
|
}
|
|
55
|
-
|
|
54
|
+
expect(methods.length).toBe(expectedEntity.methods.length);
|
|
56
55
|
};
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
describe('Schema code generator', () => {
|
|
57
|
+
test('Should generate nothing for non entity types', () => {
|
|
59
58
|
const codegen = createSchemaCodeGen(`
|
|
60
59
|
type Foo {
|
|
61
60
|
foobar: Int
|
|
@@ -65,9 +64,9 @@ vitest_1.describe.concurrent('Schema code generator', () => {
|
|
|
65
64
|
barfoo: Int
|
|
66
65
|
}
|
|
67
66
|
`);
|
|
68
|
-
|
|
67
|
+
expect(codegen.generateTypes().length).toBe(0);
|
|
69
68
|
});
|
|
70
|
-
|
|
69
|
+
describe('Should generate correct classes for each entity', () => {
|
|
71
70
|
const codegen = createSchemaCodeGen(`
|
|
72
71
|
# just to be sure nothing will be generated from non-entity types alongside regular ones
|
|
73
72
|
type Foo {
|
|
@@ -100,14 +99,14 @@ vitest_1.describe.concurrent('Schema code generator', () => {
|
|
|
100
99
|
}
|
|
101
100
|
`);
|
|
102
101
|
const generatedTypes = codegen.generateTypes();
|
|
103
|
-
|
|
102
|
+
test('Foo is NOT an entity', () => {
|
|
104
103
|
const foo = generatedTypes.find((type) => type.name === 'Foo');
|
|
105
|
-
|
|
104
|
+
expect(foo).toBe(undefined);
|
|
106
105
|
// Account and Wallet
|
|
107
|
-
|
|
106
|
+
expect(generatedTypes.length).toBe(2);
|
|
108
107
|
});
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
test('Account is an entity with the correct methods', () => {
|
|
109
|
+
testEntity(generatedTypes, {
|
|
111
110
|
name: 'Account',
|
|
112
111
|
members: [],
|
|
113
112
|
methods: [
|
|
@@ -309,8 +308,8 @@ vitest_1.describe.concurrent('Schema code generator', () => {
|
|
|
309
308
|
],
|
|
310
309
|
});
|
|
311
310
|
});
|
|
312
|
-
|
|
313
|
-
|
|
311
|
+
test('Wallet is an entity with the correct methods', () => {
|
|
312
|
+
testEntity(generatedTypes, {
|
|
314
313
|
name: 'Wallet',
|
|
315
314
|
members: [],
|
|
316
315
|
methods: [
|
|
@@ -420,7 +419,7 @@ vitest_1.describe.concurrent('Schema code generator', () => {
|
|
|
420
419
|
});
|
|
421
420
|
});
|
|
422
421
|
});
|
|
423
|
-
|
|
422
|
+
test('Should handle references with Bytes id types', () => {
|
|
424
423
|
const codegen = createSchemaCodeGen(`
|
|
425
424
|
interface Employee {
|
|
426
425
|
id: Bytes!
|
|
@@ -441,7 +440,7 @@ vitest_1.describe.concurrent('Schema code generator', () => {
|
|
|
441
440
|
}
|
|
442
441
|
`);
|
|
443
442
|
const generatedTypes = codegen.generateTypes();
|
|
444
|
-
|
|
443
|
+
testEntity(generatedTypes, {
|
|
445
444
|
name: 'Task',
|
|
446
445
|
members: [],
|
|
447
446
|
methods: [
|
|
@@ -543,7 +542,7 @@ vitest_1.describe.concurrent('Schema code generator', () => {
|
|
|
543
542
|
],
|
|
544
543
|
});
|
|
545
544
|
});
|
|
546
|
-
|
|
545
|
+
test('get related method for WithBytes entity', () => {
|
|
547
546
|
const codegen = createSchemaCodeGen(`
|
|
548
547
|
type WithBytes @entity {
|
|
549
548
|
id: Bytes!
|
|
@@ -556,7 +555,7 @@ vitest_1.describe.concurrent('Schema code generator', () => {
|
|
|
556
555
|
}
|
|
557
556
|
`);
|
|
558
557
|
const generatedTypes = codegen.generateTypes();
|
|
559
|
-
|
|
558
|
+
testEntity(generatedTypes, {
|
|
560
559
|
name: 'WithBytes',
|
|
561
560
|
members: [],
|
|
562
561
|
methods: [
|
|
@@ -623,7 +622,7 @@ vitest_1.describe.concurrent('Schema code generator', () => {
|
|
|
623
622
|
],
|
|
624
623
|
});
|
|
625
624
|
});
|
|
626
|
-
|
|
625
|
+
test('no derived loader for interface', () => {
|
|
627
626
|
const codegen = createSchemaCodeGen(`
|
|
628
627
|
interface IExample {
|
|
629
628
|
id: ID!
|