@graphprotocol/graph-cli 0.64.0 → 0.64.1-alpha-20231218145603-ee88ea0

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