webtau icon indicating copy to clipboard operation
webtau copied to clipboard

GraphQL - error when asserting on fields not in schema

Open tsiq-karold opened this issue 5 years ago • 3 comments

If one is asserting that a field is null and makes a typo in the field name then the test will always pass even if the field comes back non-null.

We should validate that the assertion is being made against a field which is actually part of the schema. In GraphQL, this will require us to fetch more data via introspection because we need to check for field names in the return objects rather than in the query.

We will also need to provide a way to turn off this behaviour should someone really want to assert something that does not exist in the schema. e.g.

graphql.execute(query) {
  suppressUnknownFieldErrors {
    somethingNotInSchema.should == 'foo'
  }
}

tsiq-karold avatar Aug 18 '20 19:08 tsiq-karold

Nice

MykolaGolubyev avatar Aug 18 '20 19:08 MykolaGolubyev

@tsiq-karold any remaining motivation for this?

MykolaGolubyev avatar May 19 '22 16:05 MykolaGolubyev

@tsiq-karold any remaining motivation for this?

Not right now, no.

tsiq-karold avatar May 20 '22 10:05 tsiq-karold

closing as not active

MykolaGolubyev avatar Jan 06 '23 17:01 MykolaGolubyev