How to use the graphql-compose.schemaComposer.buildSchema function in graphql-compose

To help you get started, we’ve selected a few graphql-compose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphql-compose / graphql-compose-json / src / __fixtures__ / Schema.js View on Github external
/* @flow */

import { schemaComposer } from 'graphql-compose';
import { FilmTC } from './Film';
import { PeopleTC } from './People';

schemaComposer.Query.addFields({
  film: FilmTC.getResolver('findById'),
  people: PeopleTC.getResolver('findById'),
  peopleByUrl: PeopleTC.getResolver('findByUrl'),
  peopleByUrls: PeopleTC.getResolver('findByUrlList'),
});

const schema = schemaComposer.buildSchema();

export default schema;
github nodkz / conf-talks / articles / graphql / schema-build-ways / graphql-compose.js View on Github external
args: {
      limit: { type: 'Int', defaultValue: 3 },
    },
    type: [ArticleType],
    resolve: (_, args) => {
      const { limit } = args;
      return articles.slice(0, limit);
    },
  },
  authors: {
    type: [AuthorType],
    resolve: () => authors,
  },
});

const schema = schemaComposer.buildSchema();

const server = new ApolloServer({ schema });
server.listen(5000).then(({ url }) => {
  console.log(`🚀 Server ready at ${url}`);
});
github Traversal-Labs / starfleet / bin / createGQL.js View on Github external
[modelName+"Connection"] : ModelTC.getResolver('connection'),
	[modelName+"Pagination"] : ModelTC.getResolver('pagination'),
  });

  schemaComposer.Mutation.addFields({
	[modelName+"CreateOne"] : ModelTC.getResolver('createOne'),
	[modelName+"CreateMany"] : ModelTC.getResolver('createMany'),
	[modelName+"UpdateById"] : ModelTC.getResolver('updateById'),
	[modelName+"UpdateOne"] : ModelTC.getResolver('updateOne'),
	[modelName+"UpdateMany"] : ModelTC.getResolver('updateMany'),
	[modelName+"RemoveById"] : ModelTC.getResolver('removeById'),
	[modelName+"RemoveOne"] : ModelTC.getResolver('removeOne'),
	[modelName+"RemoveMany"] : ModelTC.getResolver('removeMany'),
  });

  const graphqlSchemaObj = schemaComposer.buildSchema();
  const graphqlSDL = printSchema(graphqlSchemaObj, { commentDescriptions: true });
  const filename = modelName + '.graphql';
  fs.writeFile(`./graphqlsrc/models/${filename}`, graphqlSDL, err => {
		if (err) {
			return console.log(err);
		}
	console.log(chalk.white.bgGreen.bold(`Done! Your graphqlSchema has been created and put into your working directory!`, String.fromCharCode(10003)))
	console.log(String.fromCharCode(10003));
  });
};
github watscho / express-graphql-mongodb-boilerplate / src / graphql / schema.js View on Github external
verifyRequest: UserTC.getResolver('verifyRequest', [isAuth, isUnverfied]),
  verify: UserTC.getResolver('verify'),
  resetPassword: UserTC.getResolver('resetPassword', [isGuest, resetPasswordValidator]),
  newPassword: UserTC.getResolver('newPassword', [
    isGuest,
    newPasswordValidator
  ]),
  changePassword: UserTC.getResolver('changePassword', [
    isAuth,
    changePasswordValidator
  ]),
  updateUser: UserTC.getResolver('updateUser', [isAuth, updateUserValidator]),
  switchLocale: UserTC.getResolver('switchLocale', [isAuth])
})

const schema = schemaComposer.buildSchema()

module.exports = schema
github Traversal-Labs / starfleet / bin / passingGQL.js View on Github external
[modelName+"Count"] : ModelTC.getResolver('count'),
	[modelName+"Connection"] : ModelTC.getResolver('connection'),
	[modelName+"Pagination"] : ModelTC.getResolver('pagination'),
	});

	schemaComposer.Mutation.addFields({
	[modelName+"CreateOne"] : ModelTC.getResolver('createOne'),
	[modelName+"CreateMany"] : ModelTC.getResolver('createMany'),
	[modelName+"UpdateById"] : ModelTC.getResolver('updateById'),
	[modelName+"UpdateOne"] : ModelTC.getResolver('updateOne'),
	[modelName+"UpdateMany"] : ModelTC.getResolver('updateMany'),
	[modelName+"RemoveById"] : ModelTC.getResolver('removeById'),
	[modelName+"RemoveOne"] : ModelTC.getResolver('removeOne'),
	[modelName+"RemoveMany"] : ModelTC.getResolver('removeMany'),
	});
	const graphqlSchema = schemaComposer.buildSchema();
	return graphqlSchema
}
github vobi-io / api-composer / lib / build-schema.js View on Github external
resolvers => {
    schemaComposer.Query.addFields({})
    schemaComposer.Mutation.addFields({})

    resolvers
      .forEach(resolver => {
        const kind = resolver._kind
          ? `${resolver._kind.charAt(0).toUpperCase()}${resolver._kind.slice(1)}`
          : 'Query'

        schemaComposer[kind].addFields({
          [resolver._name]: resolver._gqlResolver
        })
      })

    return schemaComposer.buildSchema()
  }