zth / resgraph Goto Github PK
View Code? Open in Web Editor NEWBuild implementation-first GraphQL servers in ReScript
License: MIT License
Build implementation-first GraphQL servers in ReScript
License: MIT License
Should probably be its own package with bindings anyway.
Massage the mutations workflow a bit.
If the folder defined in resgraph.json
doesn't exist, ResGraph fails to compile.
This is the error message if /src/schema/__generated__
doesn't exist:
Error: Command failed: /path/to/repo/node_modules/resgraph/bin/darwin/resgraph.exe generate-schema
/path/to/repo/src /path/to/repo/src/schema/__generated__ true
This error could be a common mistake for new users and the message could be improved
We're half way there with the Node
interface. I have a few ideas for connections too.
Something sorely missing from GraphQL is input unions. While we won't extend the GraphQL language ourselves, we could potentially implement input unions server side:
@gql.inputUnion
type timePeriod = Preset({datePreset: datePreset}) | Dates({from: timestamp, to: timestamp})
@gql.field
let data = (_: query, ~timePeriod) => {
getDataByTimePeriod(timePeriod)
}
type Query {
data(datePreset: DatePreset, from: Timestamp, to: Timestamp): DataForPeriod
}
We'd have a code generated layer in each resolver using a input union that automatically throws if the argument configuration isn't correct.
This is about as magical as I dare make something, but imagine this (pageInfo
definition omitted):
@gql.type type user = {name: string}
@gql.typeCreator
type edge<'node> = {
@gql.field cursor: option<string>,
@gql.field node: option<'node>,
}
@gql.typeCreator
type connection<'edge> = {
@gql.field pageInfo: pageInfo,
@gq.field edges: option<array<option<edge>>>,
}
@gql.type
type userEdge = edge<user>
@gql.type
type userConnection = connection<userEdge>
Generating this:
type User {
name: String!
}
type UserEdge {
cursor: String
node: User
}
type UserConnection {
pageInfo: PageInfo!
edges: [UserEdge]
}
Essentially allowing records to act as "templates" which you can generate types from, that would then also leverage any instantiated type parameters.
Would solve for example making good connection helpers, and allow you to write functions operating on connection<'node>
directly.
Example is for connections, but can probably be generalized.
Either build and commit to repo for each change, or wait for GH runners to support building them.
Preferably in a separate repo.
Make it so you can click to jump to the implementation of types/fields/anything in the GraphQL schema, into the ReScript code.
There's an absolute ton of unused OCaml code since I started out by copying the entire editor tooling repo. Most will be possible to clean out.
Would be nice to have a good set of examples for how to implement the Node interface, which is 1st class in ResGraph. Preferably with a few helpers for creating good, short, URL friendly ID:s. cc @cometkim (message pack etc)
Explore and document how to integrate ResGraph into an existing GraphQL server.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.