Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!