Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParseIDs middleware cannot find schema_node on subsequent input field #175

Open
mjquinlan2000 opened this issue Jan 19, 2021 · 0 comments
Open

Comments

@mjquinlan2000
Copy link

I believe that we have encountered a bug with the ParseIDs middleware and it may be related to #72

I have a definition that roughly mirrors this:

  input_object(:post_comments_input) do
    field(:posted_by_user_id, :id)
  end

  connection(:comments, node_type: :comment) do
    field(:total_count, non_null(:integer), resolve: &count_resolver/3)
    edge(do: nil)
  end

  node object(:comment) do
    field(:body, non_null(:string))
  end

  node object(:post) do
    connection field(:comments, node_type: :comments) do
      # I like to put query args in an input object because I can deprecate the fields
      arg(:input, :post_comments_input)

      # This is the problem area when calling updatePost
      middleware(Absinthe.Relay.Node.ParseIDs, input: [posted_by_user_id: :user])
      resolve(&resolve_it/2)
    end
  end

  payload field(:update_post) do
    middleware(Absinthe.Relay.Node.ParseIDs, post_id: :post)

    input do
      field(:post_id, :id)
      field(:body, :string)
    end

    output do
      field(:post, non_null(:post))
    end

    reslovlve(&upate_it/2)
  end

When I call the node query with posts there are no problems:

  query TestQuery($input:PostCommentsInput,$id:ID!) {
    post: node(id:$id) {
      ... on Post {
        comments(first:0,input:$input) {
          totalCount
        }
      }
    }
  }

The problem I am seeing happens when I use the updatePost mutation and then resolve the Post.comments connection like so:

  mutation TestMutation($input:UpdatePostInput!) {
    updatePost(input:$input) {
      post {
        comments(first:0) {
          totalCount
        }
      }
    }
  }

I get an error returned that states:

{
  "data": {
    "updatePost": {
      "post": {
        "comments": null
      }
    }
  },
  "errors": [
    {
      "message": "Could not find schema_node for input",
      "path": [
        "updatePost",
        "post",
        "comments"
      ]
    }
  ]
}

I have circumvented this problem by not using the ParseIDs middleware and manually parsing the IDs, but it is not a scalable solution. I am planning to write custom middleware for this scenario, but I'd rather not. It seems like something ParseIDs should support.

Let me know if I can help clarify this any further. I know it is not a typical use-case. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant