Answer the question
In order to leave comments, you need to log in
How to pass an array of objects as GraphQL query arguments?
There is a good example in the help.
var schema = buildSchema(`
type ouTest{
num: Int
qwe: Int
}
input inTest{
num: Int
qwe: Int
}
type Query {
rollDice(input: [inTest]): [ouTest]
}
`);
const imgS = new graphql.GraphQLObjectType({
name: "img",
fields: () => {
return {
a: {type: graphql.GraphQLInt},
b: {type: graphql.GraphQLInt}
}
}
})
const img = {
type: new graphql.GraphQLList(imgS),
args: {
input: [imgS] // Как тут прописать input массив объектов
},
resolve (source, args, context) {
return args;
}
}
const Query = new graphql.GraphQLObjectType({
name: 'Query',
description: 'Root query object',
fields: () => {
return {
img: img
};
}
})
var schema = new graphql.GraphQLSchema({
query: Query
});
{
returnUserN(img: [{a: 123, b:456}]){
a
b
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question