Skip to content

Commit b3f6a99

Browse files
authoredFeb 10, 2024··
cli: Skip validations for aggregations (#1548)
This is a placeholder that simply allows `@aggregation` annotation. The real change should come from using `graph-node`'s validation functionality.
1 parent 928355f commit b3f6a99

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed
 

‎.changeset/spotty-clocks-agree.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphprotocol/graph-cli': minor
3+
---
4+
5+
Make validations more lenient to allow aggregations and Int8 ids

‎packages/cli/src/validation/schema.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ const parseSchema = (doc: string) => {
8383

8484
const validateEntityDirective = (def: any) => {
8585
validateDebugger('Validating entity directive for %s', def?.name?.value);
86-
return def.directives.find((directive: any) => directive.name.value === 'entity')
86+
return def.directives.find(
87+
(directive: any) => directive.name.value === 'entity' || directive.name.value === 'aggregation',
88+
)
8789
? List()
8890
: immutable.fromJS([
8991
{
9092
loc: def.loc,
9193
entity: def.name.value,
92-
message: `Defined without @entity directive`,
94+
message: `Defined without @entity or @aggregation directive`,
9395
},
9496
]);
9597
};
@@ -114,7 +116,8 @@ const validateEntityID = (def: any) => {
114116
idField.type.type.kind === 'NamedType' &&
115117
(idField.type.type.name.value === 'ID' ||
116118
idField.type.type.name.value === 'Bytes' ||
117-
idField.type.type.name.value === 'String')
119+
idField.type.type.name.value === 'String' ||
120+
idField.type.type.name.value === 'Int8')
118121
) {
119122
validateDebugger('Entity %s has valid id field', def?.name?.value);
120123
return List();
@@ -125,7 +128,7 @@ const validateEntityID = (def: any) => {
125128
{
126129
loc: idField.loc,
127130
entity: def.name.value,
128-
message: `Field 'id': Entity ids must be of type Bytes! or String!`,
131+
message: `Field 'id': Entity ids must be of type Int8!, Bytes! or String!`,
129132
},
130133
]);
131134
};

0 commit comments

Comments
 (0)
Please sign in to comment.