/** * Copyright (c) 2026, Salesforce, Inc., * All rights reserved. * For full license text, see the LICENSE.txt file */ import { buildSchema } from "graphql"; import { createSession } from "../../lib/session.js"; import { primeSchemaCache } from "../../lib/walker.js"; /** * Test schema covering the union of types referenced across legacy graphiti * test files. Intentionally minimal — extend only when new tests need new types. */ export const TEST_SCHEMA = buildSchema(` type Query { viewer: Viewer! accounts(first: Int, where: AccountFilter): AccountConnection! search: [SearchHit!]! } type Mutation { createAccount(input: CreateAccountInput!): Account! } type Viewer { id: ID! name: String! } input AccountFilter { minRevenue: Int name: StringFilter } input StringFilter { eq: String like: String } input CreateAccountInput { name: String! } type AccountConnection { edges: [AccountEdge!]! } type AccountEdge { node: Account! } type Account { id: ID! name: String! annualRevenue: Float } type Contact { id: ID! name: String! email: String } union SearchHit = Account | Contact `); export function makeSession(operation: "query" | "mutation" = "query") { const alias = `test_${Math.random().toString(16).slice(2, 8)}`; const instanceUrl = `https://${alias}.my.salesforce.com`; primeSchemaCache(instanceUrl, TEST_SCHEMA); return createSession(alias, operation, instanceUrl); }