Skip to content

Instantly share code, notes, and snippets.

@bluwy
Created December 10, 2020 16:19
Show Gist options
  • Save bluwy/4b4b115513220141556a22fc55dd829f to your computer and use it in GitHub Desktop.
Save bluwy/4b4b115513220141556a22fc55dd829f to your computer and use it in GitHub Desktop.
Postgraphile remove Relay 1 fields
import type { Plugin } from 'postgraphile'
export const removeFluffPlugin: Plugin = (builder) => {
builder.hook('GraphQLInputObjectType:fields', (fields, _, { scope }) => {
if (scope.isMutationInput) {
delete fields.clientMutationId
}
return fields
})
builder.hook('GraphQLObjectType:fields', (fields, _, { scope }) => {
if (scope.isMutationPayload) {
delete fields.clientMutationId
Object.keys(fields).forEach((field) => {
if (field.endsWith('Edge')) {
delete fields[field]
}
})
}
return fields
})
}
removeFluffPlugin.displayName = 'RemoveFluffPlugin'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment