waterline-graphql
waterline-graphql copied to clipboard
Json attributes not accessible
I use this project with sailsjs and mongodb and tried to setup a basic request which works fine. Here is my User.js model:
module.exports = {
tableName: 'users',
attributes: {
profile: {
type: 'json',
defaultsTo: {
'firstName': null,
'lastName': null
}
}
}
}
I can request the id attribute and the profile attribute like this (Postman body):
{"request": "query getUser { users { id, profile } }"}
What I can't do is request a specific json attribute like so:
{"request": "query getUser { users { id, profile { firstName } } }"}
I already tried waterline-to-graphql (doesn't return json at all), sails-hook-graphql (no docs provided) and sails-grapqhl (fails at request).
How can I do this?
@benediktdertinger formatting your model like below should fix the problem:
module.exports = {
tableName: 'users',
attributes: {
firstName: {
type: 'string',
defaultsTo: null
},
lastName: {
type: 'string',
defaultsTo: null
}
}
}
@pierreburgy thanks for your reply! Does it mean, that I can't use nested objects at all?
@benediktdertinger unfortunately not.