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

Add gatsby-source-mongodb plugin to gatsby #1570

Merged
merged 17 commits into from
Jul 27, 2017

Conversation

jorishermans
Copy link
Contributor

It contains:

  • example site using-mongoDB
  • plugin gatsby-source-mongoDB

Still need to write a fill mongodb script in the example site, that will make it easier to set it up when someone wants to test this out on his local machine.

@jorishermans jorishermans changed the title Topics/mongodb Add gatsby-source-mongodb plugin to gatsby Jul 19, 2017
@gatsbybot
Copy link
Collaborator

gatsbybot commented Jul 19, 2017

Deploy preview ready!

Built with commit aa719c7

https://deploy-preview-1570--using-drupal.netlify.com

@gatsbybot
Copy link
Collaborator

gatsbybot commented Jul 19, 2017

Deploy preview ready!

Built with commit aa719c7

https://deploy-preview-1570--gatsbyjs.netlify.com

@gatsbybot
Copy link
Collaborator

gatsbybot commented Jul 19, 2017

Deploy preview ready!

Built with commit aa719c7

https://deploy-preview-1570--gatsbygram.netlify.com

@KyleAMathews
Copy link
Contributor

Woah! Super cool, was hoping someone would do this :-D Adding some quick reviews inline.

// it like the site has a built-in database constructed
// from the fetched data that you can run queries against.

// HnStory is a data node type created from the HN API “allHnStory” is a
Copy link
Contributor

Choose a reason for hiding this comment

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

Comments need updated

{
"name": "using-mongodb",
"private": true,
"description": "Gatsby example site using using-mongodb",
Copy link
Contributor

Choose a reason for hiding this comment

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

"using gatsby-source-mongodb"

@@ -0,0 +1,53 @@
import React, { Component } from 'react'
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally you don't need a custom html.js. Just use https://www.gatsbyjs.org/packages/gatsby-plugin-react-helmet and then the react-helmet stuff will get added automatically to the <head>

@@ -0,0 +1,28 @@
import React from "react"
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be layouts/index.js

const story = this.props.data.mongoDbDocField;

return (
<div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there's some inconsistent formatting. We use Prettier in this repo. Just run npm run format from the root of the repo to fix things up.

@@ -0,0 +1,36 @@
# gatsby-source-mongodb

Source plugin for pulling data into [Gatsby](https://github.com/gatsbyjs) from Wordpress sites using the [Wordpress JSON REST API](https://developer.wordpress.org/rest-api/reference/).
Copy link
Contributor

Choose a reason for hiding this comment

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

Update comments

collection: collectionName,
internal: {
mediaType: 'application/json',
type: `mongoDBDocField`,
Copy link
Contributor

Choose a reason for hiding this comment

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

The node type should be based on the collection. Otherwise there could be field type conflicts between fields in different collections e.g. one collection a field is a string and another it's a int.

Also since it looks like you're supporting connecting to multiple DBs which is a cool feature, perhaps have the type name be something like Mongo${DB_NAME}${COLLECTION_NAME}.

You might want to make the collection field a bit more unique to lessen the chance of conflicting with a field named "collection".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used mongodb{dbName}{collection}

@jorishermans
Copy link
Contributor Author

I will look into the feedback this evening.

Planning to incorporate the possibility to add children in the mongoDB document and a parent reference, if one is been provided use that otherwise use a default.

@KyleAMathews
Copy link
Contributor

Awesome!

A few other things that might be nice:

@KyleAMathews
Copy link
Contributor

KyleAMathews commented Jul 20, 2017

Deploy preview failed.

Built with commit d36ecc1

https://app.netlify.com/sites/using-contentful/deploys/59710409cf321c01f861a5d7

@KyleAMathews
Copy link
Contributor

KyleAMathews commented Jul 20, 2017

@KyleAMathews
Copy link
Contributor

KyleAMathews commented Jul 20, 2017

Deploy preview failed.

Built with commit aa719c7

https://app.netlify.com/sites/using-remark/deploys/597a3bff7960b105249a1090

@KyleAMathews
Copy link
Contributor

KyleAMathews commented Jul 20, 2017

@KyleAMathews
Copy link
Contributor

KyleAMathews commented Jul 20, 2017

Deploy preview failed.

Built with commit e04ce20

https://app.netlify.com/sites/using-glamor/deploys/597794260752d047495f6a3c

@KyleAMathews
Copy link
Contributor

KyleAMathews commented Jul 20, 2017

Deploy preview failed.

Built with commit d36ecc1

https://app.netlify.com/sites/image-processing/deploys/59710409cf321c01f861a5ce

@KyleAMathews
Copy link
Contributor

It'd be cool too to have the example site pointing to a mongodb instance in the cloud somewhere (I'm assuming one of the hosted MongoDB services have tiny free instances available).

We build example sites on every PR as integration tests so we'd need this. Plus it'd be nice as someone checking out the plugin could run the example site without setting up a local mongo instance.

@KyleAMathews
Copy link
Contributor

Just merged master to stop the failing netlify builds which means you'll need to pull.

@@ -0,0 +1,3 @@
/*.js
Copy link
Contributor

Choose a reason for hiding this comment

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

Also ignore tests

Copy link
Contributor Author

@jorishermans jorishermans Jul 20, 2017

Choose a reason for hiding this comment

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

Ok done

@jorishermans
Copy link
Contributor Author

I need to work on the example site more into detail.

This will be something for next week, I will indeed look into a free cloud mongoDB instance.

@KyleAMathews
Copy link
Contributor

Oh also in gatsby-remark-images as you committed a compiled test file there https://github.com/gatsbyjs/gatsby/pull/1570/files#diff-1a268099af2a7db53e390ac9c8d35862

That's what I saw before

@jorishermans
Copy link
Contributor Author

I isolated the mapping code ...

In the mainwhile I delete the node_modules and reinstall it and do a gatsby-dev on the folder

This was referenced Mar 16, 2018
@jlengstorf
Copy link
Contributor

Hiya @jorishermans! 👋

This is definitely late, but on behalf of the entire Gatsby community, I wanted to say thank you for being here.

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 t-shirts and hats, plus some socks that are really razzing our berries right now.)
  2. If you’re not already part of it, we just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. You’ll receive an email shortly asking you to confirm. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If you have questions, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again! 💪💜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants