Fix post-jdbc.core-migration problems (column names, upsert, position… #3
+24
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, after reading the tutorial up to
Testing, Phase 1
part (so far well-written IMO!), I gave thisclojure-game-geek
repository a try in order to be able to play with GraphiQL a bit.Unfortunately, the codebase didn't really work for me and I had to fix a few issues in order to be able to successfully use GraphiQL with all the subgraph fetches & mutations working. I'm not sure if the changes are correct and complete, but they worked for me, so I'm sharing them.
Here's what I had to fix:
db.clj
: some SQL queries used parameters such as $1. According to git log, is seems thatpostgres.async
was used in the past and it supports such form of positional query parameters. But injava.jdbc
, one has to use simpler?
form (and pass the same value multiple times if present multiple times in statement, such as in case ofrating
inupsert-game-rating
).cgg-schema.edn
: had to change:member_name
to:name
in:Member
object, as the column inmember
table is called justname
, notmember_name
db.clj
: had to addexecute!
function and use it insideupsert-game-rating
instead ofquery
. Otherwise (whenquery
function was used) the update part of the statement would actually be executed successfully, but since it returned no result, thequery
function itself would then immediately fail.schema.clj
: had to modify(:id board-game)
to(:game_id board-game)
etc as columns in db are calledgame_id
,designer_id
etc.setup-db.sh
: had to add unique constraint on combination of columnsgame_id
+member_id
ofgame_rating
table. Otherwise theon conflict (game_id, member_id) do update set rating = ?
part ofupsert-game-rating
function would crash due to missing uniqe constraint.After mentioned changes, I'm able to perform following GraphQL mutation...
Request:
Response:
... and also following query:
Request: