Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added .DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ coverage
# Bower dependency directory (https://bower.io/)
bower_components

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# node-waf configuration
.lock-wscript

Expand Down
95 changes: 37 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,37 @@
# MadeByCodera GraphQL Test

## Description

You are tasked with writing the GraphQL api for a new Todo List mobile app.

### Todo GraphQL Type
The structure of the Todo GraphQL Type according to the frontend developer should look like the following:

Field | Data Type | Description
------------ | ------------- | -------------
id | UUID | Unique identifier for the todo.
description | String | Describes what the todo is.
createdAt | Date | Tells us when the todo was created. Defaults to current datetime.
completed | Boolean | Indicates if the todo is complete. Defaults to false.
priority | Int | 1 is the highest priority. Defaults to 1.

### Todo GraphQL Query and Mutations
And the frontend developer is counting on you to implement the following 5 methods under the GraphQL api endpoint:
1. **List Todos** - Query - Retrieved todos can be sorted by the `priority`, `createdAt`, or `description` fields in ascending or descending order. By default the todos are unsorted. In addition, the todos can be filtered by the `completed` field.
2. **Create todo** - Mutation - `description` is required. `priority` is optional and if not provided should default to 1. The rest of the fields: `id`, `createdAt`, and `completed` should have defaults supplied for them as noted in the Todo GraphQL Type mentioned above.
3. **Update todo** - Mutation - Should update a todo based on the `id` provided in the request. `description` and/or `priority` fields can be updated. `priority` must be 1 or greater if sent in request.
4. **Mark todo complete** - Mutation - Should update a todo's `complete` field to `true` based on the `id` provided in the request.
4. **Delete todo** - Mutation - Should delete a todo based on the `id` provided in the request.

### Documentation

The front end developer would also like a little bit of documentation to help him use the api. The easiest way to provide documentation is to add comments to each query, mutation, and type that is defined in the GraphQL schema. The following multi-line comments example highlights how you should be declaring comments in the query, mutation, or type definitions:

```
"""
<my comments go here>
"""
```

This will make it very easy for the frontend developer to see them when inspecting the running GraphQL server using [GraphQL Playground](https://www.apollographql.com/docs/apollo-server/features/graphql-playground/)

As demonstrated in the following screenshot

[![graphql-playground-example.png](https://i.postimg.cc/rw6HMzmt/graphql-playground-example.png)](https://postimg.cc/VdRgFfXY)

### Testing

The front end developer would also like to see examples of using this GraphQL api to help him make his own requests, as well as show to him that the api will work as he expects. You may do this however you see fit. The simplest way possible would be to write variations of query and mutation requests in GraphQL Playground and then click `COPY CURL`, pasting the curl command into a shell script that you could provide at the root of the repo called `test.sh`.

[![graphql-test-copy-curl-example.png](https://i.postimg.cc/8c0vxzyb/graphql-test-copy-curl-example.png)](https://postimg.cc/BP2tK4f8)

## Instructions
1. Fork this repository. Do all of your work on your personal fork. Then create a new pull request on your personal fork
2. You must implement this graphql backend using [Apollo Server](https://www.apollographql.com/docs/apollo-server/)
3. You can use whatever data structure you are most comfortable with for storing the data such as in-memory, MySQL, Postgres, SQLite, MongoDB, etc... . Using Postgres is preferred and considered a plus, since that is what we use currently.
4. This repo should be an npm project such that we can install the dependencies that you define for the server in order to run it using Node.

Here is an example of creating a pull request from a fork of a repository:
[![pull-request-example.png](https://i.postimg.cc/QCgrr53S/pull-request-example.png)](https://postimg.cc/RJ0Y7Wqn)

## NOTE
If you are not storing the data in-memory, please commit a sql dump file of the database schema to the repo. Please add a note of where this file is located in this `README.md` if the sql dump is not located at the root of the repo. Your submission will be **DISCARDED** if you **DO NOT** commit a sql dump file for your implementation, if it uses a database.
# Mobile App
- react native
- Tested on iOS simulator
- In client folder
$ npm install
$ cd ios && pod install && cd ..
$ react-native run-ios

# Functionalities app
- List todos
- Add todo (plus FAB button)
- Description mandatory
- Priority optional
- Update todo (long press on list item)
- Description mandatory
- Priority optional
- Mark as done (press on list item)
- Delete todo (close icon on list item)
- Filters (icon on top right)
- Sort by date, priority, description
- Ascending/Descending

# Server side
- GraphQL playground: http://localhost:4000/
- Entry point index.js
- In index folder
$ npm install
$ node index.js
- Test graphql queries and mutations in test.sh

# Database
- MongoDB
- NOTE: in index.js add your mongo url (local or Atlas cluster)
const url = 'YOUR_MONGO_DB_URI’;
- Name you database: "mytodos"
- Create a collection in the database called: "todos"
- dump in mongodb_dump in root
3 changes: 3 additions & 0 deletions client/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["module:metro-react-native-babel-preset"]
}
6 changes: 6 additions & 0 deletions client/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
1 change: 1 addition & 0 deletions client/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
56 changes: 56 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle
20 changes: 20 additions & 0 deletions client/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import ApolloClient from 'apollo-boost';
import { ApolloProvider } from 'react-apollo';

const client = new ApolloClient({
uri: 'http://localhost:4000/'
});

import { enableScreens } from 'react-native-screens';
enableScreens();

import Home from './src/screens/Home';

export default App = () => {
return(
<ApolloProvider client={client}>
<Home />
</ApolloProvider>
);
}
10 changes: 10 additions & 0 deletions client/__tests__/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'react-native';
import React from 'react';
import App from '../App';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
renderer.create(<App />);
});
65 changes: 65 additions & 0 deletions client/android/app/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# To learn about Buck see [Docs](https://buckbuild.com/).
# To run your application with Buck:
# - install Buck
# - `npm start` - to start the packager
# - `cd android`
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
# - `buck install -r android/app` - compile, install and run application
#

lib_deps = []

for jarfile in glob(['libs/*.jar']):
name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
lib_deps.append(':' + name)
prebuilt_jar(
name = name,
binary_jar = jarfile,
)

for aarfile in glob(['libs/*.aar']):
name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
lib_deps.append(':' + name)
android_prebuilt_aar(
name = name,
aar = aarfile,
)

android_library(
name = "all-libs",
exported_deps = lib_deps,
)

android_library(
name = "app-code",
srcs = glob([
"src/main/java/**/*.java",
]),
deps = [
":all-libs",
":build_config",
":res",
],
)

android_build_config(
name = "build_config",
package = "com.client",
)

android_resource(
name = "res",
package = "com.client",
res = "src/main/res",
)

android_binary(
name = "app",
keystore = "//android/keystores:debug",
manifest = "src/main/AndroidManifest.xml",
package_type = "debug",
deps = [
":app-code",
],
)
Loading