Skip to content

komkanit/graphql-filter-field

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphql-filter-field

filter any field on Schema not just root field

Install

yarn add graphql-filter-field

Usage

filterFields passes through all GraphQL type.

import { filterFields } from 'graphql-filter-field'
const typeDefs = `
  type User {
    id: ID
    fullName: String
    hello_delete: String
  }

  type Query {
    users: [User]
  }
`
const schema = makeExecutableSchema({ typeDefs })
addMockFunctionsToSchema({ schema })
const newSchema = filterFields(schema, (field) => {
  return field.name.endsWith('_delete')
})

Using with schema transform

import { withFilterFields } from 'graphql-filter-field'
const transformedSchema = transformSchema(schema, [
  new RenameTypes((name) => `Simple_${name}`),
  withFilterFields((field) => {
    return field.name.endsWith('_delete')
  })
])

About

filter any field on Schema not just root field

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published