Last active
July 4, 2021 19:27
-
-
Save litewarp/913c1f77581f2ed7e75d7c489b79488c to your computer and use it in GitHub Desktop.
Neo4j Work-Around for Apollo Argument Name Constraints
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// temporary fix for https://github.com/neo4j/graphql/issues/292 | |
import { wrapSchema, RenameInputObjectFields } from '@graphql-tools/wrap' | |
import { Neo4jGraphQL } from '@neo4j/graphql' | |
import { typeDefs } from './typeDefs' | |
// renames all InputObjectFields matching 'skip' | |
// see https://www.graphql-tools.com/docs/schema-wrapping#renaming | |
const renamingFn = (typeName: string, fieldName: string): string => { | |
if (fieldName === 'skip') { | |
return 'offset' | |
} | |
return inputFieldName | |
} | |
const neoSchema = new Neo4jGraphQL({ typeDefs }) | |
export const schema = wrapSchema({ | |
schema: neoSchema.schema, | |
transforms: [new RenameInputObjectFields(renamingFn)] | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment