Skip to main content

Built and signed on GitHub Actions

This module focuses on a comprehensive system offering a structured, typed query language for your APIs. It offers a straightforward way of creating, reading, updating, and deleting data using GraphQL.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
6 months ago (1.0.0)
class GqlModel
implements IGqlModel

Represents a base class for GraphQL models.

Contains the logic for managing and iterating through model's fields, hydrating model with values, validating property values, etc.

Properties

private
name: string | null

Methods

Provides an iterator over the model's properties.

__init__(): this

Initializes the model, setting up the names of all properties based on the model's prototype.

getField<T>(property: string): IGqlField<T> | null

Retrieves a field from the model.

Retrieves the name of the model. If the name is not set, retrieves the class name, removing the trailing 'GqlModel' if it exists.

Retrieves all properties of the model.

has(property: string): boolean

Checks if a property exists in this model.

hydrate(values: Record<string, unknown>): this

Populates the model with a given record.

reset(): this

Resets all the properties in the model to undefined.

validate(): ValidationResultType

Validates all properties of the model.

Add Package

deno add jsr:@ooneex/gql-model

Import symbol

import { GqlModel } from "@ooneex/gql-model";

---- OR ----

Import directly with a jsr specifier

import { GqlModel } from "jsr:@ooneex/gql-model";

Add Package

npx jsr add @ooneex/gql-model

Import symbol

import { GqlModel } from "@ooneex/gql-model";

Add Package

yarn dlx jsr add @ooneex/gql-model

Import symbol

import { GqlModel } from "@ooneex/gql-model";

Add Package

pnpm dlx jsr add @ooneex/gql-model

Import symbol

import { GqlModel } from "@ooneex/gql-model";

Add Package

bunx jsr add @ooneex/gql-model

Import symbol

import { GqlModel } from "@ooneex/gql-model";