Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
/* @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,
});
return schemaPromise.then((schema) => {
return graphqlHTTP({
schema: new GraphQLSchema(schema),
graphiql: true
})(req, res);
});
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
exports.Schema = schema => {
return new GraphQLSchema(schema);
};
exports.NonNull = type => {
},
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
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);
}
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
});
}
import { GraphQLSchema } from 'graphql';
import RootQueryType from './rootQuery';
import RootMutationType from './rootMutation';
const RootSchema = new GraphQLSchema({
query: RootQueryType,
mutation: RootMutationType,
});
export default RootSchema;
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;