// Retreives a Node given its global ID
// @flow

import {tableNameFromTypeName} from './generateDatabaseInterface';
import type {GraphQLResolveInfo, GraphQLFieldResolveFn} from 'gestalt-utils';
import type DB from './DB';

export default function generateNodeResolver(
  db: DB
): GraphQLFieldResolveFn {
  return async (source, args, context, info) => {
    const [typeName, id] = args.id.split(':');
    const tableName = tableNameFromTypeName(typeName);
    const result = await db.findBy(tableName, {id});
    result._type = typeName;
    return result;
  };
}

@@ -1,8 +1,17 @@
+// @flow%0A
 // Retre
@@ -45,17 +45,8 @@
 l ID
-%0A// @flow
 %0A%0Aim

fix @flow comment location