Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

159
Vistas
Express Graphql

I'm trying to learn graphql. I didn't find any good course witch will help me to learn it. So i started building it with little examples. In this moment i'm getting error when i'm trying to open http://127.0.0.1:3000/graphql. it's telling me "message": "Must provide query string."

I thinks i did something wrong with my users query? This is my complete code of it. Can someone please help...

// user type
const UserType = new GraphQLObjectType({
  name: "User",
  description: "User Type",
  fields: () => ({
    id: { type: GraphQLInt },
    firstname: { type: GraphQLString },
    lastname: { type: GraphQLString },
    email: { type: GraphQLString },
    password: { type: GraphQLString },
  }),
});

// register (mutation)
const register = {
  type: UserType,
  args: {
    firstname: { type: GraphQLString },
    lastname: { type: GraphQLString },
    email: { type: GraphQLString },
    password: { type: GraphQLString },
  },
  //@ts-ignore
  async resolve(parent, args) {
    const { firstname, lastname, email, password } = args;

    const user = new User();
    user.firstname = firstname;
    user.lastname = lastname;
    user.email = email;
    user.password = password;
    const result = await user.save();
    console.log(result);
    return result;
  },
};

// users (query)
const users = {
  // type: new GraphQLList(UserType),
  type: UserType,
  args: { id: { type: GraphQLInt } },
  //@ts-ignore
  async resolve(parent, args) {
    const users = await User.find();
    return users;
  },
};

const MutationType = new GraphQLObjectType({
  name: "MutationType",
  description: "Mutations",
  fields: { register },
});

const QueryType = new GraphQLObjectType({
  name: "QueryType",
  description: "Queries",
  fields: { users },
});

const schema = new GraphQLSchema({ query: QueryType, mutation: MutationType });

app.use(
  "/graphql",
  graphqlHTTP({
    schema,
    graphiql: true,
  })
);

I have 2 problems.

  1. when i type in browser: http://127.0.0.1:3000/graphql it's don't loading. it's telling me Loading... and stuck on it.
  2. when i try it in insomnia it's telling me
{
  "errors": [
    {
      "message": "Must provide query string."
    }
  ]
}

how can i fixed it ?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda