DEV Community

Discussion on: How to make a GraphQL Query (or Mutation!) in PHP with Guzzle

Collapse
 
skino2020 profile image
skino • Edited

Im having a bit of trouble getting this to work within my Laravel application. Im trying to use the Hashnode API to post from my blog. ive got Dev.to and Medium both working perfectly.

this is my query:

        $query           = <<<GQL
mutation {
  createStory(
    input: {
      title: "$post->title"
      contentMarkdown: "<h1> Ahoy </h1>"
      tags: [
        {
          _id: "56744721958ef13879b94c7e"
          name: "General Programming"
          slug: "programming"
        }
      ]
    }
  ) {
    message
    post {
      title
    }
  }
}
GQL;
Enter fullscreen mode Exit fullscreen mode

Ignore the Tags for the moment i haven got that far yet. where you have the h1 tags i want to use a variable called $markdown which is and entire post from my blog converted to markdown. Never gets passed that stage and gives me this error.

[2021-10-16 23:11:52] production.ERROR: Client error: POST https://api.hashnode.com/ resulted in a 400 Bad Request response:
{"errors":[{"message":"Syntax Error: Unterminated string.","locations":[{"line":5,"column":40}],"extensions":{"code":"GR (truncated...)

Cheers, Mike