<commit_before>const graphql = require('graphql');
const {
  GraphQLObjectType,
  GraphQLString,
  GraphQLInt,
  GraphQLList,
  GraphQLSchema,
  GraphQLNonNull
} = graphql;
const Folder = new require('../models/folder')();
const Note = new require('../models/note')();

const FolderType = new GraphQLObjectType({
  name: 'Folder',
  fields: () => ({
    id: { type: GraphQLInt },
    name: { type: GraphQLString },
    createdAt: { type: GraphQLString },
    updatedAt: { type: GraphQLString },
    notes: {
      type: new GraphQLList(NoteType),
      resolve(parentValue, args) {
        return parentValue.notes()
          .then((notes) => {
            return notes;
          });
      }
    }
  })
});

const NoteType = new GraphQLObjectType({
  name: 'Note',
  fields: {
    id: { type: GraphQLInt },
    name: { type: GraphQLString },
    content: { type: GraphQLString },
    folderId: { type: GraphQLInt },
    createdAt: { type: GraphQLString },
    updatedAt: { type: GraphQLString }
  }
});

const RootQuery = new GraphQLObjectType({
  name: 'RootQueryType',
  fields: {
    folder: {
      type: FolderType,
      args: { id: { type: GraphQLInt } },
      resolve(parentValue, args) {
        return Folder.findById(args.id)
          .then((folder) => {
            return folder;
          });
      }
    },

    folders: {
      type: new GraphQLList(FolderType),
      resolve(parentValue, args) {
        return Folder.findAll()
          .then((folders) => {
            return folders;
          });
      }
    },

    note: {
      type: NoteType,
      args: { id: { type: GraphQLInt } },
      resolve(parentValue, args) {
        return Note.findById(args.id)
          .then((note) => {
            return note;
          });
      }
    },

    notes: {
      type: new GraphQLList(NoteType),
      resolve(parentValue, args) {
        return Note.findAll()
          .then((notes) => {
            return notes;
          });
      }
    },
  }
});

const mutation = new GraphQLObjectType({
  name: 'Mutation',
  fields: {
    addFolder: {
      type: FolderType,
      args: {
        name: { type: new GraphQLNonNull(GraphQLString) },
      },
      resolve(parentValue, args) {
        return Folder.create(args.name)
      }
    },

    deleteFolder: {
      type: FolderType,
      args: {
        id: { type: new GraphQLNonNull(GraphQLInt) }
      },
      resolve(parentValue, args) {
        return Folder.findById(args.id)
          .then((folder) => {
            return folder.delete();
          })
      }
    },

    editFolder: {
      type: FolderType,
      args: {
        id: { type: new GraphQLNonNull(GraphQLInt) },
        name: { type: new GraphQLNonNull(GraphQLString) }
      },
      resolve(parentValue, args) {
        return Folder.findById(args.id)
          .then((folder) => {
            folder.name = args.name;
            return folder.save();
          });
      }
    }
  }
});

module.exports = new GraphQLSchema({
  query: RootQuery,
  mutation
});<commit_msg>GraphQL CRUD mutation methods are working for Notes.<commit_after>const graphql = require('graphql');
const {
  GraphQLObjectType,
  GraphQLString,
  GraphQLInt,
  GraphQLList,
  GraphQLSchema,
  GraphQLNonNull
} = graphql;
const Folder = new require('../models/folder')();
const Note = new require('../models/note')();

const FolderType = new GraphQLObjectType({
  name: 'Folder',
  fields: () => ({
    id: { type: GraphQLInt },
    name: { type: GraphQLString },
    createdAt: { type: GraphQLString },
    updatedAt: { type: GraphQLString },
    notes: {
      type: new GraphQLList(NoteType),
      resolve(parentValue, args) {
        return parentValue.notes()
          .then((notes) => {
            return notes;
          });
      }
    }
  })
});

const NoteType = new GraphQLObjectType({
  name: 'Note',
  fields: {
    id: { type: GraphQLInt },
    name: { type: GraphQLString },
    content: { type: GraphQLString },
    folderId: { type: GraphQLInt },
    createdAt: { type: GraphQLString },
    updatedAt: { type: GraphQLString }
  }
});

const RootQuery = new GraphQLObjectType({
  name: 'RootQueryType',
  fields: {
    folder: {
      type: FolderType,
      args: { id: { type: GraphQLInt } },
      resolve(parentValue, args) {
        return Folder.findById(args.id)
          .then((folder) => {
            return folder;
          });
      }
    },

    folders: {
      type: new GraphQLList(FolderType),
      resolve(parentValue, args) {
        return Folder.findAll()
          .then((folders) => {
            return folders;
          });
      }
    },

    note: {
      type: NoteType,
      args: { id: { type: GraphQLInt } },
      resolve(parentValue, args) {
        return Note.findById(args.id)
          .then((note) => {
            return note;
          });
      }
    },

    notes: {
      type: new GraphQLList(NoteType),
      resolve(parentValue, args) {
        return Note.findAll()
          .then((notes) => {
            return notes;
          });
      }
    },
  }
});

const mutation = new GraphQLObjectType({
  name: 'Mutation',
  fields: {
    addFolder: {
      type: FolderType,
      args: {
        name: { type: new GraphQLNonNull(GraphQLString) },
      },
      resolve(parentValue, args) {
        return Folder.create(args.name)
      }
    },

    deleteFolder: {
      type: FolderType,
      args: {
        id: { type: new GraphQLNonNull(GraphQLInt) }
      },
      resolve(parentValue, args) {
        return Folder.findById(args.id)
          .then((folder) => {
            return folder.delete();
          })
      }
    },

    editFolder: {
      type: FolderType,
      args: {
        id: { type: new GraphQLNonNull(GraphQLInt) },
        name: { type: new GraphQLNonNull(GraphQLString) }
      },
      resolve(parentValue, args) {
        return Folder.findById(args.id)
          .then((folder) => {
            folder.name = args.name;
            return folder.save();
          });
      }
    },

    addNote: {
      type: NoteType,
      args: {
        name: { type: new GraphQLNonNull(GraphQLString) },
        content: { type: GraphQLString },
        folderId: { type: GraphQLInt }
      },
      resolve(parentValue, args) {
        return Note.create({name: args.name, content: args.content, folderId: args.folderId})
      }
    },

    deleteNote: {
      type: NoteType,
      args: {
        id: { type: new GraphQLNonNull(GraphQLInt) }
      },
      resolve(parentValue, args) {
        return Note.findById(args.id)
          .then((note) => {
            return note.delete();
          })
      }
    },

    editNote: {
      type: NoteType,
      args: {
        id: { type: new GraphQLNonNull(GraphQLInt) },
        name: { type: GraphQLString },
        content: { type: GraphQLString },
        folderId: { type: GraphQLInt }
      },
      resolve(parentValue, args) {
        return Note.findById(args.id)
          .then((note) => {
            note.name = (args.name != null) ? args.name : note.name;
            note.content = (args.content != null) ? args.content : note.content;
            note.folderId = (args.folderId != null) ? args.folderId : note.folderId;
            return note.save();
          });
      }
    }
  }
});

module.exports = new GraphQLSchema({
  query: RootQuery,
  mutation
});
{'fraction_non_alphanumeric': 0.1373827965756217, 'fraction_numerical': 0.0, 'mean_word_length': 1.926441351888668, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1303853', 'n_tokens_mistral': 2286, 'n_tokens_neox': 2288, 'n_words': 468}