Created
December 10, 2020 16:19
-
-
Save bluwy/4b4b115513220141556a22fc55dd829f to your computer and use it in GitHub Desktop.
Postgraphile remove Relay 1 fields
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
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