Sefaria-Project
Sefaria-Project copied to clipboard
graphql basic structure and some queries
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!
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.
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));