How to send graphql query by postman?

前端 未结 14 826
情歌与酒
情歌与酒 2020-11-29 16:19

I use

POST type
URL http://######/graphql
Body: 
query: \"query: \"{\'noteTypes\':  {\'name\', \'label\', \'labelColor\', \'groupName\', \'groupLabel\', \'i         


        
14条回答
  •  心在旅途
    2020-11-29 16:56

    There's a simple way to do it. Use a pre-request script to stringify the payload (source).

    Step 1.

    In the body of the request put a placeholder for the payload.

    {
        "query":{{query}}
    }
    

    Step 2.

    Create the payload in the pre-request script and store it in an environment variable.

    postman.setEnvironmentVariable("query", JSON.stringify(
    `
    {
      search(query: "test", type: ISSUE, first: 10) {
        issueCount
        edges {
          node {
            ... on Issue {
              title
              id
              state
              closed
              repository {
                name
              }
            }
          }
        }
      }
    }
    `
    ));
    

    That's it.

提交回复
热议问题