Skip to content

Instantly share code, notes, and snippets.

@nodkz
Created October 18, 2017 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nodkz/bb38ee2b83454e7e81d1382903051c98 to your computer and use it in GitHub Desktop.
Save nodkz/bb38ee2b83454e7e81d1382903051c98 to your computer and use it in GitHub Desktop.
react-relay flowtype declaration
import * as React from "react";
declare class RelayComponentClass<Props> extends React$Component<Props, any> {
static getFragment: Function;
};
declare type createFragmentContainer = <TBase>(
Component: Class<React$Component<TBase, any>> | (props: TBase) => React.Node,
fragmentSpec: any
) => Class<RelayComponentClass<TBase>>;
declare type GraphQLTaggedNode =
| (() => any)
| { modern: () => any, classic: any => any };
declare type RelayModernGraphQLTag_graphql = (strings: Array<string>) => GraphQLTaggedNode;
declare module "react-relay/compat" {
declare module.exports: {
createFragmentContainer: createFragmentContainer,
graphql: RelayModernGraphQLTag_graphql,
commitMutation: Function,
}
}
declare module "react-relay" {
declare module.exports: {
createFragmentContainer: createFragmentContainer,
graphql: RelayModernGraphQLTag_graphql,
}
}
declare module "react-relay/classic" {
declare module.exports: {
QL: any,
createContainer: Function, // TODO need to check React props in legacy code or not?
Route: any,
Renderer: any,
Environment: any,
createQuery: any,
GraphQLMutation: any,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment