Skip to content

Commit

Permalink
cli: Skip validations for aggregations (#1548)
Browse files Browse the repository at this point in the history
This is a placeholder that simply allows `@aggregation` annotation. The
real change should come from using `graph-node`'s validation functionality.
  • Loading branch information
lutter authored Feb 10, 2024
1 parent 928355f commit b3f6a99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-clocks-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphprotocol/graph-cli': minor
---

Make validations more lenient to allow aggregations and Int8 ids
11 changes: 7 additions & 4 deletions packages/cli/src/validation/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ const parseSchema = (doc: string) => {

const validateEntityDirective = (def: any) => {
validateDebugger('Validating entity directive for %s', def?.name?.value);
return def.directives.find((directive: any) => directive.name.value === 'entity')
return def.directives.find(
(directive: any) => directive.name.value === 'entity' || directive.name.value === 'aggregation',
)
? List()
: immutable.fromJS([
{
loc: def.loc,
entity: def.name.value,
message: `Defined without @entity directive`,
message: `Defined without @entity or @aggregation directive`,
},
]);
};
Expand All @@ -114,7 +116,8 @@ const validateEntityID = (def: any) => {
idField.type.type.kind === 'NamedType' &&
(idField.type.type.name.value === 'ID' ||
idField.type.type.name.value === 'Bytes' ||
idField.type.type.name.value === 'String')
idField.type.type.name.value === 'String' ||
idField.type.type.name.value === 'Int8')
) {
validateDebugger('Entity %s has valid id field', def?.name?.value);
return List();
Expand All @@ -125,7 +128,7 @@ const validateEntityID = (def: any) => {
{
loc: idField.loc,
entity: def.name.value,
message: `Field 'id': Entity ids must be of type Bytes! or String!`,
message: `Field 'id': Entity ids must be of type Int8!, Bytes! or String!`,
},
]);
};
Expand Down

0 comments on commit b3f6a99

Please sign in to comment.