{"id":20126338,"url":"https://github.com/uts-cic/graphql-la-api","last_synced_at":"2025-05-06T17:35:16.293Z","repository":{"id":40750917,"uuid":"171402227","full_name":"uts-cic/graphql-la-api","owner":"uts-cic","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-30T21:52:53.000Z","size":807,"stargazers_count":1,"open_issues_count":12,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T15:29:10.996Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uts-cic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-19T04:00:13.000Z","updated_at":"2019-08-05T03:36:04.000Z","dependencies_parsed_at":"2023-01-25T14:46:22.055Z","dependency_job_id":null,"html_url":"https://github.com/uts-cic/graphql-la-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uts-cic%2Fgraphql-la-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uts-cic%2Fgraphql-la-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uts-cic%2Fgraphql-la-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uts-cic%2Fgraphql-la-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uts-cic","download_url":"https://codeload.github.com/uts-cic/graphql-la-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252734487,"owners_count":21796029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T20:15:51.341Z","updated_at":"2025-05-06T17:35:16.002Z","avatar_url":"https://github.com/uts-cic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# la-graphql-api\n\nThe LA-API provides an interface between educational data sources and learning analytics tools. GraphQL is used to modularise dependencies, providing flexibility for extending both sides of a complex learning ecosystem.\n\n\n## Setup\n\n- requires node v10.2, npm, git installed\n- ``git clone https://github.com/uts-cic/graphql-la-api.git``\n- ``npm install``\n- ``cp .env.default .env``\n- update .env\n- ``npm start ``\n- This will start server http://localhost:8080/graphql\n\n## Stack used\n- node\n- npm\n- graphql\n- express\n- mongoose\n\n### Project Structure\n\n    .\n    ├── models                  # stores all the mongoDB schemas for collections\n    ├── services                # stores files for connecting to third party api's\n    ├── .env                    # stores all configurable parameters like DB usernames, passwords etc (added to .gitignore)\n    ├── index.js                # entry point for the graphql server\n    ├── resolvers.js            # resolvers for fileds names specified in the graphql schema\n    ├── schema.js               # graphql SDL\n    ├── package.json            # npm packages required\n    ├── LICENSE\n    └── README.md\n\n\n## Development\n\n``npm start`` will start nodemon and will keep checking for changes in the files and reload the server automatically\nFor Production use PM2, forever or similar to keep node running.\n\n## Contributions\n\n- Fork the repo.\n- Merge changes into the repo on a separate branch\n\n\n### FAQ\n\tTo add a new service\n- Decide the required output and add it to the `schema.js`\n`` type Book {\n    name: String\n    author: String\n }\n ``\n- Add the query ``type {Query  { getBooks() : Book } }``\n- Next need to resolve the query so go to resolver.js and add a function getBook() to fetch all the books.\n- Data source for the Book may be either mongoDB or any other database or a third part API\n\t- if MongoDB -\u003e create a model (schema) for the book collection like by creating a new file under `models/book.js`.  replicate the code in `models/note.js` or `models/user.js` and update the fields *Note: this is the database schema and not the graphql schema we defined above*.\n\t- if Third Party API (REST or GraphQL) create a file under `services/book.js` (name could be anything). Use node fetch, http, or request to fetch book data. `npm isntall` required packages or consider using https://www.apollographql.com/docs/apollo-server/v2/features/data-sources.html\n\t- if another database (postgresql or mysql or any other db), create a model under models/book.js to match the table schema and export it.\n- import all the newly created models (db schema) into `resolver.js` or add it to the datasources like (https://github.com/uts-cic/la-graphql-api/blob/5f927804bd435c3bedfbdba91a0cf38cd04f2689/index.js#L41). This will make the datasource (functions) available in the `resolver.js`\n- Check the graphql API output.\n\n**Note**: *This is just a quick easy way to get started, please feel free to experiment and play around to get optimised results.*\n\n\tUpdate the port number\nUpdate `const PORT = 9000` in `index.js`\n\n\tUpdate MongoDB Port\nUpdate `line 18 :27017 to the port mongodb is running on` in `index.js`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futs-cic%2Fgraphql-la-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futs-cic%2Fgraphql-la-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futs-cic%2Fgraphql-la-api/lists"}