Skip to content
Snippets Groups Projects

refactor follow, unfollow, shout, unshout to custom mutations, but don't add date-time to relation yet

Closed Hannes Heine requested to merge pr449head into pr449base

Created by: Tirokk

Tirokk Authored by Tirokk Merged


Together with @mattwr18 . :smile:

Pullrequest

Issues

  • relates #219 (closed)
  • Customises mutations follow, unfollow, shout, unshout.
  • Add date-time to relation.

How2Test

  • $ docker-compose exec backend yarn test:jest backend/src/resolvers/follow.spec.js backend/src/resolvers/shout.spec.js

Merge request reports

Closed by avatar (Jul 6, 2025 6:51pm UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 export default {
2 Mutation: {
3 shout: async (_object, params, context, _resolveInfo) => {
4 const { id, type } = params
5
6 const session = context.driver.session()
7 let transactionRes = await session.run(
  • Created by: Tirokk

    mattwr18 Authored by mattwr18


    Outdated (history rewrite) - original diff


    @@ -0,0 +1,51 @@
    +export default {
    +  Mutation: {
    +    shout: async (_object, params, context, _resolveInfo) => {
    +      const { id, type } = params
    +
    +      const session = context.driver.session()
    +      let sessionRes = await session.run(

    I don't love the name sessionRes I feel like we should be naming it what is the actual result, which would tempt me to name it isShouted, but then I see on line 19, we seem to get a list of records back that we then need to grab isShouted from.

    I was having a read here https://neo4j.com/docs/driver-manual/current/sessions-transactions/, and it seems the result is from the transaction, not the session. Maybe it would be better transactionRes, but maybe I'm just being pedantic, and can be ignored.

  • Created by: Tirokk

    Tirokk Authored by Tirokk


    I am really happy to rename sessionRes to ´transactionRes´ @mattwr18 . That is a very good clarification we can use in the future for all customised mutations. :hugging:

    I am happy especially if there is nothing else to mention from your side. :grin:

  • Hannes Heine
    Hannes Heine @Elweyn started a thread on commit 9929aa46
  • 1 export default {
    2 Mutation: {
    3 shout: async (_object, params, context, _resolveInfo) => {
    4 const { id, type } = params
    5
    6 const session = context.driver.session()
    7 let transactionRes = await session.run(
    8 `MATCH (node {id: $id})<-[:WROTE]-(userWritten:User), (user:User {id: $userId})
    9 WHERE $type IN labels(node) AND NOT userWritten.id = $userId
    • Created by: Tirokk

      roschaefer Authored by roschaefer


      Outdated (history rewrite) - original diff


      @@ -0,0 +1,51 @@
      +export default {
      +  Mutation: {
      +    shout: async (_object, params, context, _resolveInfo) => {
      +      const { id, type } = params
      +
      +      const session = context.driver.session()
      +      let transactionRes = await session.run(
      +        `MATCH (node {id: $id})<-[:WROTE]-(userWritten:User), (user:User {id: $userId})
      +          WHERE $type IN labels(node) AND NOT userWritten.id = $userId

      A future improvement could be that you can omit the ShoutTypeEnum. I mean: The server knows what you can shout and what not, right? So, instead of having the type of the shouted object sent to the server, you just send the id and the server checks if the labels of the matched, shouted object intersects with a well-known set of shoutable objects (by a set of labels ['Project', 'Post', ...]).

      For now it is fine though!

    • Created by: Tirokk

      Tirokk Authored by Tirokk


      That is a concurrence between two things:

      • KISS: Keep it stupid simple …
      • But redundancy may be good for think and error checking: What type has the Webapp programmer thought to be shouted or followed and does this fit to what can be … on the server side?

      I think you just like to KISS … :kissing_heart: !?

    • Created by: Tirokk

      Lulalaby Authored by Lulalaby


      :laughing:

  • Created by: Mogge

    Review: Approved

    great job @Tirokk

  • Created by: Mogge

    Review: Approved

    It's just a refactoring after all, right? In that case: If the build server says :heavy_check_mark: I say :ok:

    That's the blessing of a reliable test setup: Refactor with confide :muscle:

  • Please register or sign in to reply
    Loading