Skip to content

Conversation

@h3ssan
Copy link
Contributor

@h3ssan h3ssan commented Aug 26, 2024

Overview

In this PR, I did Implement the TODO in src/handler.ts, which is to make sure the contents of init match ResponseInit.

The implemented code:

/** Checks whether the passed value is the `graphql-http` server agnostic response. */
function isResponse(val: unknown): val is Response {
  // Make sure the contents of body match string | null
  if (!Array.isArray(val)) return false;
  if (typeof val[0] !== 'string' || val[0] !== null) return false;
  if (!isObject(val[1])) return false;

  // Make sure the contents of init match ResponseInit
  const init = val[1];
  if (typeof init.status !== 'number') return false;
  if (typeof init.statusText !== 'string') return false;
  if (init.headers && !isObject(init.headers)) return false;

  return true;
}

Please test the implemented code further more. Thank you!

Copy link
Member

@enisdenjo enisdenjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤩

@enisdenjo enisdenjo merged commit 2187f0d into graphql:main Aug 27, 2024
@h3ssan h3ssan deleted the fix/todo-check-value-is-response branch August 27, 2024 10:16
enisdenjo added a commit that referenced this pull request Aug 27, 2024
@enisdenjo
Copy link
Member

🎉 This PR is included in version 1.22.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Has been released and published

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants