/flow-graphql

graphql with .js.flow output

OtherNOASSERTION

Note

Graphql > v0.8.0 Has .js.flow output. just use this when you need old version Graphql. ( < V0.8.0).

flow-GraphQL.js

Add flow-type outputs for Graphql.
For convenience, also make a modified express-graphql->t-express-graphql (It require flow-graphql inner insteadof graphql).
And, if you use Relay(Graphql relay server), there also has a Flow Typed relayql. But it is very different from graphql-relay. Because graphql-relay is not designed for a static Flow Type check.

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)

modified printSchema(schema) to printSchema(schema, printStyle?: 'alphabet'|'hierarchy'):

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);
  }
}

With 'hierarchy' option( printSchema(schema, 'hierarchy') ), It will print schema as a leaf->root order.
(The leaf Type is at the top, the root Type is at the bottom).

And 'alphabet'|void ( printSchema(schema) ) will call the GraphQL's original printSchema.
The more detail 'hierarchy' behaviour is in unit test.