Member Junction
    Preparing search index...

    This class is responsible for generating the GraphQL Server resolvers and types for the entities, you can sub-class this class to extend/modify the logic, make sure to use @memberjunction/global RegisterClass decorator so that your class is used.

    Index

    Constructors

    Properties

    _graphQLTypeSuffix: string = '_'

    Accessors

    Methods

    • Build one GraphQL server file — a single schema, or the legacy monolith when per-schema emit is turned off.

      Parameters

      • entities: EntityInfo[]
      • generatedEntitiesImportLibrary: string
      • excludeRelatedEntitiesExternalToSchema: boolean
      • fromSchemaSubdir: boolean = false

      Returns string

    • Delegates so both generators write identically; override to change that.

      Parameters

      • filePath: string
      • content: string
      • useWriteIfChanged: boolean

      Returns void

    • Parameters

      • entities: EntityInfo[]
      • importLibrary: string
      • isInternal: boolean
      • fromSchemaSubdir: boolean = false

      Returns string

    • Generates import statements for entity classes, grouping by package when entityPackageName is a schema-to-package map.

      Parameters

      • entities: EntityInfo[]
      • defaultLibrary: string
      • isInternal: boolean

      Returns string

    • Emits the field-security transport field onto every generated object type.

      Present on ALL entities, not just those with EnableFieldLevelSecurity — the schema is a build artifact and that flag is runtime metadata an administrator can toggle in Explorer, so a schema whose SHAPE depended on it would be silently wrong the moment someone flipped it without re-running CodeGen. It is nullable and the server leaves it null for unrestricted callers, so it costs nothing on the overwhelming majority of requests.

      See ReadableFieldsTransportKey for what it carries and why it names readable rather than denied fields.

      Returns string

    • Parameters

      • entity: EntityInfo
      • includeFileHeader: boolean
      • generatedEntitiesImportLibrary: string
      • _excludeRelatedEntitiesExternalToSchema: boolean

      Returns string

    • Generates the base GraphQL type name for an entity using SchemaBaseTable pattern. Preserves original capitalization. Special case: MJ core schema uses "MJ" prefix. This ensures unique type names across different schemas.

      Parameters

      • entity: EntityInfo

        The entity to generate the type name for

      Returns string

      The base GraphQL type name (without suffix)

    • Maps a column's SQL type to the TypeGraphQL @Field(...) type-fn argument.

      Categories that emit an empty string fall through to TypeGraphQL's automatic inference based on the field's TypeScript type — appropriate for string, Date, and binary-as-string columns. Boolean / Float require an explicit type fn, and anything else defaults to Int.

      The category checks come from @memberjunction/sql-dialect so that the list of recognized type names lives in exactly one place per category.

      Parameters

      Returns string

    • Whether an OUTPUT-type field may be marked non-nullable in the generated GraphQL schema.

      The rule is deliberately NOT AllowsNull. A column's NOT NULL constraint and a GraphQL field's ! say different things:

      • NOT NULL — no ROW stores an empty value in this column.
      • String! — every RESPONSE, to every caller, carries a value for this field.

      The second does not follow from the first. It only coincided while every caller saw every column of every row they could read. Field-level security ends that: a denied field is OMITTED from the response (ResolverBase.MapFieldNamesToCodeNames), and GraphQL treats an absent value on a non-nullable field as an error that propagates up to the nearest nullable parent — nulling the whole record on a single-record load, the whole query on a typed list, and failing the mutation RESPONSE after the write already landed.

      So presence is promised only where FLS is structurally incapable of stripping the field: primary keys (hard and soft) and __mj_ system columns — exactly EntityFieldInfo.IsUnrestrictableField, the same predicate the runtime aggregation and the save-time guard use. Anything else can legitimately be absent for SOME caller, so the schema must not promise otherwise.

      INPUT types are unaffected and keep deriving from AllowsNull — they carry the WRITE contract, which the database constraint does still govern.

      Parameters

      Returns boolean

    • Returns a JavaScript expression string (for use in generated code) that resolves to the schema name at runtime. Core schema uses the dynamic config lookup; non-core schemas use a literal string.

      Parameters

      Returns string