GraphQL to Flow
Turn a GraphQL schema into Flow object types: non-null fields required, nullable fields optional and nullable, enums as string unions.
What the GraphQL to Flow does
Flow's ?T says the value may be null and the ? after the property name says the key may be absent. A schema's nullable field can be either, so both markers are emitted.
Lists become Array<T>, and the inner type keeps its own nullability.
Field arguments are not modelled, and a custom scalar becomes mixed because the schema does not say what it carries.
How to use it
Paste the schema into the GraphQL schema box, or press Run with the example already there.
Read the Flow below: each schema type becomes one exported object type, in declaration order.
Check a Flow field you expected to be required — it carries neither the optional marker nor the nullable marker.
Worked example
Input:
type Query {
me: User
}
type User {
id: ID!
name: String
}
Output:
export type Query = {
me?: ?User,
};
export type User = {
id: string,
name?: ?string,
};
Why it runs in your browser
The result is produced on this page with JavaScript, so it works offline after the page loads and nothing you enter is sent anywhere.
One Flow object type per schema type, with the optional marker and the nullable marker kept separate because Flow treats them as two different facts.
A non-null field is neither optional nor nullable; that is the only combination the schema guarantees.
What it does, and what it does not
Flow's `?T` says the value may be null and the `?` after the property name says the key may be absent. A schema's nullable field can be either, so both markers are emitted.
Lists become `Array<T>`, and the inner type keeps its own nullability.
Field arguments are not modelled, and a custom scalar becomes `mixed` because the schema does not say what it carries.
How to use GraphQL to Flow
Paste the schema into the GraphQL schema box, or press Run with the example already there.
Read the Flow below: each schema type becomes one exported object type, in declaration order.
Check a Flow field you expected to be required — it carries neither the optional marker nor the nullable marker.
What to Expect
Best for
- Typing a Flow codebase from a schema you already own
- Seeing exactly where a field may be absent rather than null
Not ideal for
- Typing request variables — argument types are not modelled
- Narrowing a custom scalar, which is emitted as mixed
What this tool keeps
- Optional and nullable markers on the right fields
- Enum values as a string union
What may need cleanup
- A custom scalar stays mixed until you refine it
- Field arguments need a hand-written type
Common errors
- The page refuses it: unknown type Missing referenced by Query.me
Example use cases
- Typing a Flow client from its schema
- Reviewing a schema change as a Flow diff
Sample input
GraphQL schema: type Query { …
Sample output
Flow: export type Query = { …
Who this is for
- Developers maintaining a Flow codebase
- Anyone comparing Flow and TypeScript output for the same schema
Frequently asked questions
What is the difference between the two question marks?
field?: ?string means the key may be absent and the value may be null. The first marker comes from the property, the second from the type. A non-null field has neither.
How is a list typed?
As Array<T>, with T carrying the inner type's own nullability. [String!]! becomes Array<string>, while [String] becomes Array<?string>.
What does a custom scalar become?
mixed. The schema does not say what the scalar carries, so the page refuses to invent a shape; refine it where you unmarshal the value.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.