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

Reload/Refresh the GraphQL content from MySQL data. #26042

Closed
AjayDhimanELS opened this issue Jul 27, 2020 · 6 comments
Closed

Reload/Refresh the GraphQL content from MySQL data. #26042

AjayDhimanELS opened this issue Jul 27, 2020 · 6 comments
Labels
status: awaiting author response Additional information has been requested from the author topic: data Relates to source-nodes, internal-data-bridge, and node creation type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@AjayDhimanELS
Copy link

I'm using Node/Express to successfully push some data into a MySQL db. Now the issue is that GraphQL is not refreshing/loading the new/recently added data. I tried following these:

But couldn't get any help. Have we found any simpler solutions to this?

@AjayDhimanELS AjayDhimanELS added the type: question or discussion Issue discussing or asking a question about Gatsby label Jul 27, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jul 27, 2020
@herecydev
Copy link
Contributor

So have you tried using ENABLE_GATSBY_REFRESH_ENDPOINT? If so, is there something that's not working correctly?

@vladar
Copy link
Contributor

vladar commented Jul 27, 2020

Can you elaborate a bit more on what did you try? And what didn't work?

Did you try sending a POST request to __reresh endpoint? If so, did you set ENABLE_GATSBY_REFRESH_ENDPOINT env variable as @herecydev correctly pointed out above?

@vladar vladar added topic: data Relates to source-nodes, internal-data-bridge, and node creation status: awaiting author response Additional information has been requested from the author and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jul 27, 2020
@AjayDhimanELS
Copy link
Author

AjayDhimanELS commented Jul 28, 2020

@vladar @herecydev
Yes, I tried adding ENABLE_GATSBY_REFRESH_ENDPOINT= true in my .env file.
Also, added the following in my node file.

app.post('/__refresh', (req, res) => {

const enableRefresh = process.env.ENABLE_GATSBY_REFRESH_ENDPOINT

const refreshToken = process.env.GATSBY_REFRESH_TOKEN

const authorizedRefresh =

!refreshToken || req.headers.authorization === refreshToken 

if (enableRefresh && authorizedRefresh) {

console.log(`Refreshing source data`) 

sourceNodes() 

}
res.end()
})

app.listen(8001, function() {
console.log('App listening on port 8001!');
});

Still, this doesn't seem to refresh the graphQL query's data.

@capndave
Copy link
Contributor

Not sure if this will help, but I think you need to remove a space from the variable definition in your .env file. Try changing ENABLE_GATSBY_REFRESH_ENDPOINT= true to ENABLE_GATSBY_REFRESH_ENDPOINT=true.

@vladar
Copy link
Contributor

vladar commented Aug 3, 2020

@AjayDhimanELS You don't need to add anything to your gatsby-node file to enable this feature. Did you try removing the space from ENABLE_GATSBY_REFRESH_ENDPOINT= true as suggested above?

@openscript
Copy link
Contributor

Unfortunately I also have troubles with this. I've created a .env.development file with the following content:

ENABLE_GATSBY_REFRESH_ENDPOINT=true

When I start Gatsby with gatsby develop from the console it doesn't pick up this variable, hence the refresh button in the GraphiQL editor is not shown. What am I doing wrong?

  System:
    OS: Linux 5.9 alpine VSCode devcontainer
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 14.14.0 - /tmp/yarn--1608064598022-0.6500972906168905/node
    Yarn: 1.22.5 - /tmp/yarn--1608064598022-0.6500972906168905/yarn
    npm: 6.14.8 - /usr/local/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    gatsby: ^2.28.2 => 2.28.2 
    gatsby-image: ^2.7.0 => 2.7.0 
    gatsby-plugin-emotion: ^5.0.0 => 5.0.0 
    gatsby-plugin-manifest: ^2.8.0 => 2.8.0 
    gatsby-plugin-react-helmet: ^3.6.0 => 3.6.0 
    gatsby-plugin-robots-txt: ^1.5.3 => 1.5.3 
    gatsby-plugin-sharp: ^2.10.1 => 2.10.1 
    gatsby-plugin-sitemap: ^2.8.0 => 2.8.0 
    gatsby-plugin-svgr: ^2.0.2 => 2.0.2 
    gatsby-plugin-ts-config: ^1.1.5 => 1.1.5 
    gatsby-remark-copy-linked-files: ^2.6.0 => 2.6.0 
    gatsby-remark-images: ^3.7.1 => 3.7.1 
    gatsby-source-filesystem: ^2.7.0 => 2.7.0 
    gatsby-transformer-remark: ^2.12.0 => 2.12.0 
    gatsby-transformer-sharp: ^2.8.0 => 2.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: awaiting author response Additional information has been requested from the author topic: data Relates to source-nodes, internal-data-bridge, and node creation type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

5 participants