https://www.prisma.io/ logo
Join Slack
Powered by
# prisma-whats-new
  • u

    user

    04/27/2017, 8:29 AM
    @sorenbs commented on @theom’s file

    https://prisma.slack.com/files/U4KKMFVK2/F557PGTL3/no_websocket_connection_made.jpg▾

    : Hi @theom Can you try to start the same subscription from the Playground on console.graph.cool to verify that the query is correct?
  • a

    artyom

    04/27/2017, 8:33 AM
    @riconegri @bouncetribe @hardys @jt9001 @sfteague hello there and welcome to graphcool thanks for joining us! 🙇 🙂
  • h

    hardys

    04/27/2017, 8:51 AM
    Just created my first schema ^^ pretty cool
    a
    • 2
    • 1
  • s

    samuell

    04/27/2017, 8:52 AM
    Hey cool guys ! 😄
  • a

    artyom

    04/27/2017, 8:54 AM
    guys and girls 😉 hey @samuell 👋 welcome to graphcool and our slack! 🎉
  • s

    samuell

    04/27/2017, 9:00 AM
    https://demo.graph.cool/worldchat/ is broken ? 😄
    n
    • 2
    • 1
  • u

    user

    04/27/2017, 9:23 AM
    @theom commented on @theom’s file

    https://prisma.slack.com/files/U4KKMFVK2/F557PGTL3/no_websocket_connection_made.jpg▾

    : @sorenbs Yes. The subscription activates successfully from playground when the mutation is triggered from my app.
  • u

    user

    04/27/2017, 9:35 AM
    @theom commented on @theom’s file

    https://prisma.slack.com/files/U4KKMFVK2/F557PGTL3/no_websocket_connection_made.jpg▾

    : The subscription in question is:
    Copy code
    export const Subscription_Add_Delete_Comment_Query = gql`
      subscription CreateDeleteComment {
        Comments(
          filter: {
            mutation_in: [CREATED, DELETED]
          }
        ) {
          node {
            id
            text
            user
            deleted
            posts {
              id
            }
          }
        }
      }
    `;
  • u

    user

    04/27/2017, 9:47 AM
    @rtowarek commented on @rtowarek’s file

    https://prisma.slack.com/files/U54PXSN04/F557HPF1R/graph.gif▾

    : @sorenbs Yup. Here it is: https://github.com/graphcool/console/issues/868
  • u

    user

    04/27/2017, 10:25 AM
    @sorenbs commented on @theom’s file

    https://prisma.slack.com/files/U4KKMFVK2/F557PGTL3/no_websocket_connection_made.jpg▾

    : Maybe @tim can spot the issue? (the query works in the playground)
  • n

    nish

    04/27/2017, 10:57 AM
    Hi, I remember people having problems in the past when naming their fields ending with Id. For e.g CustomerId, OrderId and trying to map the relation with other models. Is that still an issue?
    n
    • 2
    • 7
  • a

    artyom

    04/27/2017, 11:25 AM
    Wave @dunghd.it @pettanko @danielvdm welcome!
  • r

    richashby

    04/27/2017, 11:30 AM
    Hi there, thanks for the invite.
  • d

    danielvdm

    04/27/2017, 11:32 AM
    hi
    🙌 1
  • u

    user

    04/27/2017, 11:36 AM
    @tim2 commented on @theom’s file

    https://prisma.slack.com/files/U4KKMFVK2/F557PGTL3/no_websocket_connection_made.jpg▾

    : @theom I can’t see the issue in the code on the first sight. It’s obvious that the issue is the code and not the subscription query itself. 2 things that you can do to gain more insight: 1. in the chrome devtools it’s great that you’re already in the WS tab. From there please click on the one request to our api. you will see all ws messages that have been sent. Please post us a screenshot of that so we can see if that part works correctly. 2. option: provide us a link to reproducible example, so we can test it (you can send me that per PM)
  • a

    artyom

    04/27/2017, 11:56 AM
    hi @richashby great to see you here! hello @vitaliiznak as well 🙌 graphcool
  • t

    theom

    04/27/2017, 11:57 AM
    @tim2 As requested, and please excuse me starting a new thread as I can't figure out how to attach an image to an ongoing thread?, I have attached the websocket image you requested. I obtained the code to establish a websocket from https://www.graph.cool/docs/tutorials/worldchat-subscriptions-example-ui0eizishe/#setting-up-the-apollo-client-to-use-subscriptions
  • u

    user

    04/27/2017, 11:58 AM
    @tim2 commented on @theom’s file

    https://prisma.slack.com/files/U4KKMFVK2/F566NTPPG/initial_websocket_connection.jpg▾

    : @theom awesome! One last wish: Please click on
    Frames
    and screenshot that one
  • t

    theom

    04/27/2017, 12:05 PM
    @tim2 As requested I have attached the frames screenshot.
  • u

    user

    04/27/2017, 12:22 PM
    @tim2 commented on @theom’s file

    https://prisma.slack.com/files/U4KKMFVK2/F5674LFAB/websocket_frames.jpg▾

    : @theom perfect! As you can see there comes a
    data
    event, so the subscription works 🙂 Now we need to find out why the callback in apollo is not called
  • s

    sdubois

    04/27/2017, 12:26 PM
    Hi! I'm trying to create a new permission without any custom Permission Query (just a basic read for everyone) but the UI seems to prevent this?
  • u

    user

    04/27/2017, 12:26 PM
    @tim2 commented on @theom’s file

    https://prisma.slack.com/files/U4KKMFVK2/F5674LFAB/websocket_frames.jpg▾

    : @theom Ok so the most important point why you don’t see any change is because in
    updateQuery
    you currently return the
    previousState
    . Actually you need to merge the new data into the previous state and return that new merged object.
  • s

    sdubois

    04/27/2017, 12:27 PM
  • u

    user

    04/27/2017, 12:29 PM
    @tim2 commented on @sdubois’s file

    https://prisma.slack.com/files/U2HEKAQ79/F55CRB21G/screen_shot_2017-04-27_at_15.25.41.png▾

    : Oops, thats a responsiveness issue, we should make it possible for smaller screen sizes. **cmd**+ - to make the site smaller in chrome should be a quick fix
  • u

    user

    04/27/2017, 12:36 PM
    @theom commented on @theom’s file

    https://prisma.slack.com/files/U4KKMFVK2/F5674LFAB/websocket_frames.jpg▾

    : @tim2 Ok, So I have made a minor adjustment to my code, but I thought, and as previousState is already correctly reflecting changes made by the mutations, all I needed to do was to return previousState as is? My currecnt code is as follows:
    Copy code
    isDuplicateComment(newComment, existingComments) {
        let duplicateComment = false;
        existingComments.forEach((comment) => {
          if (newComment.id !== null && newComment.id === comment.id) {
            duplicateComment = true;
          }
        });
        console.log('duplicateComment = ', duplicateComment);
        return duplicateComment;
      },
      subscribe() {
        const postIndexID = this.props.postIndexID;
    
        return this.subscriptionObserver = this.props.data.subscribeToMore({
          document: Subscription_Add_Delete_Comment_Query,
          updateQuery: (previousState, {subscriptionData}) => {
            // The mutations allways update the Root_Tree, so the newComment will already exist in previousState.
            // So you just need to return the previousState as is
            console.log('previousState = ', previousState);
            console.log('subscriptionData = ', subscriptionData);
    
            // Ascertain whether the mutation fired was created or deleted 
            if (subscriptionData.data.Comments.mutation === 'CREATED') {
              // Ascertain whether the current record has already been added to the ROOT_TREE.
              // If so, just return previousState as is.
              const newComment = subscriptionData.data.Comments.node;
              if (this.isDuplicateComment(newComment, previousState.allPostses[postIndexID].comments)) {
                return previousState;
              }else {
                // const Comments = previousState.allPostses[postIndexID].comments.concat([newComment]); // If adding a new comment to Root_Query
                // return Comments;
              }
            } else if (subscriptionData.data.Comments.mutation === 'DELETED') {
              return {
                allPostses: previousState.allPostses
              }
            }
          },
          onError: (err) => console.error(err),
        });
      },
    My mutations are as follows:
    Copy code
    export const Add_Comment_Mutation = gql`
      mutation createComment ($id: ID, $textVal: String!, $userVal: String!) {
        createComments (postsId: $id, text: $textVal, user: $userVal){
          __typename
          id
          text
          user
          deleted
          posts {
            __typename
            id
          }
        }
      }
    `;
    
    export const Remove_Comment_Mutation = gql`
      mutation removeComment ($id: ID!, $cid: ID!) {
        removeFromPostsOnComments (postsPostsId: $id, commentsCommentsId: $cid) {
          postsPosts {
            __typename
            id
            comments {
              __typename
              id
              text
              user
              deleted
              posts {
                __typename
                id
              }
            }
          }
        }
    
        deleteComments(id: $cid) {
          id
        }
      }
    `;
  • s

    sdubois

    04/27/2017, 12:40 PM
  • u

    user

    04/27/2017, 12:40 PM
    @tim2 commented on @theom’s file

    https://prisma.slack.com/files/U4KKMFVK2/F5674LFAB/websocket_frames.jpg▾

    : @theom yes, if the mutation has been executed on the same client, returning previousState in the subscription is fine (in other words: ignoring the result of the subscription in the client where the mutation happend). however, other clients need to apply the changes to the previousState as they didn’t execute the mutation. I like to think of a subscription as a mutation that didn’t happen here. That means: You have to check if THIS client executed the mutation, if not, apply the changes that come through the subscription
  • u

    user

    04/27/2017, 1:18 PM
    @theom commented on @theom’s file

    https://prisma.slack.com/files/U4KKMFVK2/F5674LFAB/websocket_frames.jpg▾

    :
    Copy code
    That means: You have to check if THIS client executed the mutation, if not, apply the changes that come through the subscription
    Ok, so this is the part that I'm confused about. Can you show me how this is done?
  • u

    user

    04/27/2017, 1:45 PM
    @tim2 commented on @theom’s file

    https://prisma.slack.com/files/U4KKMFVK2/F5674LFAB/websocket_frames.jpg▾

    : Yeah I described that more complicated than necessary. The easiest approach is to make sure that the mutation is not updating the apollo store. Then you always take the change of the subscription.
  • u

    user

    04/27/2017, 1:51 PM
    @tim2 commented on @theom’s file

    https://prisma.slack.com/files/U4KKMFVK2/F5674LFAB/websocket_frames.jpg▾

    : That means, just remove the updateQuery of your mutation but update the state in updateQuery of your subscription
1...167168169...637Latest