master b0d53fd8c362 cached
18 files
8.2 KB
2.7k tokens
10 symbols
1 requests
Download .txt
Repository: StephenGrider/Lyrical-GraphQL
Branch: master
Commit: b0d53fd8c362
Files: 18
Total size: 8.2 KB

Directory structure:
gitextract_i0e0v96c/

├── .babelrc
├── .gitignore
├── README.md
├── client/
│   ├── index.html
│   ├── index.js
│   └── style/
│       └── style.css
├── index.js
├── package.json
├── server/
│   ├── models/
│   │   ├── index.js
│   │   ├── lyric.js
│   │   └── song.js
│   ├── schema/
│   │   ├── lyric_type.js
│   │   ├── mutations.js
│   │   ├── root_query_type.js
│   │   ├── schema.js
│   │   └── song_type.js
│   └── server.js
└── webpack.config.js

================================================
FILE CONTENTS
================================================

================================================
FILE: .babelrc
================================================
{
  "presets": ["env", "react"]
}


================================================
FILE: .gitignore
================================================
node_modules
.DS_STORE


================================================
FILE: README.md
================================================
# Lyrical-GraphQL

Starter project from a GraphQL course on Udemy.com

### Setup

- Run `npm install --legacy-peer-deps` in the root of the project to install dependencies
- Access the application at `localhost:4000` in your browser


================================================
FILE: client/index.html
================================================
<head>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/css/materialize.min.css">
  <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
  <div id="root" />
</body>


================================================
FILE: client/index.js
================================================
import React from 'react';
import ReactDOM from 'react-dom';

const Root = () => {
  return <div>Lyrical</div>
};

ReactDOM.render(
  <Root />,
  document.querySelector('#root')
);


================================================
FILE: client/style/style.css
================================================


================================================
FILE: index.js
================================================
const app = require('./server/server');

app.listen(4000, () => {
  console.log('Listening');
});


================================================
FILE: package.json
================================================
{
  "name": "lyrical",
  "version": "1.0.0",
  "description": "Starter point for a graphQL course",
  "main": "index.js",
  "repository": {
    "type": "git",
    "url": "https://github.com/StephenGrider/Lyrical-GraphQL"
  },
  "scripts": {
    "dev": "nodemon index.js --ignore client"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "apollo-client": "^0.8.1",
    "axios": "^0.15.3",
    "babel-core": "^6.22.1",
    "babel-loader": "^6.2.10",
    "babel-preset-env": "^1.1.8",
    "babel-preset-react": "^6.22.0",
    "body-parser": "^1.16.0",
    "connect-mongo": "^1.3.2",
    "css-loader": "^0.26.1",
    "express": "^4.14.0",
    "express-graphql": "0.6.1",
    "express-session": "^1.15.0",
    "graphql": "^0.8.2",
    "html-webpack-plugin": "^2.26.0",
    "lodash": "^4.17.4",
    "mongoose": "^7.3.1",
    "nodemon": "^2.0.22",
    "passport": "^0.3.2",
    "passport-local": "^1.0.0",
    "react": "^15.4.2",
    "react-apollo": "^0.9.0",
    "react-dom": "^15.4.2",
    "react-router": "^3.0.2",
    "style-loader": "^0.13.1",
    "webpack": "^2.2.0",
    "webpack-dev-middleware": "^1.9.0"
  }
}


================================================
FILE: server/models/index.js
================================================
require('./song');
require('./lyric');


================================================
FILE: server/models/lyric.js
================================================
const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const LyricSchema = new Schema({
  song: {
    type: Schema.Types.ObjectId,
    ref: 'song'
  },
  likes: { type: Number, default: 0 },
  content: { type: String }
});

LyricSchema.statics.like = function(id) {
  const Lyric = mongoose.model('lyric');

  return Lyric.findById(id)
    .then(lyric => {
      ++lyric.likes;
      return lyric.save();
    })
}

mongoose.model('lyric', LyricSchema);


================================================
FILE: server/models/song.js
================================================
const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const SongSchema = new Schema({
  title: { type: String },
  user: {
    type: Schema.Types.ObjectId,
    ref: 'user'
  },
  lyrics: [{
    type: Schema.Types.ObjectId,
    ref: 'lyric'
  }]
});

SongSchema.statics.addLyric = function(id, content) {
  const Lyric = mongoose.model('lyric');

  return this.findById(id)
    .then(song => {
      const lyric = new Lyric({ content, song })
      song.lyrics.push(lyric)
      return Promise.all([lyric.save(), song.save()])
        .then(([lyric, song]) => song);
    });
}

SongSchema.statics.findLyrics = function(id) {
  return this.findById(id)
    .populate('lyrics')
    .then(song => song.lyrics);
}

mongoose.model('song', SongSchema);


================================================
FILE: server/schema/lyric_type.js
================================================
const mongoose = require('mongoose');
const graphql = require('graphql');
const {
  GraphQLObjectType,
  GraphQLList,
  GraphQLID,
  GraphQLInt,
  GraphQLString
} = graphql;
const Lyric = mongoose.model('lyric');

const LyricType = new GraphQLObjectType({
  name:  'LyricType',
  fields: () => ({
    id: { type: GraphQLID },
    likes: { type: GraphQLInt },
    content: { type: GraphQLString },
    song: {
      type: require('./song_type'),
      resolve(parentValue) {
        return Lyric.findById(parentValue).populate('song')
          .then(lyric => {
            console.log(lyric)
            return lyric.song
          });
      }
    }
  })
});

module.exports = LyricType;


================================================
FILE: server/schema/mutations.js
================================================
const graphql = require('graphql');
const { GraphQLObjectType, GraphQLString, GraphQLID } = graphql;
const mongoose = require('mongoose');
const Song = mongoose.model('song');
const Lyric = mongoose.model('lyric');
const SongType = require('./song_type');
const LyricType = require('./lyric_type');

const mutation = new GraphQLObjectType({
  name: 'Mutation',
  fields: {
    addSong: {
      type: SongType,
      args: {
        title: { type: GraphQLString }
      },
      resolve(parentValue, { title }) {
        return new Song({ title }).save();
      }
    },
    addLyricToSong: {
      type: SongType,
      args: {
        content: { type: GraphQLString },
        songId: { type: GraphQLID }
      },
      resolve(parentValue, { content, songId }) {
        return Song.addLyric(songId, content);
      }
    },
    likeLyric: {
      type: LyricType,
      args: { id: { type: GraphQLID } },
      resolve(parentValue, { id }) {
        return Lyric.like(id);
      }
    },
    deleteSong: {
      type: SongType,
      args: { id: { type: GraphQLID } },
      resolve(parentValue, { id }) {
        return Song.findByIdAndRemove(id);
      }
    }
  }
});

module.exports = mutation;


================================================
FILE: server/schema/root_query_type.js
================================================
const mongoose = require('mongoose');
const graphql = require('graphql');
const { GraphQLObjectType, GraphQLList, GraphQLID, GraphQLNonNull } = graphql;
const SongType = require('./song_type');
const LyricType = require('./lyric_type');
const Lyric = mongoose.model('lyric');
const Song = mongoose.model('song');

const RootQuery = new GraphQLObjectType({
  name: 'RootQueryType',
  fields: () => ({
    songs: {
      type: new GraphQLList(SongType),
      resolve() {
        return Song.find({});
      }
    },
    song: {
      type: SongType,
      args: { id: { type: new GraphQLNonNull(GraphQLID) } },
      resolve(parentValue, { id }) {
        return Song.findById(id);
      }
    },
    lyric: {
      type: LyricType,
      args: { id: { type: new GraphQLNonNull(GraphQLID) } },
      resolve(parnetValue, { id }) {
        return Lyric.findById(id);
      }
    }
  })
});

module.exports = RootQuery;


================================================
FILE: server/schema/schema.js
================================================
const _ = require('lodash');
const graphql = require('graphql');
const { GraphQLSchema } = graphql;

const RootQueryType = require('./root_query_type');
const mutations = require('./mutations');

module.exports = new GraphQLSchema({
  query: RootQueryType,
  mutation: mutations
});


================================================
FILE: server/schema/song_type.js
================================================
const mongoose = require('mongoose');
const graphql = require('graphql');
const { GraphQLObjectType, GraphQLString, GraphQLID, GraphQLList } = graphql;
const LyricType = require('./lyric_type');
const Song = mongoose.model('song');

const SongType = new GraphQLObjectType({
  name:  'SongType',
  fields: () => ({
    id: { type: GraphQLID },
    title: { type: GraphQLString },
    lyrics: {
      type: new GraphQLList(LyricType),
      resolve(parentValue) {
        return Song.findLyrics(parentValue.id);
      }
    }
  })
});

module.exports = SongType;


================================================
FILE: server/server.js
================================================
const express = require('express');
const models = require('./models');
const expressGraphQL = require('express-graphql');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const schema = require('./schema/schema');

const app = express();

// Replace with your Mongo Atlas URI
const MONGO_URI = '';
if (!MONGO_URI) {
  throw new Error('You must provide a Mongo Atlas URI');
}

mongoose.Promise = global.Promise;
mongoose.connect(MONGO_URI);
mongoose.connection
  .once('open', () => console.log('Connected to Mongo Atlas instance.'))
  .on('error', (error) =>
    console.log('Error connecting to Mongo Atlas:', error)
  );

app.use(bodyParser.json());
app.use(
  '/graphql',
  expressGraphQL({
    schema,
    graphiql: true
  })
);

const webpackMiddleware = require('webpack-dev-middleware');
const webpack = require('webpack');
const webpackConfig = require('../webpack.config.js');
app.use(webpackMiddleware(webpack(webpackConfig)));

module.exports = app;


================================================
FILE: webpack.config.js
================================================
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: './client/index.js',
  output: {
    path: '/',
    filename: 'bundle.js'
  },
  module: {
    rules: [
      {
        use: 'babel-loader',
        test: /\.js$/,
        exclude: /node_modules/
      },
      {
        use: ['style-loader', 'css-loader'],
        test: /\.css$/
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: 'client/index.html'
    })
  ]
};
Download .txt
gitextract_i0e0v96c/

├── .babelrc
├── .gitignore
├── README.md
├── client/
│   ├── index.html
│   ├── index.js
│   └── style/
│       └── style.css
├── index.js
├── package.json
├── server/
│   ├── models/
│   │   ├── index.js
│   │   ├── lyric.js
│   │   └── song.js
│   ├── schema/
│   │   ├── lyric_type.js
│   │   ├── mutations.js
│   │   ├── root_query_type.js
│   │   ├── schema.js
│   │   └── song_type.js
│   └── server.js
└── webpack.config.js
Download .txt
SYMBOL INDEX (10 symbols across 5 files)

FILE: server/schema/lyric_type.js
  method resolve (line 20) | resolve(parentValue) {

FILE: server/schema/mutations.js
  method resolve (line 17) | resolve(parentValue, { title }) {
  method resolve (line 27) | resolve(parentValue, { content, songId }) {
  method resolve (line 34) | resolve(parentValue, { id }) {
  method resolve (line 41) | resolve(parentValue, { id }) {

FILE: server/schema/root_query_type.js
  method resolve (line 14) | resolve() {
  method resolve (line 21) | resolve(parentValue, { id }) {
  method resolve (line 28) | resolve(parnetValue, { id }) {

FILE: server/schema/song_type.js
  method resolve (line 14) | resolve(parentValue) {

FILE: server/server.js
  constant MONGO_URI (line 11) | const MONGO_URI = '';
Condensed preview — 18 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (10K chars).
[
  {
    "path": ".babelrc",
    "chars": 34,
    "preview": "{\n  \"presets\": [\"env\", \"react\"]\n}\n"
  },
  {
    "path": ".gitignore",
    "chars": 23,
    "preview": "node_modules\n.DS_STORE\n"
  },
  {
    "path": "README.md",
    "chars": 233,
    "preview": "# Lyrical-GraphQL\n\nStarter project from a GraphQL course on Udemy.com\n\n### Setup\n\n- Run `npm install --legacy-peer-deps`"
  },
  {
    "path": "client/index.html",
    "chars": 253,
    "preview": "<head>\n  <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/css/materialize.min.css\""
  },
  {
    "path": "client/index.js",
    "chars": 181,
    "preview": "import React from 'react';\nimport ReactDOM from 'react-dom';\n\nconst Root = () => {\n  return <div>Lyrical</div>\n};\n\nReact"
  },
  {
    "path": "client/style/style.css",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "index.js",
    "chars": 98,
    "preview": "const app = require('./server/server');\n\napp.listen(4000, () => {\n  console.log('Listening');\n});\n"
  },
  {
    "path": "package.json",
    "chars": 1127,
    "preview": "{\n  \"name\": \"lyrical\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Starter point for a graphQL course\",\n  \"main\": \"index.js\""
  },
  {
    "path": "server/models/index.js",
    "chars": 39,
    "preview": "require('./song');\nrequire('./lyric');\n"
  },
  {
    "path": "server/models/lyric.js",
    "chars": 469,
    "preview": "const mongoose = require('mongoose');\nconst Schema = mongoose.Schema;\n\nconst LyricSchema = new Schema({\n  song: {\n    ty"
  },
  {
    "path": "server/models/song.js",
    "chars": 763,
    "preview": "const mongoose = require('mongoose');\nconst Schema = mongoose.Schema;\n\nconst SongSchema = new Schema({\n  title: { type: "
  },
  {
    "path": "server/schema/lyric_type.js",
    "chars": 688,
    "preview": "const mongoose = require('mongoose');\nconst graphql = require('graphql');\nconst {\n  GraphQLObjectType,\n  GraphQLList,\n  "
  },
  {
    "path": "server/schema/mutations.js",
    "chars": 1202,
    "preview": "const graphql = require('graphql');\nconst { GraphQLObjectType, GraphQLString, GraphQLID } = graphql;\nconst mongoose = re"
  },
  {
    "path": "server/schema/root_query_type.js",
    "chars": 917,
    "preview": "const mongoose = require('mongoose');\nconst graphql = require('graphql');\nconst { GraphQLObjectType, GraphQLList, GraphQ"
  },
  {
    "path": "server/schema/schema.js",
    "chars": 283,
    "preview": "const _ = require('lodash');\nconst graphql = require('graphql');\nconst { GraphQLSchema } = graphql;\n\nconst RootQueryType"
  },
  {
    "path": "server/schema/song_type.js",
    "chars": 561,
    "preview": "const mongoose = require('mongoose');\nconst graphql = require('graphql');\nconst { GraphQLObjectType, GraphQLString, Grap"
  },
  {
    "path": "server/server.js",
    "chars": 994,
    "preview": "const express = require('express');\nconst models = require('./models');\nconst expressGraphQL = require('express-graphql'"
  },
  {
    "path": "webpack.config.js",
    "chars": 514,
    "preview": "const webpack = require('webpack');\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\n\nmodule.exports = {\n  entr"
  }
]

About this extraction

This page contains the full source code of the StephenGrider/Lyrical-GraphQL GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 18 files (8.2 KB), approximately 2.7k tokens, and a symbol index with 10 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!