Export RelayParser as a class
@@ -104,7 +104,12 @@ const INCLUDE = 'include';
const SKIP = 'skip';
const IF = 'if';
-function parseRelay(
+class RelayParser {
+ _definition: OperationDefinitionNode | FragmentDefinitionNode;
+ _referencedVariables: {[name: string]: ?GraphQLInputType};
+ _schema: GraphQLSchema;
+
+ static parse(
schema: GraphQLSchema,
text: string,
filename?: string,
@@ -114,7 +119,7 @@ function parseRelay(
schema = extendSchema(schema, ast);
ast.definitions.forEach(definition => {
if (isOperationDefinitionAST(definition)) {
- nodes.push(transform(schema, definition));
+ nodes.push(RelayParser.transform(schema, definition));
}
});
return nodes;
@@ -124,7 +129,7 @@ function parseRelay(
* Transforms a raw GraphQL AST into a simpler representation with type
* information.
*/
-function transform(
+ static transform(
schema: GraphQLSchema,
definition: OperationDefinitionNode | FragmentDefinitionNode,
): Root | Fragment {
@@ -132,11 +137,6 @@ function transform(
return parser.transform();
}
-class RelayParser {
- _definition: OperationDefinitionNode | FragmentDefinitionNode;
- _referencedVariables: {[name: string]: ?GraphQLInputType};
- _schema: GraphQLSchema;
-
constructor(
schema: GraphQLSchema,
definition: OperationDefinitionNode | FragmentDefinitionNode,
@@ -992,7 +992,4 @@ function getClassicFieldDefinition(
}
}
-module.exports = {
- parse: parseRelay,
- transform,
-};
+module.exports = RelayParser;
