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

Library page #1569

Closed
wants to merge 13 commits into from
Closed

Library page #1569

wants to merge 13 commits into from

Conversation

dinakajoy
Copy link
Contributor

@dinakajoy dinakajoy commented Apr 28, 2021

Issue Description

Make it possible to get quick glimpse of what PRs are being actively worked on for various ocaml libraries.
The library page is responsive to any device width.

Starts #1483

What has been achieved so far

Details of specified github repos will be displayed on the /libraries page

screencapture-file-wsl-Ubuntu-20-04-home-dinakajoy-outreachy-ocaml-org-ocaml-org-libraries-html-2021-04-28-11_22_59

Capture

What is yet to be achieved

Details of the PRs of individual libraries
Catching errors on HTTP request
Format date to display in this format - Last updated 2 days ago
Add a link to the Libraries page

  • Please check if the PR fulfills these requirements
  • PR is descriptively titled and links the original issue above
  • Before/after screenshots (if this is a layout change)
  • Details of which platforms the change was tested on (if this is a browser-specific change)
  • Context for what motivated the change (if this is a change to some content)

@dinakajoy
Copy link
Contributor Author

dinakajoy commented Apr 28, 2021

@patricoferris please I can't get the test to pass. Please can you assist with a solution..
I just noticed that yojson has to be installed.

@patricoferris
Copy link
Contributor

Hi @dinakajoy thanks for the PR.

You have added the Yojson library as a dependency but haven't added it to the opam file. You probably did opam install yojson which installs it globally which is why it works locally, but the tests build the package from scratch every time. If you create a fresh switch (opam switch create ocamlorg 4.10.2) and try make deps and make you will probably recreate this error locally.

One thought though, we already transitively (i.e. one of our dependencies depends on) a JSON parsing library called Ezjsonm, do you think you could refactor to use that? It means we keep our dependency footprint a little smaller and you don't have to add anything to the opam file because of this transitive dependency (we probably still will add it but that's more for future-proofing as we already have it)?

@dinakajoy
Copy link
Contributor Author

I will check it out. Thank you for the update

@patricoferris
Copy link
Contributor

Have a look at ocaml/ocaml.org#1528 (comment) where I recommended that same. It should already be installed by COW.

It's not a bad idea to add it into the opam file anyway to make dependency explicit, but it doesn't change much as we were pulling it in anyway. The only reason to add it as well is in case COW decides to not use it anymore.

@dinakajoy dinakajoy marked this pull request as draft April 30, 2021 16:17
@dinakajoy
Copy link
Contributor Author

dinakajoy commented May 4, 2021

@patricoferris I have changed from yojson to ezjsonm and the test passes now. Thank you.
Another thing is that I have been trying to consume the github's graphQL API instead of the REST API.
I have tried using cohttp to make a post request but the query keeps throwing error.
OCaml does not yet have a GraphQL client, so please can you suggest the best approach to go about this - ppx_graphql, cohttp, apollo-client, etc
This method also looks great but I am confused on how to do it - Serving over HTTP via https://graphql.org/learn/serving-over-http/#post-request.
There are no documentation or code samples, so please if you can provide a code sample as a guide I will appreciate it. Thank you

@dinakajoy dinakajoy marked this pull request as ready for review May 4, 2021 11:00
@patricoferris
Copy link
Contributor

@dinakajoy thanks for converting over to Ezjsonm, great work!

To use GraphQL this example which I showed someone else but can't remember who should be quite instructive. I'm pretty sure all GraphQL clients do this at some point, apollo-client is more for actually applications where you want things like in-memory (or in-browser caching) and graphql-ppx is just checking your query against the schema and can provide some nice type transformations.

@dinakajoy
Copy link
Contributor Author

To use GraphQL this example which I showed someone else but can't remember who should be quite instructive. I'm pretty sure all GraphQL clients do this at some point

This is a great start but would I be able to pass arguments for the query?

@patricoferris
Copy link
Contributor

Yes for example https://github.com/coq/bot/blob/master/bot-components/GraphQL_query.ml#L15 you just pass it as part of the JSON argument with the key "variables"

@dinakajoy
Copy link
Contributor Author

Yes for example https://github.com/coq/bot/blob/master/bot-components/GraphQL_query.ml#L15 you just pass it as part of the JSON argument with the key "variables"

Thank you so much. Let me try this out.

@dinakajoy
Copy link
Contributor Author

dinakajoy commented May 5, 2021

Hi @patricoferris I have been able to get the queries to run.
The issue is to access the returned data using ezjsonm.
It keeps throwing error:

{
  "data": {
    "repository": {
      "name": "merlin",
      "description": "Context sensitive completion for OCaml in Vim and Emacs",
      "url": "https://github.com/ocaml/merlin",
      "stargazerCount": 1306,
      "forkCount": 180,
      "updatedAt": "2021-05-05T02:09:45Z",
      "issues": {
        "totalCount": 887
      },
      "pullRequests": {
        "nodes": [
          {
            "title": "Attempt to fix #1199",
            "url": "https://github.com/ocaml/merlin/pull/1329",
            "state": "MERGED",
            "updatedAt": "2021-04-27T16:56:30Z",
            "author": {
              "login": "rgrinberg"
            }
          },
          {
            "title": "Fix #1228",
            "url": "https://github.com/ocaml/merlin/pull/1331",
            "state": "OPEN",
            "updatedAt": "2021-05-04T16:39:14Z",
            "author": {
              "login": "rgrinberg"
            }
          },
          {
            "title": "[construct] Module holes",
            "url": "https://github.com/ocaml/merlin/pull/1333",
            "state": "OPEN",
            "updatedAt": "2021-04-30T15:02:16Z",
            "author": {
              "login": "voodoos"
            }
          },
          {
            "title": "Don't repeat environment entries in Typemod.check_type_decl (ocaml/ocaml#10382)",
            "url": "https://github.com/ocaml/merlin/pull/1334",
            "state": "OPEN",
            "updatedAt": "2021-04-29T15:59:09Z",
            "author": {
              "login": "voodoos"
            }
          },
          {
            "title": "Reproduce issue #1335",
            "url": "https://github.com/ocaml/merlin/pull/1336",
            "state": "OPEN",
            "updatedAt": "2021-04-30T18:39:27Z",
            "author": {
              "login": "rgrinberg"
            }
          }
        ]
      }
    }
  }
}

Please how do I access these data?

@patricoferris
Copy link
Contributor

Hi :))

You've said

It keeps throwing error:

But you haven't showed me the code that is throwing the error or what error it is which makes it quite difficult to help. It's always useful to provide too much information when you encounter an error and ask for help.

That being said, I open utop with Ezjsonm and loaded the string in as a variable called s and performed the following:

utop # let v = Ezjsonm.from_string s;;
utop # Ezjsonm.find v [ "data"; "repository"; "name" ];;
- : Ezjsonm.value = `String "merlin"

So it all seems to be working, am I missing something?

@dinakajoy
Copy link
Contributor Author

dinakajoy commented May 6, 2021

@patricoferris @pitag-ha @kanishka-work
Thank you for the feedback @patricoferris. The error was just about weak type but the code sample helped.
I have been able to consume the github graphql api and here is a screenshot of the updated page

screencapture-file-wsl-Ubuntu-20-04-home-dinakajoy-outreachy-ocaml-org-ocaml-org-libraries-html-2021-05-06-19_09_56

Can I make a pull request with this?
I want to also see if I can format the last_updated_date to be in a format like "2days ago", etc rather than date. Any idea please?

@dinakajoy
Copy link
Contributor Author

Hi @patricoferris and @pitag-ha, please I am still expecting feedback on this.
Can I make a pull request with the changes or are there improvement suggestions

@patricoferris
Copy link
Contributor

Hi @dinakajoy, awesome work, feel free to make a PR if you wish :))

@dinakajoy dinakajoy closed this by deleting the head repository Jan 27, 2024
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.

2 participants