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

    nilan

    12/04/2016, 9:52 AM
    hey henny, what client are you using? simple smile
  • h

    henny

    12/04/2016, 9:52 AM
    I started with your Angular/Apollo example for Instagram and changed it to my needs.
  • n

    nilan

    12/04/2016, 9:53 AM
    ok let's continue in DM simple smile
  • g

    geocine

    12/04/2016, 2:03 PM
    I cannot seem to update the permissions for my graphql model from
    Everyone
    to
    Authenticated
    when I click on
    Update Permissions
    looks like nothing is happening. Do I have to do something else?
  • g

    geocine

    12/04/2016, 2:05 PM
    I checked the mutation request for the
    updateModelPremission
    this is what I see
    Copy code
    {
      "data": {
        "updateModelPermission": null
      },
      "errors": [
        {
          "message": "Whoops. Looks like an internal server error. Please contact us in Slack (<https://slack.graph.cool>) and send us your Request ID: ciwapysm816aa0187je7lyj7r",
          "requestId": "ciwapysm816aa0187je7lyj7r",
          "path": [
            "updateModelPermission"
          ],
          "locations": [
            {
              "line": 1,
              "column": 74
            }
          ]
        }
      ]
    }
  • n

    nilan

    12/04/2016, 2:11 PM
    hey @geocine thanks for the report! for now it should work to disable this permission and create a complete new one. can you create an issue at http://github.com/graphcool/console/issues?
  • g

    geocine

    12/04/2016, 3:07 PM
    @nilan disabling the permission returns about the same error
    Copy code
    {
      "data": {
        "updateModelPermission": null
      },
      "errors": [
        {
          "message": "Whoops. Looks like an internal server error. Please contact us in Slack (<https://slack.graph.cool>) and send us your Request ID: ciwas7bkv16wa0187ym4xmmip",
          "requestId": "ciwas7bkv16wa0187ym4xmmip",
          "path": [
            "updateModelPermission"
          ],
          "locations": [
            {
              "line": 1,
              "column": 80
            }
          ]
        }
      ]
    }
    Also it is really intended to return an HTTP 200 for errors?
  • n

    nilan

    12/04/2016, 3:08 PM
    hey I noticed you are working on the dev environment simple smile use https://console.graph.cool
  • g

    geocine

    12/04/2016, 3:09 PM
    oh thanks, I did not know how I got here 🙂
  • n

    nilan

    12/04/2016, 3:17 PM
    we are intentionally returning 200 even if errors occured during executing your queries and use the
    errors
    object to inform the consumer. if you do a bad-formed query, we return 400 for example, because we cannot execute a bad-formed query.
  • g

    geocine

    12/04/2016, 3:23 PM
    that makes sense. that is why apollo has that .catch function for the http 200 errors.. and the reject block for malformed queries am I right?
  • n

    nilan

    12/04/2016, 3:23 PM
    I am not familiar with the reject block, but the first part is correct simple smile
  • n

    nilan

    12/04/2016, 3:24 PM
    you can read more reasoning for this here: https://facebook.github.io/graphql/#sec-Response-Format
  • n

    nilan

    12/04/2016, 3:25 PM
    for example, imagine where you query multiple fields, but you are only allowed to query some of them. the question is how should it be handled?
  • n

    nilan

    12/04/2016, 3:25 PM
    with GraphQL we can resolve the fields that you are allowed to read in
    data
    , and return a "Insufficient permissions" error in
    errors
    simple smile
  • n

    nilan

    12/04/2016, 3:25 PM
    so we see that really, the http status code is not related to the existence of errors
  • g

    geocine

    12/04/2016, 3:26 PM
    what I meant was the onrejected event of the promise. thank you will definitely read it
  • n

    nilan

    12/04/2016, 3:26 PM
    ahh cool. have to check that out. makes a lot of sense 👍
  • t

    tmoney

    12/05/2016, 7:32 AM
    Hey anybody here have success implementing the optimisticUpdate feature of apollo client with graph.cool, running into a snag with the
    dataIdFromObject
    . Keep getting an error that there is no id on the result object, since I’m trying to check for
    result.id
  • e

    emilrmoeller

    12/05/2016, 7:42 AM
    hey @tmoney yeah i had no issues using it, it’s pretty weird from times to times though, but it’s not because of graph.cool. The objects in the list or where you push to has to be exactly identically in fields. Also if it’s for example a `createComment`mutation, you need to add a temporary id to the optimistic response object. So if the list of comments are
    Copy code
    [{id: ‘123’, name: ‘name 1’}, {id: ‘456’, name: ‘name 2’}]
    Then the optimistic response needs to be
    Copy code
    {id: ‘something random which doesnt matter’, ‘the new name’}
    And the mutation result
    Copy code
    {id: ‘789’, ‘the new name’}
  • t

    tmoney

    12/05/2016, 7:47 AM
    I was literally just about to try adding a random id just now haha, I’ll see if that does the trick
  • t

    tmoney

    12/05/2016, 7:48 AM
    I just saw in the githunt example they set it to
    null
    , when I do that it errors out
  • e

    emilrmoeller

    12/05/2016, 7:51 AM
    haha alright, i didn’t see the githunt example for it, so i got the same error as you hehe
  • e

    emilrmoeller

    12/05/2016, 7:51 AM
    i don’t write null, ill write ‘blabla’ haha
  • t

    tmoney

    12/05/2016, 7:54 AM
    hmm shoot it looks like it’s hitting the
    dataIdFromObject
    twice, the first time around it has it, second time around the entire result is undefined. Any reason why that should ever be undefined? Cause if so I could just do a null check on it, but all the examples act as if it should never be undefined
  • t

    tmoney

    12/05/2016, 7:55 AM
    Copy code
    const InventoryWithData = graphql(ADD_ITEM_MUTATION, {
        props({ ownProps, mutate }) {
            return {
                addItem({ description, image, price, purchaseDate, quantity, size, type, wholesale }) {
                    return mutate({
                        variables: { description, image, price, purchaseDate, quantity, size, type, wholesale },
                        optimisticResponse: {
                            __typename: 'Mutation',
                            createItem: {
                                __typename: 'Item',
                                id: 'newTempId'
                            }
                        },
                        updateQueries: {
                            AllItems: (previousResult, { mutationResult }) => {
                                debugger;
                                const newItem = mutationResult.data.addItem;
                                return update(previousResult, {
                                    allItems: {
                                        $unshift: [newItem]
                                    }
                                });
                            }
                        }
                    });
                }
            };
        }
    })(
        graphql(ITEM_QUERY)(Inventory)
    );
  • t

    tmoney

    12/05/2016, 7:55 AM
    Copy code
    dataIdFromObject: (result) => {
            if (result.id && result.__typename) { // eslint-disable-line no-underscore-dangle
                return result.__typename + result.id; // eslint-disable-line no-underscore-dangle
            }
            return null;
        },
  • t

    tmoney

    12/05/2016, 7:59 AM
    And also here’s the query:
    Copy code
    const ADD_ITEM_MUTATION = gql`
        mutation addItem(
                $description: String,
                $image: String,
                $price: BigDecimal!,
                $purchaseDate: DateTime!,
                $quantity: Int,
                $size: ITEM_SIZE!,
                $type: ITEM_TYPE!,
                $wholesale: BigDecimal!
        ){
            createItem(
                description: $description,
                image: $image,
                price: $price,
                purchaseDate: $purchaseDate,
                quantity: $quantity,
                size: $size,
                type: $type,
                wholesale: $wholesale
            ) { id, __typename }
        }
    `;
  • t

    tmoney

    12/05/2016, 7:59 AM
    Anything seem off here?
  • n

    nilan

    12/05/2016, 8:04 AM
    can you try not returning the typename in dataIdFromObject?
1...565758...637Latest