-
Notifications
You must be signed in to change notification settings - Fork 1
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
GraphQL Server #1
Comments
Yes it absolutely would. It is something I've been meaning to get around to. I'll give you a brain dump of my current thoughts on it in case you want to try it out. Here is an example of a plugin Google Sheets Plugin I would develop this as a plugin import { Collection } from '@active-mdx/core'
import GraphQlPlugin from '@active-mdx/graphql'
export const collection = new Collection({
rootPath: "./docs"
}).use(GraphQlPlugin, { ...options }) That plugin would define a function on the collection to generate a graphql API. I think you could generate the entire graphql API without needing custom code, unless you wanted to. Here is an ActiveMDX project https://github.com/soederpop/active-mdx/tree/main/packages/software-project-demo-site/docs If you import this module, you are getting an instance of the ActiveMDX Collection The collection exposes information about the available model classes import docs from "./docs/index.mjs"
docs.modelClasses // => [Epic, Story, Standup, Decision] Each model class has a static property Each model class also has an Each model class can also, optionally export a So I think using this data, you could generate a graphql schema, as well as resolver functions. // resolvers.js
module.exports = {
Query: {
epics: (_, __, { collection }) =>
collection.query('Epic').fetchAll()
}
}; I would have every node / object have common properties like id, model type, meta, title, ast. etc. Finally, you would just need to wrap it with like apollo-graphql, but in the end you would just be able to say
and get something you could serve with express or whatever. |
You can call {
"type": "object",
"flags": {
"unknown": true
},
"keys": {
"meta": {
"type": "object",
"flags": {
"presence": "required",
"unknown": true
},
"keys": {
"status": {
"type": "string",
"flags": {
"presence": "required"
},
"rules": [
{
"name": "pattern",
"args": {
"regex": "/^(created|in-progress|qa|approved|complete)$/",
"options": {
"name": "valid statuses"
}
}
}
]
},
"estimates": {
"type": "object",
"flags": {
"unknown": true,
"presence": "required"
},
"keys": {
"high": {
"type": "number",
"flags": {
"presence": "required"
}
},
"low": {
"type": "number",
"flags": {
"presence": "required"
}
}
}
},
"github": {
"type": "object",
"keys": {
"issue": {
"type": "number"
}
}
}
}
}
}
} You could easily take that object and generate a graphql type. |
@rawkode just pushed up a commit. still need to document and test. If you clone the repo and run then
It will start a graphql server you can open on Just a proof of concept of what is possible. To use it you need |
wow |
Would it be possible to expose this as a read-only GraphQL server?
I love the idea of keeping all my data in Git, but I'd still like to consume it from other services
The text was updated successfully, but these errors were encountered: