Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby-source-graphql) Execute functions in header. #20731

Merged
merged 2 commits into from
Jan 21, 2020

Conversation

etylermoss
Copy link
Contributor

Description

Allows functions to be passed in the headers object, so that async functions may be used to set the value of headers.

Useful to get the value of the Authorization header before the graphql source is queried (i.e resulting in null data).

Related Issues

Fixes #20690

Resolves issue gatsbyjs#20690, allowing the use of async functions to define
headers for gatsby-source-graphql. To use, functions can be passed in
the headers object, i.e: headers { authorization: asyncFunc }.
Copy link
Contributor

@freiksenet freiksenet left a comment

Choose a reason for hiding this comment

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

Thank you for this PR!

I think it would be better if whole headers parameter accepted async function, they are often interdependent. After that change I'd be happy to approve.

See gatsbyjs#20731. Updated README.md to
include new (optional) syntax.
@etylermoss etylermoss requested a review from freiksenet January 21, 2020 13:38
@freiksenet
Copy link
Contributor

Thank you @ajmar!

@freiksenet freiksenet added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Jan 21, 2020
@gatsbybot gatsbybot merged commit 99f002b into gatsbyjs:master Jan 21, 2020
@gatsbot
Copy link

gatsbot bot commented Jan 21, 2020

Holy buckets, @ajmar — we just merged your PR to Gatsby! 💪💜

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. We’ve got Gatsby t-shirts, stickers, hats, scrunchies, and much more. (You can also unlock even more free swag with 5 contributions — wink wink nudge nudge.) See gatsby.dev/swag for details.
  2. We just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. Accept the invite by visiting https://github.com/orgs/gatsbyjs/invitation. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again!

@etylermoss etylermoss deleted the async-headers branch January 21, 2020 14:05
gatsbybot added a commit to gatsbyjs/gatsby-starter-blog that referenced this pull request Jan 21, 2020
* feat(gatsby-source-graphql) Execute functions in headers.

Resolves issue #20690, allowing the use of async functions to define
headers for gatsby-source-graphql. To use, functions can be passed in
the headers object, i.e: headers { authorization: asyncFunc }.

* Changes whole headers parameter to accept async function.

See gatsbyjs/gatsby#20731. Updated README.md to
include new (optional) syntax.
leonhiat added a commit to leonhiat/gatsby-starter-blog that referenced this pull request Oct 31, 2023
* feat(gatsby-source-graphql) Execute functions in headers.

Resolves issue #20690, allowing the use of async functions to define
headers for gatsby-source-graphql. To use, functions can be passed in
the headers object, i.e: headers { authorization: asyncFunc }.

* Changes whole headers parameter to accept async function.

See gatsbyjs/gatsby#20731. Updated README.md to
include new (optional) syntax.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't use async function to set headers. (gatsby-source-graphql).
3 participants