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) })
56
682
14
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) {
11
34
2
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);
0
29
2
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')
0
2
0
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 ' +
0
24
9
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]
9
16
5
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)) {
0
5
4
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 }),
0
0
7
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
0
0
3
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 = {
0
0
5
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')));
0
0
0
graphql.GraphQLNonNull is the most popular function in graphql (4226 examples)