{"id":41681,"library":"orchid-graphql","title":"orchid-graphql","description":"orchid-graphql is a helper library for resolving GraphQL queries directly with Orchid ORM tables and relations (version 1.9.1). It selects only requested fields and relations, supports unlimited nested resolvers, pagination, filters (e.g., date-based, __in), query modifiers, and field result hooks for access control. Released pre-release (not battle-tested), it is a quick adaptation of objection-graphql-resolver. Requires graphql ^16 and orchid-orm ^1.31.5 as peer dependencies. Node.js >=14. Ships TypeScript types, but typings are not fully ready (returns generic Query).","status":"active","version":"1.9.1","language":"javascript","source_language":"en","source_url":"https://github.com/IlyaSemenov/orchid-graphql","tags":["javascript","typescript"],"install":[{"cmd":"npm install orchid-graphql","lang":"bash","label":"npm"},{"cmd":"yarn add orchid-graphql","lang":"bash","label":"yarn"},{"cmd":"pnpm add orchid-graphql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for GraphQL integration","package":"graphql","optional":false},{"reason":"peer dependency for ORM integration","package":"orchid-orm","optional":false}],"imports":[{"note":"Common pattern is to import all as 'r' (e.g., r.graph), but named import is also valid.","wrong":"import * as r from 'orchid-graphql'","symbol":"graph","correct":"import { graph } from 'orchid-graphql'"},{"note":"There is no default export; use namespace import.","wrong":"import r from 'orchid-graphql'","symbol":"r","correct":"import * as r from 'orchid-graphql'"},{"note":"Package is ESM-only; CommonJS require may not work.","wrong":"const { graph } = require('orchid-graphql')","symbol":"graph","correct":"import { graph } from 'orchid-graphql'"}],"quickstart":{"code":"import { ApolloServer } from '@apollo/server';\nimport { startStandaloneServer } from '@apollo/server/standalone';\nimport gql from 'graphql-tag';\nimport * as r from 'orchid-graphql';\nimport { createBaseTable, orchidORM } from 'orchid-orm';\n\nconst BaseTable = createBaseTable();\n\nclass PostTable extends BaseTable {\n  readonly table = 'post';\n  columns = this.setColumns(t => ({\n    id: t.identity().primaryKey(),\n    text: t.text(0, 5000),\n  }));\n}\n\nconst db = orchidORM({\n  databaseURL: process.env.DATABASE_URL ?? '',\n  log: true,\n}, { post: PostTable });\n\nawait db.$query`\n  create table post (\n    id serial primary key,\n    text text not null\n  );\n`;\n\nconst typeDefs = gql`\n  type Post {\n    id: Int!\n    text: String!\n  }\n  type Mutation {\n    create_post(text: String!): Post!\n  }\n  type Query {\n    posts: [Post!]!\n  }\n`;\n\nconst graph = r.graph({ Post: r.table(db.post) });\n\nconst resolvers = {\n  Mutation: {\n    async create_post(_parent: any, args: { text: string }, context: any, info: any) {\n      const post = await db.post.create(args);\n      return await graph.resolve(db.post.find(post.id), { context, info });\n    },\n  },\n  Query: {\n    async posts(_parent: any, _args: any, context: any, info: any) {\n      return await graph.resolve(db.post, { context, info });\n    },\n  },\n};\n\nconst server = new ApolloServer({ typeDefs, resolvers });\nconst { url } = await startStandaloneServer(server, { listen: { port: 4000 } });\nconsole.log(`Listening on ${url}`);","lang":"typescript","description":"Full example setting up Apollo Server with orchid-graphql: defines a Post table, creates GraphQL schema, maps table to resolver with r.graph, and runs server."},"warnings":[{"fix":"Use with caution; test thoroughly in production-like environments.","message":"The library is pre-release and not battle tested. May have bugs or incomplete features.","severity":"gotcha","affected_versions":"<2.0"},{"fix":"Cast or use type assertions when needed (e.g., as unknown as YourType).","message":"Typings are incomplete; resolver returns generic 'Query' type instead of specific shapes.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Use namespace import (import * as r from 'orchid-graphql') or named import (import { graph }).","message":"Package does not export a default export; must use named imports like import { graph } or import * as r.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Install peer deps: npm install graphql orchid-orm","message":"Requires graphql ^16 and orchid-orm ^1.31.5 as peer dependencies; missing them causes runtime errors.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Ensure you pass a table instance from orchid-orm, e.g., r.table(db.post).","message":"The r.table() function expects a table object with a query method; passing wrong object causes cryptic errors.","severity":"gotcha","affected_versions":">=1.0"}],"env_vars":null,"search_vec":"'1.31.5':76 '1.9.1':23 '14':81 '16':71 'access':49 'adapt':63 'base':40 'battl':57 'battle-test':56 'control':50 'date':39 'date-bas':38 'depend':79 'direct':15 'e.g':37 'field':28,45 'filter':36 'fulli':89 'generic':92 'graphql':3,6,13,67,70 'helper':9 'hook':47 'javascript':94 'librari':10 'modifi':43 'nest':33 'node.js':80 'object':66 'objection-graphql-resolv':65 'orchid':2,5,17,74 'orchid-graphql':1,4 'orchid-orm':73 'orm':18,75 'pagin':35 'peer':78 'pre':53 'pre-releas':52 'queri':14,42,93 'quick':62 'readi':90 'relat':21,30 'releas':51,54 'request':27 'requir':69 'resolv':12,34,68 'result':46 'return':91 'select':25 'ship':82 'support':31 'tabl':19 'test':58 'type':84,86 'typescript':83,95 'unlimit':32 'version':22","created_at":"2026-06-04T18:53:35.327870+00:00","updated_at":"2026-06-04T18:53:35.327870+00:00","problems":[{"fix":"Run npm install orchid-graphql and ensure project uses ES modules (type: 'module' in package.json or .mjs files).","cause":"Package not installed or ESM not configured.","error":"Cannot find module 'orchid-graphql'"},{"fix":"Use import * as r from 'orchid-graphql' or import { graph } from 'orchid-graphql'.","cause":"Namespace import used incorrectly (e.g., import r from 'orchid-graphql') instead of import * as r.","error":"TypeError: r.graph is not a function"},{"fix":"Ensure you call r.graph() and then use the returned object's resolve method: const graph = r.graph({...}); graph.resolve(...).","cause":"graph object returned from r.graph() is used before being assigned or destructured incorrectly.","error":"Cannot read properties of undefined (reading 'resolve')"},{"fix":"Pass a specific table: r.table(db.post) instead of r.table(db).","cause":"Passing the ORM object instead of a table instance to r.table().","error":"Type 'typeof import(\"orchid-orm\")' is not assignable to parameter of type 'Table'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/IlyaSemenov/orchid-graphql#readme","github":"https://github.com/IlyaSemenov/orchid-graphql","docs":null,"changelog":null,"pypi":null,"npm":"orchid-graphql","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}