Error de GraphQL Args: el tipo de argumento debe ser Input Type pero tiene: function GraphQLObjectType (config) {
Al iniciar el servidor (node index.js
) Recibo el siguiente error con mi servidor GraphQL NodeJS:
Error: el tipo de argumento Query.payment (data :) debe ser Input Type pero tiene: function GraphQLObjectType (config) {_classCallCheck (this, GraphQLObjectType);
Este error ocurrió cuando cambié mis argumentos originales de una cadena
args: {
data: { type: graphQL.GraphQLString }
},
Para un tipo de objeto:
args: {
data: { type: graphQL.GraphQLObjectType }
},
Necesito un tipo de objeto, ya que necesito enviar varios campos como parámetros.
Servidor GraphQL:
var Query = new graphQL.GraphQLObjectType({
name: 'Query',
fields: {
payment: {
type: graphQL.GraphQLString,
args: {
data: { type: graphQL.GraphQLObjectType }
},
resolve: function (_, args) {
// There will be more data here,
// but ultimately I want to return a string
return 'success!';
}
}
}
});
¿Cómo puedo permitirle aceptar un objeto?
Interfaz (si es necesario. Pero el error está ocurriendo incluso antes de enviar esto):
var userQuery = encodeURIComponent('{ payment ( data: { user : "test" } )}');
$.get('http://localhost:4000/graphql?query=' + userQuery, function (res) {
//stuff
});