How to use the graphql.GraphQLSchema function in graphql

To help you get started, we’ve selected a few graphql 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 Sleashe / choice / app.js View on Github external
const ChoiceQueryRootType = new GraphQLObjectType({
  name: 'ChoiceSchema',
  description: "Choice Schema Query Root",
  fields: () => ({
    tests: {
      type: new GraphQLList(TestType),
      description: "List of all Tests",
      resolve: function() {
        return TestModel.find()
      }
    }
  })
});

// This is the schema declaration
const ChoiceSchema = new GraphQLSchema({
  query: ChoiceQueryRootType,
  // If you need to create or updata a datasource,
  // you use mutations. Note:
  // mutations will not be explored in this post.
  mutation: TestMutationType
});

var app = express();
app.use(cors())
app.use('/choice', graphqlHTTP({
  schema: ChoiceSchema,
  graphiql: true
}));

app.listen(process.env.PORT || 80);
github codazen / react-relay-graphql-starter-kit / server / data / schema.js View on Github external
/* @flow */
/* eslint import/prefer-default-export: 0 */

import { GraphQLSchema } from 'graphql';

import queries from './queries';
import mutations from './mutations';

export const schema = new GraphQLSchema({
  query: queries,
  mutation: mutations,
});
github almost-full-stack / sequelize-graphql-schema / tests / sequelize-graphql-schema.spec.js View on Github external
return schemaPromise.then((schema) => {
      return graphqlHTTP({
        schema: new GraphQLSchema(schema),
        graphiql: true
      })(req, res);
    });
github Wellers0n / 4Fun-Fullstack / packages / server / src / schema.ts View on Github external
import { GraphQLSchema } from 'graphql'
import QueryType from './type/QueryType'
import MutationType from './type/MutationType'

const schema =  new GraphQLSchema({
    query: QueryType,
    mutation: MutationType
})

export default schema
github andrewnaeve / Full-Stack-Docker / api / src / graphql / utilities / type-utilities.js View on Github external
exports.Schema = schema => {
  return new GraphQLSchema(schema);
};
exports.NonNull = type => {
github siakaramalegos / star_wars_graphql / schema.js View on Github external
},
    starships: {
      type: new GraphQLList(StarshipType),
      args: {
        search: {type: GraphQLString}
      },
      resolve: (root, args) => (
        fetch(`${BASE_URL}/starships/${searchHelper(args.search)}`)
          .then(res => res.json())
          .then(json => json.results)
      )
    },
  })
})

const schema = new GraphQLSchema({
  query: QueryType,
})

module.exports = schema
github spderosso / deja-vu / core / server-bus / src / server-bus.ts View on Github external
const schema = {
      query: new graphql.GraphQLObjectType({
        name: "Query",
        fields: {
          root: {"type": graphql.GraphQLString, resolve: "tbd"}
        }
      })
    };
    if (!_u.isEmpty(mut)) {
      schema["mutation"] = new graphql.GraphQLObjectType({
        name: "Mutation",
        fields: mut
      });
    }
    const gql = express_graphql({
      schema: new graphql.GraphQLSchema(schema),
      pretty: true,
      formatError: e => ({
        message: e.message,
        locations: e.locations,
        stack: e.stack
      })
    });
    _ws.options(BUS_PATH, this._cors);
    _ws.get(BUS_PATH, this._cors, gql);
    _ws.post(BUS_PATH, this._cors, gql);
  }
github AEB-labs / graphql-weaver / src / graphql / schema-merger.ts View on Github external
type: schema.schema.getMutationType(),
        resolver: schema.mutationResolver
    })));

    const subscription = createRootFieldMaybe('Subscription', schemas.map(schema => ({
        namespace: schema.namespace,
        type: schema.schema.getSubscriptionType(),
        resolver: schema.subscriptionResolver
    })));

    const directives = schemas
        .map(schema => schema.schema.getDirectives().filter(d => !isNativeDirective(d)))
        .reduce((a,b) => a.concat(b), [])
        .concat(specifiedDirectives);

    return new GraphQLSchema({
        query,
        mutation,
        subscription,
        directives
    });
}
github strues / boldr / web / src / server / data / rootSchema.js View on Github external
import { GraphQLSchema } from 'graphql';

import RootQueryType from './rootQuery';
import RootMutationType from './rootMutation';

const RootSchema = new GraphQLSchema({
  query: RootQueryType,
  mutation: RootMutationType,
});

export default RootSchema;
github lakshmantgld / comingOrNot / serverless / lib / schema.js View on Github external
type: Event,
      description: 'Update a specific attendee in the Event',
      args: {
        eventId: {type: new GraphQLNonNull(GraphQLString)},
        attendeeId: {type: new GraphQLNonNull(GraphQLString)},
        attendeeName: {type: new GraphQLNonNull(GraphQLString)},
        personalizedDateSelection: {type: new GraphQLNonNull(PersonalizedDateSelection)}
      },
      resolve(source, args) {
        return updateAttendee(args);
      }
    }
  }
});

const Schema = new GraphQLSchema({
  query: Query,
  mutation: Mutation
});

export default Schema;