This is directives package for Apollo
in .js
var { RenameDirective } = require('apollo-directives-package') // in VanillaJS(javascript)
// or
import { RenameDirective } from 'apollo-directives-package' // in ES
const schema = makeExecutableSchema({
schemaDirectives: {
...
rename: RenameDirective,
}
})
in .ts
// in Typescript
import { RenameDirective } from 'apollo-directives-package'
const schema = makeExecutableSchema({
schemaDirectives: {
...
rename: RenameDirective, // if graphql-tools >= 3.x.x
rename: RenameDirective as any, // if graphql-tools < 3.x.x
}
})
type Query {
getBook: Book
anotherGetBook: Book @rename(type: "Query", to: "allBook")
}
type Mutation {
createBook(title: "Apollo Directives Package"): Book
newBook(title: "Apollo Directives Package"): Book @rename(type: "Mutation", to: "createBook")
}
- RenameDirective: To rename(redirect) other Query, Mutation, Field resolve
Please pull-request to update your awesome directive!🤩 and give me your username in github, npm to register collaborators.
- Directive type is no match in Typescript -> Resolved.(Refer to version of
graphql-tools
)
makeExecutableSchema({
schemaDirectives: {...} // <- type no match error in Typescript
})
Code copyright 2018 Yoonho Go. Code released under the MIT license.