@graphprotocol/graph-cli 0.25.0 → 0.25.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "description": "CLI for building for and deploying to The Graph",
5
5
  "dependencies": {
6
6
  "assemblyscript": "0.19.10",
@@ -80,17 +80,24 @@ module.exports = class SchemaCodeGenerator {
80
80
  .map(field => {
81
81
  const name = field.getIn(['name', 'value'])
82
82
  const type = this._typeFromGraphQl(field.get('type'))
83
+
83
84
  const isNullable = type instanceof tsCodegen.NullableType
85
+ const isPrimitive = type.isPrimitive && type.isPrimitive()
84
86
 
85
87
  const directives = field.get('directives')
86
88
  const isDerivedFrom = directives.some(directive => directive.getIn(['name', 'value']) === 'derivedFrom')
87
89
 
88
- return { name, type, isNullable, isDerivedFrom }
90
+ return { name, type, isNullable, isPrimitive, isDerivedFrom }
89
91
  })
90
92
  // We only call the setter with the default value in the constructor for fields that are:
93
+ // - Not primitive (such as Int/i32)
91
94
  // - Not nullable, so that AS doesn't break when subgraph developers try to access them before a `set`
92
95
  // - Not tagged as `derivedFrom`, because they only exist in query time
93
- .filter(({ isNullable, isDerivedFrom }) => !isNullable && !isDerivedFrom)
96
+ .filter(({
97
+ isNullable,
98
+ isPrimitive,
99
+ isDerivedFrom,
100
+ }) => !(isNullable || isPrimitive || isDerivedFrom))
94
101
  .map(({ name, type, isNullable }) => {
95
102
  const fieldTypeString = isNullable ? type.inner.toString() : type.toString()
96
103
 
@@ -57,7 +57,7 @@ const assertGraphTsVersion = async (sourceDir, minimumGraphTsVersion) => {
57
57
  if (graphTsVersion && semver.lt(semver.coerce(graphTsVersion), minimumGraphTsVersion)) {
58
58
  throw new Error(
59
59
  `To use this version of the graph-cli you must upgrade the graph-ts dependency to a version greater than or equal to ${minimumGraphTsVersion}
60
- Also, you'll probably need to take a look at our AssemblyScript migration guide because of language breaking changes: https://gist.github.com/otaviopace/8406cb39644d2e7678570d1e7f50dac4`
60
+ Also, you'll probably need to take a look at our AssemblyScript migration guide because of language breaking changes: https://thegraph.com/docs/developer/assemblyscript-migration-guide`
61
61
  )
62
62
  }
63
63
  }
@@ -197,7 +197,7 @@ describe('Version Command Helpers', () => {
197
197
  .rejects
198
198
  .toThrow(new Error(
199
199
  `To use this version of the graph-cli you must upgrade the graph-ts dependency to a version greater than or equal to ${minimumGraphTsVersion}
200
- Also, you'll probably need to take a look at our AssemblyScript migration guide because of language breaking changes: https://gist.github.com/otaviopace/8406cb39644d2e7678570d1e7f50dac4`
200
+ Also, you'll probably need to take a look at our AssemblyScript migration guide because of language breaking changes: https://thegraph.com/docs/developer/assemblyscript-migration-guide`
201
201
  ))
202
202
  })
203
203
  test('When the installed graph-ts version is a supported one', async () => {