Skip to content

Instantly share code, notes, and snippets.

@litewarp
Last active July 4, 2021 19:27
Show Gist options
  • Save litewarp/913c1f77581f2ed7e75d7c489b79488c to your computer and use it in GitHub Desktop.
Save litewarp/913c1f77581f2ed7e75d7c489b79488c to your computer and use it in GitHub Desktop.
Neo4j Work-Around for Apollo Argument Name Constraints
// 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