migueloller / graphql-utilities Goto Github PK
View Code? Open in Web Editor NEWBuild GraphQL types using the schema language.
License: MIT License
Build GraphQL types using the schema language.
License: MIT License
Using Flow will greatly reduce various bugs and it should be easy to implement given that GraphQL.js is written with it.
buildSchema does seem to support it while, build doesn't
export default function buildSchema(schemaAST, { types, directives } = {}, typeDeps) {
...
}
To ensure we're catching edge cases for most use cases we should have an integration test suite.
build
is very useful and convenient in that it can produce any number of types. Sometimes it might be inconvenient to get a type map though.
If we export the internal buildSchema
and buildType
functions then the developer could potentially use these to build a single type (or schema) and expect a GraphQLType
or GraphQLSchema
as an output instead of a map of those 2 things.
Would love to hear people's thoughts on adding these to the public API.
Warning the developer or throwing errors early (e.g, when passing undefined
as a type dependency) can avoid many headaches.
There are various problems when trying to build a schema that make the API more confusing.
build
will check for the operations. Can they all be type dependencies? Do they all have to be in the AST?build
wouldn't support thunks for type dependencies. This is inconsistent.build
.Perhaps it would be best to delegate schema creation to a separate function and use build
only for types. While it adds an extra function it reduces complexity by separating concerns.
It would be useful to be able to apply a transform to enum values (e.g., camelcase)
We should add support to import files from .graphql
files. You could import another .graphql
file or a .js
file that has a build
config for it.
build(`
type Query {
status: Boolean!
}
`, { status: () => true });
The code above will throw an error when attempting to query status
.
This schema won't behave as expected. The default value for friends
ends up being null
.
input InsertUserInput {
id: ID!
name: String!
friends: [ID!] = []
}
Would it be possible to provide an API to add the resolve functions onto the build output at a later point in time. I would prefer to keep my data type specification separate from the details of resolution.
The next utility after build
should be custom GraphQL types, mostly scalars, that facilitate validation. Potential types include GraphQLURL
, GraphQLJSON
, GraphQLEmail
, GraphQLUnsignedInt
, and many more!
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.