hygraph / gatsby-source-graphcms

The official Gatsby source plugin for GraphCMS projects
https://graphcms.com
MIT License
145 stars 41 forks source link

Refactor creation of headers #57

Closed chrisbuttery closed 6 years ago

chrisbuttery commented 6 years ago

This PR refactors how headers are created.

I found the existing method cause Authorization errors regardless if the dashboard URL was public, or was protected and a token was provided.

// This is the response from an 'open' URL

Error: Not Authorised!: {"response":{"errors":[{"message":"Not Authorised!","locations":[{"line":2,"column":11}],"path  ":["pages"]}],"data":null,"status":500},"request":{"query":"{\n          pages {\n            id\n            title\n            }\n        }"}}
// This is the response from a 'protected' URL with a token provided

TypeError: Cannot read property '1' of null


This proposed change only includes headers keys if their values are provided.

Redmega commented 6 years ago

Interesting, I didn't face those issues when using public or private endpoints. It may be something related to the new GraphCMS beta? Or I'm wondering if it's something platform specific? What OS / version are you on?

In any case, code looks fine. I'll do some testing tonight get it merged.

chrisbuttery commented 6 years ago

@Redmega These points have been addressed. Let me know if you require anything else. 👍

Redmega commented 6 years ago

Deployed as v1.0.0-alpha.3!

github-actions[bot] commented 4 years ago

:tada: This PR is included in version 0.1.0-next.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: