graphile-build-pg
Version:
Build a GraphQL schema by reflection over a PostgreSQL schema. Easy to customize since it's built with plugins on graphile-build
16 lines (13 loc) • 381 B
Flow
export default function parseIdentifier(typeIdentifier) {
const match = typeIdentifier.match(
/^(?:([a-zA-Z0-9_]+)|"([^"]*)")\.(?:([a-zA-Z0-9_]+)|"([^"]*)")$/
);
if (!match)
throw new Error(
`Type identifier '${typeIdentifier}' is of the incorrect form.`
);
return {
namespaceName: match[1] || match[2],
entityName: match[3] || match[4],
};
}