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

Possible to add sourcesNodes in the gatsby-node.js? #1285

Closed
wcastand opened this issue Nov 28, 2019 · 4 comments
Closed

Possible to add sourcesNodes in the gatsby-node.js? #1285

wcastand opened this issue Nov 28, 2019 · 4 comments
Labels
bug Something isn't working fixed Issue fixed and released question Usage question or clarification request v2

Comments

@wcastand
Copy link

Bug Report

I'm trying to add data to the graphql source with a gatsby-config.js. but the console.log doesn't appear.

exports.sourceNodes = async ({
  actions,
  createNodeId,
  createContentDigest
}) => {
  console.log("pages");
  const { createNode } = actions;
  const data = puag.methodOptions;
  const nodeContent = JSON.stringify(data);

  const nodeMeta = {
    id: createNodeId(`puag-options`),
    parent: null,
    children: [],
    internal: {
      type: `PuagNode`,
      mediaType: `application/json`,
      content: nodeContent,
      contentDigest: createContentDigest(data)
    }
  };
  const node = Object.assign({}, data, nodeMeta);
  return await createNode(node);
};

i just took a look into .docz/gatsby-node.js and seems that we can only extend onCreateWebpackConfig and onCreateBabelConfig. Is there a reason for this?

how can i add more data to my website and is it possible to use StaticQuery after ?

@rakannimer
Copy link
Contributor

Hey @wcastand

Thanks for reporting this issue !

I just took a look into .docz/gatsby-node.js and seems that we can only extend onCreateWebpackConfig and onCreateBabelConfig. Is there a reason for this?

No there isn't, it was an oversight from our side 😅

It will be fixed in 2.2.0 by this commit, meanwhile you can try it out in 2.2.0-alpha.1 by installing it with :

yarn add docz@next # or docz@2.2.0-alpha.1

is it possible to use StaticQuery after ?

It should be possible to use StaticQuery and fetch your own data.

You would probably need to shadow the useDbQuery hook and/or the Layout component.

@rakannimer rakannimer added bug Something isn't working fixed Issue fixed and released question Usage question or clarification request v2 labels Nov 28, 2019
@wcastand
Copy link
Author

I did it an other way but thank for the quick fix ! i'll probably have to use this in the final project.

I checked and the gatsby-node.js now has all the hooks so no reason for it to not work anymore.

I think we can close this for now :)

@colbyfayock
Copy link

@wcastand curious what your solution for this was - I'm looking into sourcing content from a CMS (looking at maybe Takeshape or something) and would like to pull in the source to my docz / gatsby installation with the ultimate goal of allowing a customer to update content from the CMS. having trouble finding any examples of this.

@SimonKaluza
Copy link

@colbyfayock @wcastand I'm trying to do the same thing -- I'm admittedly new to Gatsby and Docz, but everything works great from my filesystem. Would love to source my MDX files from a CMS like Takeshape or DatoCMS but I'm not sure what hooks or components to shadow in order to make that happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Issue fixed and released question Usage question or clarification request v2
Projects
None yet
Development

No branches or pull requests

4 participants