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

Fix source medium Plugin #2515

Closed
wants to merge 4 commits into from
Closed

Conversation

Necmttn
Copy link
Contributor

@Necmttn Necmttn commented Oct 18, 2017

The plugin was outdated. it's working now.

  - gatsby-node.js updated according to new medium api.
@KyleAMathews
Copy link
Contributor

Deploy preview failed.

Built with commit cc16ae4

https://app.netlify.com/sites/using-glamor/deploys/59e77f1c0b79b75fbcd60fb2

@gatsbybot
Copy link
Collaborator

gatsbybot commented Oct 18, 2017

Deploy preview ready!

Built with commit 014c8e6

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

@KyleAMathews
Copy link
Contributor

Thanks for the PR!

I'm a bit confused though. How is the plugin outdated? Medium changed their API? Or are you adding support for querying users?

@Necmttn
Copy link
Contributor Author

Necmttn commented Oct 19, 2017

Hey Kyle,
currently, if I make get request with https://medium.com/@necmttn/latest?format=json
it returns.

    {
    "success": true,
    "payload": {
    "user": {},
    "streamItems": [],
    "userMeta": {},
    "userNavItemList": {},
    "userNavActiveIndex": 1,
    "profileTypeName": "latest",
    "references": {
        "User": {},
        "Post": {},
        "Social": {},
        "SocialStats": {}
    },
    "paging": {
    "path": "https://medium.com/_/api/users/42d89279af33/profile/stream",
    "next": {
    "limit": 10,
    "to": "1508333639510",
    "source": "latest",
    "page": 1
    }
    }
    },
    "v": 3,
    "b": "31175-bdb30b5"
}

while current code is looking for
https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-medium/src/gatsby-node.js#L36 payload.references.Collection that's why when it's tries to fetch a user it's throws error.
apparently medium is has changed their api. btw this is not offical API suggest. But quick walk around for adding medium article links to website.

@Necmttn
Copy link
Contributor Author

Necmttn commented Oct 19, 2017

Hey, Kyle better hold PR a bit.
I will try to use official API with Integration tokens. which also allows publishing an article to medium. in that case, what's the best way we let a developer have awesome DX to publish.

Question is;
Can plugin act differently on gatsby build?

How about Gatsby gatsby publish <platform> command.

@KyleAMathews
Copy link
Contributor

The plugin acts exactly the same for develop and build.

We might add a publish command at some point but it's not a high priority right now. Easy enough generally to just use the CLIs provided by different hosting providers.

@Necmttn
Copy link
Contributor Author

Necmttn commented Oct 26, 2017

@KyleAMathews understood, well no need then.
I will start working on the gatsby-desktop project soon. I can add publish feature there. btw you can merge this one I fixed a linting issue and I have no time for implant Integration tokens.
✌️

@KyleAMathews
Copy link
Contributor

@deniaz @mfeltscher could you review this PR before I merge it?

@deniaz
Copy link
Contributor

deniaz commented Oct 29, 2017

Hey there,

From what I can see that API hasn't changed, but @Necmttn doesn't post to a collection on Medium. If you take my user (https://medium.com/@deniaz/latest?format=json) payload.references.Collection sill exists. With this PR Collection wouldn't be imported anymore (neither for publications nor users).

Also the links are removed (https://github.com/gatsbyjs/gatsby/pull/2515/files#diff-914dccf08660c2fd85676d5e5412464cL54) which were explicitly asked for by @KyleAMathews ;)

The reason why we didn't use the official API here because it does not support reading posts, just publishing.

From my point of view the code should check whether references.Collection exists before accessing it - and that's about it.

@Necmttn
Copy link
Contributor Author

Necmttn commented Oct 31, 2017

Hey :)
thanks for the review @deniaz, apparently I fooled by bad API design of trello. I'm closing this pull request. if I had time this weekend. I will add references.Collection exists before accessing it logic

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