@graphprotocol/graph-cli 0.42.4 → 0.42.5-alpha-20230317153958-8b44d62

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,13 @@
1
1
  # @graphprotocol/graph-cli
2
2
 
3
+ ## 0.42.5-alpha-20230317153958-8b44d62
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1193](https://github.com/graphprotocol/graph-tooling/pull/1193)
8
+ [`8b44d62`](https://github.com/graphprotocol/graph-tooling/commit/8b44d620602cc748436ac7767f60082d4b03d177)
9
+ Thanks [@saihaj](https://github.com/saihaj)! - do not generate setters for derived fields
10
+
3
11
  ## 0.42.4
4
12
 
5
13
  ### Patch Changes
@@ -139,10 +139,14 @@ class SchemaCodeGenerator {
139
139
  `));
140
140
  }
141
141
  _generateEntityFieldMethods(entityDef, fieldDef) {
142
- return immutable_1.default.List([
142
+ return (immutable_1.default
143
+ .List([
143
144
  this._generateEntityFieldGetter(entityDef, fieldDef),
144
145
  this._generateEntityFieldSetter(entityDef, fieldDef),
145
- ]);
146
+ ])
147
+ // generator can return null if the field is not supported
148
+ // so we filter all falsy values
149
+ .filter(Boolean));
146
150
  }
147
151
  _generateEntityFieldGetter(_entityDef, fieldDef) {
148
152
  const name = fieldDef.getIn(['name', 'value']);
@@ -163,6 +167,12 @@ class SchemaCodeGenerator {
163
167
  }
164
168
  _generateEntityFieldSetter(_entityDef, fieldDef) {
165
169
  const name = fieldDef.getIn(['name', 'value']);
170
+ const isDerivedField = !!fieldDef
171
+ .get('directives')
172
+ .find((directive) => directive.getIn(['name', 'value']) === 'derivedFrom');
173
+ // We cannot have setters for derived fields
174
+ if (isDerivedField)
175
+ return null;
166
176
  const gqlType = fieldDef.get('type');
167
177
  const fieldValueType = this._valueTypeFromGraphQl(gqlType);
168
178
  const paramType = this._typeFromGraphQl(gqlType);
@@ -242,18 +242,6 @@ describe('Schema code generator', () => {
242
242
  } else {
243
243
  return value.toStringArray()
244
244
  }
245
- `,
246
- },
247
- {
248
- name: 'set wallets',
249
- params: [new typescript_1.Param('value', new typescript_1.NullableType(new typescript_1.ArrayType(new typescript_1.NamedType('string'))))],
250
- returnType: undefined,
251
- body: `
252
- if (!value) {
253
- this.unset('wallets')
254
- } else {
255
- this.set('wallets', Value.fromStringArray(<Array<string>>value))
256
- }
257
245
  `,
258
246
  },
259
247
  ],
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.42.4",
2
+ "version": "0.42.5-alpha-20230317153958-8b44d62",
3
3
  "commands": {
4
4
  "add": {
5
5
  "id": "add",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.42.4",
3
+ "version": "0.42.5-alpha-20230317153958-8b44d62",
4
4
  "description": "CLI for building for and deploying to The Graph",
5
5
  "license": "(Apache-2.0 OR MIT)",
6
6
  "engines": {