flow-graphql
v0.7.0
Published
flow typed grapgql
Downloads
13
Readme
flow-GraphQL.js
Add flow-type outputs for Graphql
Changelog
v0.7.0 (origin Graphql v0.7.0,with PR#479, cause tag v0.7.0 has some wrong Flow typo).
The Official Graphql upcoming release plan(So this flow-GraphQL was temporarily used until v0.8.0): v0.7.0: Introduce all latest improvements and changes to graphql-js, but no flow-types. v0.8.0-beta: Shortly after, a beta release will contain flow-types. v0.8.0: After some time for people to test and report any issues, a new non-beta release will contain flow types.
v0.6.7 (Graphql v0.6.2)
Update to Graphql v0.6.2.
v0.6.6 (Graphql v0.6.1)
GraphQLObjectTypeConfig<TSource>
to GraphQLFieldResolveFn<TSource, TResult>
Make user can do a whole top-bottom Flow check between their resolvers.
With the Flow typed feature, user can ensure his data structure is correspond to schema . ex: starWarsData.js L103
More details see the src/tests/starWarsSchema.js A simple demonstration:
type DCPost;
type DComment;
type DUser;
const Post = new GraphQLObjectType({
name: 'Post',
fields: () => ({
...
comment: {
type: new GraphQLList(Comment),
resolve: (src:DPost):DComment[] => { // Flow check DPost -> DComment[]
return ...;
} }
}),
});
const Comment = new GraphQLObjectType({
name: 'Comment',
fields: () => ({
...
user: {
type: User,
resolve: (src:DComment):DUser => { // DComment -> DUser
return ...;
}
},
}),
});
const User = new GraphQLObjectType({
...
});
Note: Because in v0.61 ,in source code use a any
type to force cast TSource
. So it is user's responsibility to check the Data Type is not typo. In above code , if resolve: (src:DPost):DComment
is typo to resolve: (src:DPost):DSomeAnotherType[]
(and user return a wrong data), Flow will still pass. Flow will not check DSomeAnotherType
is DComment
,cause of DSomeAnotherType
-> any
-> DComment
v0.6.5 (Graphql v0.6.1)
update to the latest master (Graphql v0.6.1) update Flow to 0.28
v0.6.3 (Graphql v0.6.0)
printSchema to this
type printStyle = 'alphabet' | 'hierarchy';
export function printSchema(
schema: GraphQLSchema,style: printStyle = 'alphabet'): string {
switch (style) {
case 'hierarchy':
return printFineSchema(schema, n => !isSpecDirective(n));
case 'alphabet':
default:
return printFilteredSchema(schema, n => !isSpecDirective(n),
isDefinedType);
}
}