Skip to content

graphql queries verification broken with graphql-tag #254

@tomasAlabes

Description

@tomasAlabes

Software versions

  • OS: e.g. Mac OSX 10.11.5
  • Consumer Pact library: e.g. Pact JS v7.0.4
  • Node Version: 10.13.0

Expected behaviour

Related to #243

When using the graphql-tag package like in the graphql example:

const gql = require("graphql-tag");

const client = /* ... */

function query() {
	return client.query({
		query: gql`{ hello }`
	})
	.then(result => result.data);
};

Actual behaviour

With graphql-tag, when the query doesn't have variables, the post is done with

"body" : {
   "query" : "...",
   "variables": {}
}

and without operation:

"body" : {
   "query" : "...",
    "operationName": null
}

With the latest commit, now those attributes are not part of the body, hence the verification fails. As the tests are written with manual queries and not with the graphql-tag package, tests are sucessfull.

Steps to reproduce

Just remove the variables of the example in this repo and the example fails to verify.

Relevant log files

Matching keys and values are not shown
 {
   "body": {
+    "operationName": null
   }
 }
Matching keys and values are not shown

 {
   "body": {
+    "variables": {
+    }
   }
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions