0

I am new to graphql and tried to add a unique schema in graphql but got such error.
This is the schema:

const mongoose = require('mongoose');
const { Schema } = mongoose;

const incidentSchema = new Schema({
  incidentNumber: {type: String, required: true, unique: true},
  releaseDate: {type: String, required: true}
});
module.exports = mongoose.model('Incident', incidentSchema);

In graphql mutation:

addIncident: {
      type: IncidentType,
      args: {
        incidentNumber: { type: GraphQLString },
        releaseDate: { type: GraphQLString }
      },
      resolve(parent, args) {
        let incident = new Incident({
          incidentNumber: args.incidentNumber,
          releaseDate: args.releaseDate
        });
        return incident.save();
      }
    }

Do not know what needs to be done for this issue

subhro
  • 75
  • 1
  • 1
  • 8

1 Answers1

0

This error message is normally returned when a query is made using a directive that isn't supported by the server. It sounds like your query includes the @unique directive, but there is no such directive defined server-side. You can check your API's documentation to see which directives are supported. It's also possible to run an introspection query to obtain that information:

query GetDirectives {
  __schema {
    directives {
      name
      description
      locations
      args {
        name
        description
        defaultValue
        type {
          name
        }
      }
    }
  }
}
Daniel Rearden
  • 80,636
  • 11
  • 185
  • 183