How to use the buildASTSchema function from graphql
Find comprehensive JavaScript graphql.buildASTSchema code examples handpicked from public code repositorys.
GitHub: sheerun/graphqlviz

76 77 78 79 80 81 82 83 84 85
// given a "GraphQL schema language" text file, converts into introspection JSON function introspect (text) { return new Promise(function (resolve, reject) { try { var astDocument = GraphQL.parse(text) var schema = GraphQL.buildASTSchema(astDocument) GraphQL.graphql({ schema, source: graphqlviz.query }) .then(function (data) { resolve(data) })
GitHub: geek/graphi

7 8 9 10 11 12 13 14 15 16
// Inspired by graphql-tools exports.makeExecutableSchema = ({ schema, resolvers = {}, preResolve }) => { const parsed = Graphql.parse(schema); const astSchema = Graphql.buildASTSchema(parsed, { commentDescriptions: true, assumeValidSDL: true }); for (const resolverName of Object.keys(resolvers)) { const type = astSchema.getType(resolverName); if (!type) {
3 4 5 6 7 8 9 10 11 12
* Builds Graphql schema with * support for extending type definitions */ module.exports = function(typeDefs) { let astDocument = parse(typeDefs); let schema = buildASTSchema(astDocument); let extensionsAst = extractExtensionDefinitions(astDocument); if (extensionsAst.definitions.length > 0) { schema = extendSchema(schema, extensionsAst);
GitHub: AlanZMD/docs

11 12 13 14 15 16 17 18 19
// select and format all the data from the schema that we need for the docs // used in the build step by script/graphql/build-static-files.js module.exports = async function processSchemas (idl, previewsPerVersion) { const schemaAST = parse(idl.toString()) const schema = buildASTSchema(schemaAST) // list of objects is used when processing mutations const objectsInSchema = schemaAST.definitions.filter(def => def.kind === 'ObjectTypeDefinition')
64 65 66 67 68 69 70 71 72 73
if (introspection.__schema) { return buildClientSchema((introspection: any)); } else if (introspection.data && introspection.data.__schema) { return buildClientSchema((introspection.data: any)); } else if (introspection.kind && introspection.kind === 'Document') { return buildASTSchema(introspection); } throw new Error( 'Invalid introspection data supplied to the Babel Relay plugin. The ' +
10 11 12 13 14 15 16 17 18 19
const app = express() app.use(cors()) okta.initializeApp(app) const schema = buildASTSchema(gql` # Queries type Query { posts: [Post]
GitHub: trepo/trepo-js

201 202 203 204 205 206 207 208 209 210
}`, // Scalars `scalar JSON`, ].join('\n'); const schema = buildASTSchema(parse(definitions)); // Adapted from graphql-tools makeExecutableSchema // For each resolver for (const typeName of Object.keys(resolvers)) {
GitHub: tes/restfor

13 14 15 16 17 18 19 20 21 22
module.exports = async (context, collections = [], schmemasPath, resolversPath) => { if (!schmemasPath) return { schema: {}, router: express.Router() }; const resolvers = getResolvers(resolversPath); const schemas = getSchemas(schmemasPath); const ast = parse(schemas, { noLocation: true }); const thirdPartySchema = buildASTSchema(ast); const restforSchema = createRestforSchema(collections, ast); const defaultSchema = createDefaultSchema({ ast, restforSchema, schema: thirdPartySchema }); const router = graphqlExpress({ schema: mergeSchemas({ schemas: [defaultSchema, schemas], resolvers }),
GitHub: jquense/relay-test

28 29 30 31 32 33 34 35 36 37
} } function getSchema() { try { return buildASTSchema( parse( ` directive @include(if: Boolean) on FRAGMENT | FIELD directive @skip(if: Boolean) on FRAGMENT | FIELD
28 29 30 31 32 33 34 35 36 37
const { buildASTSchema } = require('graphql') const app = express() app.use(cors()) const schema = buildASTSchema(gql` type Query { hello: String } `) const rootValue = {
GitHub: zmbush/relay

14 15 16 17 18 19
const path = require('path'); const {buildASTSchema, parse} = require('graphql'); const schemaPath = path.join(__dirname, 'testschema.graphql'); module.exports = buildASTSchema(parse(fs.readFileSync(schemaPath, 'utf8')));
graphql.GraphQLNonNull is the most popular function in graphql (4226 examples)