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

1.1K
Views
[Error: Consulta. Mutación definida en los resolutores, pero no en el esquema]
const { ApolloServer, gql } = require('apollo-server-express'); const express = require('express'); const port = process.env.PORT || 4000; const notes = [ { id: '1', content: 'This is a note', author: 'Adam Scott' }, { id: '2', content: 'This is another note', author: 'Harlow Everly' }, { id: '3', content: 'Oh hey look, another note!', author: 'Riley Harrison' } ]; const typeDefs = gql ` type Note { id: ID content: String author: String } type Query { hello: String notes: [Note] note(id: ID!): Note } type Mutation { newNote(content: String!): Note } `; const resolvers = { Query:{ hello: () => 'Hello World', notes: () => notes, note: (parent, args) => { return notes.find(note => note.id == args.id); }, Mutation: { newNote: (parent, args) => { let noteValue = { id : String(notes.length + 1), content : args.content, author: 'Adam Scott', }; notes.push(noteValue); return noteValue; } } }, }

Algunas personas tuvieron problemas con los nombres, pero parece que estoy usando lo mismo en la resolución y en el esquema. Tenga paciencia conmigo, este es mi segundo día en GraphQL y Express. Eliminé intencionalmente las importaciones y la asignación de objetos express, middleware ya que no me permite publicar.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que simplemente te falta un corchete.

 const resolvers = { Query:{ hello: () => 'Hello World', notes: () => notes, note: (parent, args) => { return notes.find(note => note.id == args.id); } }, <==== THIS IS MISSING =====> Mutation: { newNote: (parent, args) => { let noteValue = { id : String(notes.length + 1), content : args.content, author: 'Adam Scott', }; notes.push(noteValue); return noteValue; } }
about 4 years ago · Juan Pablo Isaza Report
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!