devour-client
devour-client copied to clipboard
Nested includes leads to Error: "too much recursion"
Hi, i have the following models:
client.define('role', {
name: '',
displayname: '',
service_authorizations: {
jsonApi: 'hasMany',
type: 'service_authorization'
}
})
client.define('service', {
name: '',
displayname: '',
service_authorizations: {
jsonApi: 'hasMany',
type: 'service_authorization'
}
})
client.define('service_authorization', {
name: '',
displayname: '',
service: {
jsonApi: 'hasOne',
type: 'service'
},
roles: {
jsonApi: 'hasMany',
type: 'role'
}
})
When trying to fetch the roles and its relationships i use the following:
this.$authApiClient.findAll('role', { include: ['service_authorizations', 'service_authorizations.service'] })
But it crashes with the error in the title.
The stacktrace:
InternalError: "too much recursion"
resource webpack-internal:///./node_modules/devour-client/lib/middleware/json-api/_deserialize.js:65:1
collection webpack-internal:///./node_modules/devour-client/lib/middleware/json-api/_deserialize.js:61:12
collection webpack-internal:///./node_modules/devour-client/lib/middleware/json-api/_deserialize.js:60:10
attachHasManyFor webpack-internal:///./node_modules/devour-client/lib/middleware/json-api/_deserialize.js:161:12
attachRelationsFor webpack-internal:///./node_modules/devour-client/lib/middleware/json-api/_deserialize.js:137:16
resource webpack-internal:///./node_modules/devour-client/lib/middleware/json-api/_deserialize.js:115:32
createBaseFor webpack-internal:///./node_modules/lodash/_createBaseFor.js:17:11
baseForOwn webpack-internal:///./node_modules/lodash/_baseForOwn.js:13:20
forOwn webpack-internal:///./node_modules/lodash/forOwn.js:33:20
resource webpack-internal:///./node_modules/devour-client/lib/middleware/json-api/_deserialize.js:100:3
helpers.js:73
The issue is most likely that the two models ServiceAuthorization and Service both relate to each other and are both included in the response from the backend.