Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Augment schema refactor #84

Merged
merged 3 commits into from
Aug 13, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Augment schema refactor
  • Loading branch information
michaeldgraham authored Aug 13, 2018
commit abb47ee4dae0ec531b65a3770a56637bc4d42fc5
23 changes: 10 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -16,9 +16,10 @@ import {
} from './utils';
import { buildCypherSelection } from './selections';
import {
addIdFieldToSchema,
addOrderByToSchema,
addMutationsToSchema
extractAstNodesFromSchema,
augmentTypeDefs,
createOperationMap,
makeAugmentedSchema
} from './augmentSchema';
import { checkRequestError } from './auth';

@@ -439,14 +440,10 @@ RETURN ${fromVar} {${subQuery}} AS ${fromVar};`;
return [query, params];
}

export function augmentSchema(schema) {
// FIXME: better composable API for schema augmentation
schema = addMutationsToSchema(schema);
schema = addIdFieldToSchema(schema);

// FIXME: adding order by fields to the query types doesn't
// quite work yet so don't include those in schema augmentation yet
//schema = addOrderByToSchema(schema);

return schema;
export const augmentSchema = (schema) => {
const typeMap = extractAstNodesFromSchema(schema);
const mutationMap = createOperationMap(typeMap.Mutation);
const queryMap = createOperationMap(typeMap.Query);
const augmentedTypeMap = augmentTypeDefs(typeMap);
return makeAugmentedSchema(schema, augmentedTypeMap, queryMap, mutationMap);
}