Name: graphql-transform-schema
Owner: Prisma
Description: Transform, filter & alias resolvers of a GraphQL schema
Created: 2017-09-03 14:13:35.0
Updated: 2018-05-02 14:55:36.0
Pushed: 2018-05-21 16:44:00.0
Homepage: https://example-rakllksfme.now.sh/graphiql
Size: 66
Language: TypeScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Transform, filter & alias resolvers of a GraphQL schema
add graphql-transform-schema
By default transformSchema
passes through all queries/mutations. (Open Demo)
rt { transformSchema } from 'graphql-transform-schema'
eeded for remote schemas
rt { createApolloFetch } from 'apollo-fetch'
rt { makeRemoteExecutableSchema } from 'graphql-tools'
t schema = await makeRemoteExecutableSchema(createApolloFetch({
i: 'https://api.graph.cool/simple/v1/swapi',
ide every query/mutation except the `Starship` and `allStarships` query
t transformedSchema = transformSchema(schema, {
': false,
arship: true,
lStarships: true,
t transformedSchema = transformSchema(schema, {
ery: {
'*': false,
Starship: true,
allStarships: true,
tation: {
arship: {
'*': false,
id: true,
rface Rules {
ieldName: string]: boolean | Function
tion transformSchema(schema: GraphQLSchema, rules: Rules): GraphQLSchema
createX
and deleteX
mutationst transformedSchema = transformSchema(schema, {
tation: {
'create*': false,
'delete*': false
t typeDefs = `
pe Query {
hello: String!
pe Mutation {
alexaHello(name: String!): String!
t resolvers = {
ery: {
hello: () => 'Hello world',
tation: {
alexaHello: (_, { name }) => `Alexa: Hello world, ${name}`,
t schema = makeExecutableSchema({ typeDefs, resolvers })
t transformedSchema = transformSchema(schema, {
exaHello: ({ args, resolve }) => resolve(args).replace('Bob', 'Alice'),
t typeDefs = `
pe Query {
hello: String!
pe Mutation {
alexaHello(name: String!): String!
t resolvers = {
ery: {
hello: () => 'Hello world',
tation: {
alexaHello: (_, { name }) => `Alexa: Hello world, ${name}`,
t schema = makeExecutableSchema({ typeDefs, resolvers })
t transformedSchema = transformSchema(schema, {
exaHello: ({ args, resolve }) => resolve({ name: 'John' }),
Join our Slack community if you run into issues or have questions. We love talking to you!