
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@graphex/core
Advanced tools
This package allows you to automatically generate Apollo Server schema and resolvers for MongoDB using Prisma-like SDL.
Note! In Codesandbox any change in the code will restart the service. In this setup we use in memory DB, hence any restart will purge the data you'll create with Mutations
With yarn:
yarn add @graphex/core
or using npm:
npm install --save @graphex/core
Project initialization is the same as for Apollo Server. The only difference is that we use makeExecutableSchema
from this package to generate schema.
import ApolloModelMongo, { QueryExecutor } from '@graphex/core';
const schema = await new ApolloModelMongo({
queryExecutor: QueryExecutor(db),
}).makeExecutablSchema({
typeDefs,
});
const server = new ApolloServer({
schema,
});
You can find full examples here
type Category @model {
id: ObjectID! @id @unique @db(name: "_id")
title: String @default(value: "New Category")
parentCategory: Category @relation(storeField: "parentCategoryId")
subcategories: [Category!] @extRelation(storeField: "parentCategoryId")
posts: [Post!] @extRelation
createdAt: Date @createdAt
updatedAt: Date @updatedAt
}
type Comment {
body: String
user: User! @relation
}
type Post @model {
id: ObjectID! @id @unique @db(name: "_id")
title: String!
body: String!
category: Category @relation
keywords: [String!]
owner: User! @relation
place: GeoJSONPoint
comments: [Comment!]
}
interface User @inherit @model {
id: ObjectID! @id @unique @db(name: "_id")
username: String! @unique
}
enum AdminRole {
superadmin
moderator
}
type Admin implements User {
role: AdminRole
}
enum SubscriberRole {
free
standard
premium
}
type SubscriberProfile {
firstName: String!
lastName: String!
}
type Subscriber implements User {
role: SubscriberRole
profile: SubscriberProfile!
}
The above SDL generates this endpoint https://apollo-model-mongodb-example.now.sh
Example queries below
model
directiveunique
directiveid
directivedb
directivedefault
directiveinherit
directivediscriminator
directiverelation
directive${TypeName}Id${s}
extRelation
directiveUsed to define external relation between two collections (identifiers stored in related documents).
Valid locations: FIELD
Optional
Arguments
field:String
storeField:String
${TypeName}Id${s}
many:Boolean
createdAt
directiveupdatedAt
directiveYou can use this package with serverless environments. Read more here. Also take a look at example-now if you are using Zeit Now.
const QueryExecutor = ({ type, collection, doc, docs, selector, options })=>Promise
You are welcome to open Issues, Feature Requests and PR with new features and bug fixes
{
categories {
id
title
}
}
{
"data": {
"categories": [
{
"id": "5c3f4d84e98bd4e76e1d34d1",
"title": "root"
},
{
"id": "5c3f4dd3e98bd4e76e1d34d2",
"title": "JS"
},
{
"id": "5c3f4f46e98bd4e76e1d34d3",
"title": "MongoDB"
}
]
}
}
mutation {
createCategory(data: { title: "root" }) {
id
}
}
{
"data": {
"createCategory": {
"id": "5c3f4d84e98bd4e76e1d34d1"
}
}
}
{
categories(where: { title: "root" }) {
id
title
}
}
{
"data": {
"categories": [
{
"id": "5c3f4d84e98bd4e76e1d34d1",
"title": "root"
}
]
}
}
{
categories(where: { OR: [{ title: "root" }, { title: "JS" }] }) {
id
title
}
}
{
"data": {
"categories": [
{
"id": "5c3f4d84e98bd4e76e1d34d1",
"title": "root"
},
{
"id": "5c3f4dd3e98bd4e76e1d34d2",
"title": "JS"
}
]
}
}
{
categories {
id
title
parentCategory {
title
}
}
}
{
"data": {
"categories": [
{
"id": "5c3f4d84e98bd4e76e1d34d1",
"title": "root",
"parentCategory": null
},
{
"id": "5c3f4dd3e98bd4e76e1d34d2",
"title": "JS",
"parentCategory": {
"title": "root"
}
},
{
"id": "5c3f4f46e98bd4e76e1d34d3",
"title": "MongoDB",
"parentCategory": {
"title": "root"
}
}
]
}
}
{
categories(where: { parentCategory: { title: "root" } }) {
id
title
}
}
{
"data": {
"categories": [
{
"id": "5c3f4dd3e98bd4e76e1d34d2",
"title": "JS"
},
{
"id": "5c3f4f46e98bd4e76e1d34d3",
"title": "MongoDB"
}
]
}
}
mutation {
createCategory(
data: {
title: "Mongodb"
parentCategory: { connect: { id: "5c3f4d84e98bd4e76e1d34d1" } }
}
) {
id
}
}
{
"data": {
"createCategory": {
"id": "5c3f4f46e98bd4e76e1d34d3"
}
}
}
mutation {
createSubscriber(
data: {
username: "subscriber1"
profile: { create: { firstName: "Gwion", lastName: "Britt" } }
}
) {
id
username
}
}
{
"data": {
"createSubscriber": {
"id": "5c3f555b190d25e7bda1dea2",
"username": "subscriber1"
}
}
}
mutation {
createPost(
data: {
title: "Build GraphQL API with Apollo"
body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
owner: { connect: { Admin: { username: "admin" } } }
}
) {
id
}
}
{
"data": {
"createPost": {
"id": "5c401347de7e67e9540abad2"
}
}
}
{
posts {
title
owner {
username
... on Subscriber {
profile {
firstName
lastName
}
}
}
}
}
{
"data": {
"posts": [
{
"title": "Build GraphQL API with Apollo",
"owner": {
"username": "admin"
}
}
]
}
}
{
posts(
where: {
place_near: {
geometry: { type: Point, coordinates: [0, 51.01] }
maxDistance: 10000
}
}
) {
id
title
place {
distance(toPoint: { type: Point, coordinates: [0, 51.01] })
}
}
}
{
"data": {
"posts": [
{
"id": "5c401347de7e67e9540abad2",
"title": "Build GraphQL API with Apollo",
"place": {
"distance": 1111.9492664453662
}
}
]
}
}
1.2.4 (2021-06-14)
Note: Version bump only for package graphex
FAQs

We found that @graphex/core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.