Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
81db6fb
Create extracted_remo.sql
narayansharma-21 Jan 25, 2023
ac76915
Update schema.graphqls
narayansharma-21 Jan 31, 2023
2ba5e5a
Moved teacher struct from schema to book.go
Bedrockdude10 Jan 31, 2023
f694dc6
Accidentally pushed .idea
Bedrockdude10 Jan 31, 2023
b2d4b7d
Updated gitignore
Bedrockdude10 Jan 31, 2023
a8724b6
Added teacher & classroom structs in model, added teacher skeleton to…
Bedrockdude10 Jan 31, 2023
19e5873
Merge branch 'database' of https://github.com/GenerateNU/remo into da…
Bedrockdude10 Jan 31, 2023
7ec5c73
Added skeleton books resolver
Bedrockdude10 Jan 31, 2023
75b8d00
Implemented model structs - need to flesh out JSON encoding for custo…
Bedrockdude10 Jan 31, 2023
6bacde9
Implemented model structs in schema - need to flesh out JSON encoding…
Bedrockdude10 Jan 31, 2023
c18014a
Fixed non-null requirements in schema
Bedrockdude10 Feb 2, 2023
476158c
Schema Changes
narayansharma-21 Feb 5, 2023
15c497a
Merged books & user_books, implemented books and user resolvers, need…
Bedrockdude10 Feb 7, 2023
688676a
Merged books & user_books, implemented books and user resolvers, need…
Bedrockdude10 Feb 7, 2023
455d5f2
Converted book and user storage to map, all mapped to their respectiv…
Bedrockdude10 Feb 7, 2023
31d69b6
Stupid fing maps - need to figure out a way to get maps working for g…
Bedrockdude10 Feb 7, 2023
9030955
Added user_books back to schema - need to update model
Bedrockdude10 Feb 8, 2023
27e3d07
Added user_books back to schema - need to update model
Bedrockdude10 Feb 8, 2023
d0f1cba
Model has both user_books and books. Need to fix resolvers
Bedrockdude10 Feb 8, 2023
04fbd27
THIS DOESN'T WORK BUT LEBRON
Bedrockdude10 Feb 8, 2023
6c06de6
THIS DOESN'T WORK BUT LEBRON PT 2
Bedrockdude10 Feb 8, 2023
850c31f
Integrated the gin server
narayansharma-21 Feb 8, 2023
97748aa
Rlly bad work in progress - look into option types
Bedrockdude10 Feb 8, 2023
cec4c37
Merge branch 'database' of https://github.com/GenerateNU/remo into da…
Bedrockdude10 Feb 8, 2023
182e7b0
Have a jank solution to types. Map still screwed
Bedrockdude10 Feb 8, 2023
b0948b0
Have a jank solution to types. Map still screwed
Bedrockdude10 Feb 8, 2023
c5205d6
Something is seriously wrong
Bedrockdude10 Feb 9, 2023
0a57f10
Finally got fields to update. String & int are working properly - nee…
Bedrockdude10 Feb 10, 2023
bf592e4
Wait figured out only author - need to figure out how to generalize t…
Bedrockdude10 Feb 10, 2023
730e9ae
Holy s*** I can actually create, update and query books with nullable…
Bedrockdude10 Feb 10, 2023
f5e5ca3
Fixed maps. Literally just needed to import the built-in scalar to Gr…
Bedrockdude10 Feb 10, 2023
0c93cb3
Moved mutation helpers into reslover.go so all types can implement them
Bedrockdude10 Feb 10, 2023
cd6aec8
Removing cyclic imports
brianreicher Feb 12, 2023
8f86386
Modifications to being to implement DB calling
brianreicher Feb 12, 2023
d2c8fb1
Initial commit
brianreicher Feb 17, 2023
82a0afc
Adding back token strings
brianreicher Feb 17, 2023
c5aedd7
Lebron pt.3
narayansharma-21 Feb 17, 2023
2b4ae38
Removing old comments from tokenizer
brianreicher Feb 17, 2023
987b983
Fixing docker port mapping & tests
brianreicher Feb 17, 2023
4394100
Updating error responses
brianreicher Feb 17, 2023
c9693db
Fixed book fetching to return empty JSON upon not finding ISBN
brianreicher Feb 17, 2023
bc19b5b
Changed Taskfile.yaml to connect to mysql on port 3333
Bedrockdude10 Feb 20, 2023
0af67bf
Able to establish connection to database, need to implement resolvers
Bedrockdude10 Feb 21, 2023
7390210
Go run server.go not working properly - not sure why
Bedrockdude10 Feb 21, 2023
f792855
implemented a test for createBook function and created raw sql for cr…
narayansharma-21 Feb 21, 2023
0d96f88
Got rid of the defer connections and rerouted the connection back to …
narayansharma-21 Feb 21, 2023
1d30d3f
Fixing pointer errors
brianreicher Feb 22, 2023
e658fdf
Changed to list implementation of books model
Bedrockdude10 Feb 25, 2023
a4e4a71
Added var for DB connection in resolvers file, DbInitConnection() pas…
Bedrockdude10 Feb 25, 2023
3c6291a
Busted af
Bedrockdude10 Feb 26, 2023
a954f5c
got a working connection as a test in the db_connection_test.go
narayansharma-21 Feb 26, 2023
5db900d
Merge branch 'graphql-integration' of https://github.com/GenerateNU/r…
narayansharma-21 Feb 26, 2023
61ea4c6
Commented out create book test
Bedrockdude10 Feb 26, 2023
e0accf0
finished dbinitconnection to have a successful working connection
narayansharma-21 Feb 26, 2023
12d9e5d
testing querying in db_connection_test
narayansharma-21 Feb 26, 2023
12703f4
Working on query tests
Bedrockdude10 Feb 26, 2023
c5852c3
me when
Bedrockdude10 Feb 26, 2023
f7cdb7b
Successful connection & scan of database query result into book struct
Bedrockdude10 Feb 26, 2023
8680d51
Test passes. Time to write all the resolvers
Bedrockdude10 Feb 26, 2023
59ee072
Working on resolvers
Bedrockdude10 Feb 26, 2023
26fb58e
Implemented getBooksByID resolver, have not tested it yet
narayansharma-21 Feb 26, 2023
5a4863e
Lebron pt 4
Bedrockdude10 Feb 26, 2023
e82857a
Me > the NBA
Bedrockdude10 Feb 26, 2023
b818506
Cleaned up getBooksByID
Bedrockdude10 Feb 26, 2023
0d81eae
Updated createBook resolver, almost finished implementation of it
narayansharma-21 Feb 26, 2023
3508bbd
Merge branch 'graphql-integration' of https://github.com/GenerateNU/r…
narayansharma-21 Feb 26, 2023
8cf6156
Gotta fix createBooks
Bedrockdude10 Feb 26, 2023
37e6695
Able to insert data into database
narayansharma-21 Feb 27, 2023
f8cf617
Able to create books, but json returning weird error on playground
narayansharma-21 Feb 27, 2023
80c16f7
Added all remo-client files and added getUserByID resolver
narayansharma-21 Mar 19, 2023
3e7669c
Implemented createBooks and a test for it
narayansharma-21 Mar 19, 2023
5dbf5c9
Realized that ID is auto-incremented all the way at the end of the sq…
narayansharma-21 Mar 19, 2023
870687d
createBooks works according to test
narayansharma-21 Mar 19, 2023
91006d5
Teacher schema had attributes that don't exist in SQL so attempting t…
narayansharma-21 Mar 20, 2023
ad74c82
Fixed schema for Teacher and implementation for createTeacher
narayansharma-21 Mar 20, 2023
1292201
createClassroom resolver implemented
narayansharma-21 Mar 21, 2023
b320e43
All mutationResolvers (createSomething) are finished
narayansharma-21 Mar 21, 2023
a994d88
Implemented teachers resolver
narayansharma-21 Mar 21, 2023
64d05f3
Added test for query resolver framework
Bedrockdude10 Mar 21, 2023
3999482
Abstracted resolver instances into vars
Bedrockdude10 Mar 22, 2023
1f1a72f
Updated endpoints.go trying to finish implementing booksByID
narayansharma-21 Mar 26, 2023
308e12c
My bad
narayansharma-21 Mar 26, 2023
a4b55b8
Implemented global variables for resolver, query resolver and mutatio…
Bedrockdude10 Mar 26, 2023
ee4d3fd
Need to implement filler values for book created during resolver queries
Bedrockdude10 Mar 26, 2023
e48b490
Reimplemented getUsersByID resolver
narayansharma-21 Mar 28, 2023
bb85025
Working api test for getUserByID
narayansharma-21 Mar 28, 2023
d3718ef
Status code is failing and getting the wrong status code for some rea…
narayansharma-21 Mar 28, 2023
b10127e
Reupdated user schema/ getUserByID
narayansharma-21 Mar 28, 2023
77cad15
Changed context input for bookById resolver
narayansharma-21 Mar 29, 2023
ff57921
Added test for user query resolver
Bedrockdude10 Mar 31, 2023
e66aea4
Merging new src
brianreicher Apr 2, 2023
340dd67
Adding to go.mod
brianreicher Apr 2, 2023
636d087
added neccessary libraries but original endpoints not working
narayansharma-21 Apr 2, 2023
1b3ba76
Updating tests
brianreicher Apr 2, 2023
590fe13
Merge branch 'graphql-integration' of https://github.com/GenerateNU/r…
brianreicher Apr 2, 2023
cbf6706
Updated the getBookByID resolver to grab isbn_13 instead of id
narayansharma-21 Apr 2, 2023
d66ce26
Changed getBookByID to getBookByISBN, wrote test
Bedrockdude10 Apr 2, 2023
eacfa37
Ran graphqlgen
Bedrockdude10 Apr 2, 2023
bd262ba
Updated tests
Bedrockdude10 Apr 2, 2023
054872c
Updated getBooksByISBN to go to isbn 10 if 13 doesn't exist
narayansharma-21 Apr 2, 2023
28cb46d
Merge branch 'graphql-integration' of https://github.com/GenerateNU/r…
narayansharma-21 Apr 2, 2023
6757688
Wrote isbn_10 fallback test
Bedrockdude10 Apr 2, 2023
7d16ff6
change the type value of the isbn10 value in the getbookbyId resolver
narayansharma-21 Apr 2, 2023
a5a8964
Updated resolver tests
Bedrockdude10 Apr 2, 2023
867c44b
changed limit to 1 for SQL queries in getbooksbyisbn resolver
narayansharma-21 Apr 2, 2023
17ceec9
update schema.resolvers.go
narayansharma-21 Apr 2, 2023
e8ab50c
Tried updating getBooksByIsbn to handle Isbn_10 search
Bedrockdude10 Apr 2, 2023
11a7c4e
Successfully implemented fallback search for isbn_10
Bedrockdude10 Apr 2, 2023
e72c212
Added pseudocode endpoint queries
Bedrockdude10 Apr 6, 2023
b7ade2c
Added api test file
Bedrockdude10 Apr 11, 2023
01576a1
Updated api_test
Bedrockdude10 Apr 11, 2023
0fcc818
Updated api_tests
Bedrockdude10 Apr 12, 2023
9ba5d51
ngrok link added and instructions as well
narayansharma-21 Apr 12, 2023
c469fff
query comment added for postman
narayansharma-21 Apr 12, 2023
b7db41d
Updated api_test
Bedrockdude10 Apr 12, 2023
c7af373
Successfully tested getBooksByISBN in API
Bedrockdude10 Apr 13, 2023
abeae5f
Continue to test query/mutation resolvers - having type issues with t…
narayansharma-21 Apr 16, 2023
232debb
running into type issue conversion from MySQL date to Go String
narayansharma-21 Apr 16, 2023
5bb8c2f
changed back types to time
narayansharma-21 Apr 16, 2023
93a6f6e
still attempting to resolve type issue
narayansharma-21 Apr 16, 2023
06fd73a
still getting teacher type issues
narayansharma-21 Apr 16, 2023
8086262
Commented out code
Bedrockdude10 Apr 16, 2023
74ca5fd
changing types of uint8
narayansharma-21 Apr 16, 2023
cde8a27
Wrote framework for createBook mutation test, added comment where we …
Bedrockdude10 Apr 17, 2023
5b0c60a
Handler for the controller - not sure how to integrate into the endpoint
narayansharma-21 Apr 17, 2023
a34fa72
Tried updating the userID endpoint to integrate the resolver - still …
narayansharma-21 Apr 18, 2023
6fab9ca
Added call to server.go in main
Bedrockdude10 Apr 18, 2023
d3b11e5
Changed package for server.go from main to server
Bedrockdude10 Apr 18, 2023
5c843b4
Needs accurate context paramter
Bedrockdude10 Apr 18, 2023
475ea19
Added global variables for resolver instances. Still need proper cont…
Bedrockdude10 Apr 18, 2023
1ad447a
fixed the type error of the endpoints
narayansharma-21 Apr 18, 2023
894ddc1
Got rid of repeated endpoint
narayansharma-21 Apr 18, 2023
0a4cab5
Comment out my one line addition
Bedrockdude10 Apr 19, 2023
639f35c
Updated controller to have a single query endpoint. Works for queries…
Bedrockdude10 Apr 19, 2023
03ff24a
Updated api mutation test
Bedrockdude10 Apr 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

remo-backend/.idea
remo-backend/.idea/vcs.xml
remo-backend/.idea/remo-backend.iml
remo-backend/.idea/modules.xml
5 changes: 5 additions & 0 deletions .gitignore 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

remo-backend/.idea
remo-backend/.idea/vcs.xml
remo-backend/.idea/remo-backend.iml
remo-backend/.idea/modules.xml
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
- db:/var/lib/mysql
ports:
# mapping host port 3200 to container port 3306
- 3213:3306
- 3333:3306

restart: unless-stopped
environment:
Expand Down
2 changes: 1 addition & 1 deletion remo-backend/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ tasks:
test-all:
- go test ./...
connect:
- mysql -u remo --password=pwd -P 3213 -h localhost --protocol=tcp
- mysql -u remo --password=pwd -P 3333 -h localhost --protocol=tcp
14 changes: 9 additions & 5 deletions remo-backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ module remo/backend
go 1.19

require (
github.com/99designs/gqlgen v0.17.22
github.com/99designs/gqlgen v0.17.24
github.com/gin-gonic/gin v1.8.2
github.com/huandu/go-assert v1.1.5
github.com/jinzhu/gorm v1.9.16
github.com/vektah/gqlparser/v2 v2.5.1
)

require (
github.com/agnivade/levenshtein v1.1.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/urfave/cli/v2 v2.8.1 // indirect
Expand All @@ -32,17 +35,18 @@ require (
github.com/go-playground/validator/v10 v10.11.1 // indirect
github.com/go-sql-driver/mysql v1.7.0
github.com/goccy/go-json v0.10.0 // indirect
github.com/golang-jwt/jwt/v4 v4.4.3
github.com/json-iterator/go v1.1.12 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/ugorji/go/codec v1.2.8 // indirect
golang.org/x/crypto v0.5.0
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/net v0.6.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
49 changes: 39 additions & 10 deletions remo-backend/go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
github.com/99designs/gqlgen v0.17.22 h1:TOcrF8t0T3I0za9JD3CB6ehq7dDEMjR9Onikf8Lc/04=
github.com/99designs/gqlgen v0.17.22/go.mod h1:BMhYIhe4bp7OlCo5I2PnowSK/Wimpv/YlxfNkqZGwLo=
github.com/99designs/gqlgen v0.17.24 h1:pcd/HFIoSdRvyADYQG2dHvQN2KZqX/nXzlVm6TMMq7E=
github.com/99designs/gqlgen v0.17.24/go.mod h1:BMhYIhe4bp7OlCo5I2PnowSK/Wimpv/YlxfNkqZGwLo=
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=
Expand All @@ -14,10 +16,14 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM=
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g=
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.8.2 h1:UzKToD9/PoFj/V4rvlKqTRKnQYyz8Sc1MJlv4JHPtvY=
Expand All @@ -31,20 +37,32 @@ github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/j
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ=
github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA=
github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU=
github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c=
github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U=
github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o=
github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M=
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kevinmbeaulieu/eq-go v1.0.0/go.mod h1:G3S8ajA56gKBZm4UB9AOyoOS37JO3roToPzKNM8dtdM=
Expand All @@ -58,12 +76,16 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc=
github.com/matryer/moq v0.2.7/go.mod h1:kITsx543GOENm48TUAQyJ9+SAvFSr7iGQXPoth/VUBk=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA=
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down Expand Up @@ -105,24 +127,32 @@ github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsr
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/net v0.6.0 h1:L4ZwwTvKW9gr0ZMS1yrHD9GZhIuVjOBBnaKH+SPQK0Q=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -131,17 +161,17 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
Expand All @@ -150,7 +180,6 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
Expand Down
117 changes: 117 additions & 0 deletions remo-backend/graph/api_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package graph

// query {
// getBookByISBN(isbn: 9781525303890) {
// id
// isbn_13
// title
// author
// }
// }
// ngrok http 8080
// postman URL: https://ea01-155-33-132-61.ngrok.io
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"testing"
)

// the url generated by ngrok. Needs to be refreshed every hour
var queryEndpointURL = "https://ea01-155-33-132-61.ngrok.io"

// TESTS NEEDED
// accurate get requests
// accurate post requests

// test for getting books by ISBN request
// technically a POST request because we're sending a JSON, but performs the function of a GET request
func TestAPIGetBookByISBN(t *testing.T) {

// below request and response JSONs were collected from postman
query := `query {
getBookByISBN(isbn: 9781525303890) {
isbn_13
id
author
num_pages
}
}`

request := struct {
Query string `json:"query"`
}{Query: query}

requestBody, err := json.Marshal(request)
if err != nil {
t.Errorf("Unable to marshal request into JSON: %q", err)
}

// "application/json"
response, err := http.Post(queryEndpointURL+"/v1/query", "application/json", bytes.NewBuffer(requestBody))
if err != nil {
t.Errorf("Unable to complete POST request properly: %q", err)
}

defer response.Body.Close()

var result map[string]interface{}

err = json.NewDecoder(response.Body).Decode(&result)

if err != nil {
t.Errorf("Unable to decode request from JSON: %q", err)
}

fmt.Println(result)
}

func TestAPICreateBook(t *testing.T) {

// below request and response JSONs were collected from postman
// mutation query request

//************************************************************
// INCOMPLETE. MUST FINISH QUERY - MAKE SURE BOOK INPUT IS PROPERLY FORMATTED
// ASK CHATGPT OR BOOT UP PLAYGROUND

query := `mutation {
createBook (input: {
id: 1
default_user_id: 1
story_id: 1
}){
id
default_user_id
story_id
}
}
}`

request := struct {
Query string `json:"query"`
}{Query: query}

requestBody, err := json.Marshal(request)
if err != nil {
t.Errorf("Unable to marshal request into JSON: %q", err)
}

response, err := http.Post(queryEndpointURL, "application/json", bytes.NewBuffer(requestBody))
if err != nil {
t.Errorf("Unable to complete POST request properly: %q", err)
}

defer response.Body.Close()

var result map[string]interface{}

err = json.NewDecoder(response.Body).Decode(&result)

if err != nil {
t.Errorf("Unable to decode request from JSON: %q", err)
}

fmt.Println(result)
}
Loading