Sefaria-Project icon indicating copy to clipboard operation
Sefaria-Project copied to clipboard

graphql basic structure and some queries

Open JonMosenkis opened this issue 3 years ago • 2 comments

Setting up a basic module for graphql queries. This looks pretty promising and very easy to enhance and expand in the future. I'd love to hear feedback!

JonMosenkis avatar Jan 20 '22 15:01 JonMosenkis

This is still a work in progress, so I'd strongly recommend against merging at this time. But I would like periodic feedback if possible.

JonMosenkis avatar Jan 20 '22 15:01 JonMosenkis

I've been using the graphql-request library from npm to execute the graph querries. For example, to query indices I set up the file graphql.mjs as so:

import { request, gql } from 'graphql-request'

const query = gql`
  {
      Index(title: "Genesis") {
        title
        categories
        node {
          depth
          sectionNames
          titles {
            text
            primary
          }
        }
        altStructs
      }
  }
`

request('http://localhost:8000/api/graphql', query)
.then(data => {
  console.log(data);
})
.catch(err => console.error(err));

JonMosenkis avatar Jan 20 '22 15:01 JonMosenkis