jdnavarro / graphql-haskell

Haskell GraphQL implementation
BSD 3-Clause "New" or "Revised" License
168 stars 27 forks source link

State of this project? #23

Open tchoutri opened 6 years ago

tchoutri commented 6 years ago

Hi! I'm begining to write some utilities that will be reaching a GraphQL endpoint with Haskell. Do you plan to maintain this library in the future, and if not, could you recommend me another one I could use instead? Thanks a lot

brandon-leapyear commented 5 years ago

:sparkles: This is an old work account. Please reference @brandonchinn178 for all future communication :sparkles:


@tchoutri, I've actually been working on a graphql-client package that provides type-safe querying of GraphQL apis (in my case, the GitHub GraphQL api). It's currently a work-in-progress in a private repo, but as soon as I finish work on it and I get approval, I would like to move it out into an open-source repo and onto Hackage. Feel free to bug me every once in a while to see where I'm at.

As a sneak preview, the basic API I'm defining will look like this:

module Recordings where

{- TODO: This file will be generated from the .graphql file -}

type Query = GraphQL.Query Args Schema

data Args = Args
  { _query :: String
  , _first :: Maybe Int
  }

query :: Query
query = $(readGraphQLFile "Recordings.graphql")

type Schema = [schema|
  {
    "search": Maybe {
      "recordings": Maybe {
        "nodes": Maybe List Maybe {
          "title": Maybe Text,
          "artists": Maybe {
            "nodes": Maybe List Maybe {
              "name": Maybe Text,
            },
          },
          "video": Maybe Bool,
          "length": Maybe Duration,
          "rating": Maybe {
            "voteCount": Int,
            "value": Maybe Double,
          },
          "releases": Maybe {
            "nodes": Maybe List Maybe {
              "title": Maybe Text,
              "date": Maybe Date,
              "status": Maybe ReleaseStatus,
            },
          },
        },
      },
    },
  }
|]
query Recordings($query: String!, $first: Int) {
  search {
    recordings(query: $query, first: $first) {
      nodes {
        title
        artists {
          nodes {
            name
          }
        }
        video
        length
        rating {
          voteCount
          value
        }
        releases {
          nodes {
            title
            date
            status
          }
        }
      }
    }
  }
}
main = do
  result <- runQuery Recordings.query Recordings.Args
    { _query = song
    , _first = Just 5
    }
  forM_ [get| result.search!.recordings!.nodes![]! |] $ \song -> do
    print [get| song.title! |]
    print [get| song.artists!.nodes![]!.name! |]
tchoutri commented 5 years ago

@brandon-leapyear that sounds super neat! Thank you very much :)

jdnavarro commented 5 years ago

Getting back to this project is something that's been in the back of my mind in the last few years. There were so many things left to be done, with so much promising prototyping, but there is always something else that takes more priority in my TODO list.

The main obstacle is that I haven't had a real need for this package anymore in my latest job roles, so it's hard for me to context switch into it.

I'd be open to transfer ownership if anyone is interested in developing it further, or you could always fork it :smile:

belka-ew commented 5 years ago

@jdnavarro I’d be interested in maintaining graphql. I’ve already done some work on it, implemented block strings and escape sequences in the strings, improved parser error messages (with megaparsec though instead of attoparsec).

tchoutri commented 5 years ago

@belka-ew that sounds awesome! @jdnavarro what is your opinion on this?

belka-ew commented 5 years ago

For what it's worth, here is my fork: https://github.com/caraus-ecms/graphql It's only a draft and should be treated as such. I'm experimenting currently, updating the structure, moving the stuff around. But it passes all available tests now, i.e. has proper error handling and supports nullable values. I'm looking now for a reasonable way to work with GraphQL lists. I'm also integrated it in a small JSON-API to see how it works in real life. So because of a lot small changes it's probably not usable yet, but if someone still wants to play with it, I'd be more than happy to see some bug reports with small, not working examples.

tchoutri commented 5 years ago

Thank you very much :)