Проблема решена , так и не понял почему не работало. Но сей час все хорошо.
Схема
const graphql = require('graphql');
const img = new graphql.GraphQLObjectType({
name: "img",
fields: () => {
return {
id: {type: graphql.GraphQLInt},
idUser: {type: graphql.GraphQLInt},
name: {type: graphql.GraphQLString}
}
}
})
const user = new graphql.GraphQLObjectType({
name: 'user',
description: 'This represents a Person',
fields: () => {
return {
id: {
type: graphql.GraphQLInt,
resolve (res) {
return res.id;
}
},
mail: {
type: graphql.GraphQLString,
resolve (res) {
return res.mail;
}
},
password: {
type: graphql.GraphQLString,
resolve (res) {
return "privat info";
}
},
name: {
type: graphql.GraphQLString,
resolve (res) {
return res.name;
}
},
img: {
type: new graphql.GraphQLList(img),
}
};
}
});
module.exports = user;
Запрос
const graphql = require('graphql');
const userSchema = require("../schema/userSchema")
module.exports = {
type: new graphql.GraphQLList(userSchema),
args: {
id: {type: new graphql.GraphQLNonNull(graphql.GraphQLInt)}
},
resolve (source, args, context) {
return [
{
id: 123,
name: "pero",
img:
[
{id: 1, name: "pero111"},
{id: 2, name: "pero112"},
{id: 3, name: "pero113"}
]
}
]
}
}