* First run of script * Get the app running --- ish * Get NextJS working * Remove `node:` * Get more tests passing in unit directory * Update FailBot test to use nock * Update test.yml * Update Dockerfile * tests/content fixes * Update page.js * Update build-changelog.js * updating tests/routing * Update orphan-tests.js * updating tests/rendering * Update .eslintrc.js * Update .eslintrc.js * Install jest/globals * "linting" tests * staging update to server.mjs * Change '.github/allowed-actions.js' to a ESM export * Lint * Fixes for the main package.json * Move Jest to be last in the npm test command so we can pass args * Just use 'npm run lint' in the npm test command * update algolia label script * update openapi script * update require on openapi * Update enterprise-algolia-label.js * forgot JSON.parse * Update lunr-search-index.js * Always explicitly include process.cwd() for JSON file reads pathed from project root * update graphql/update-files.js script * Update other npm scripts using jest to pass ESM NODE_OPTIONS * Update check-for-enterprise-issues-by-label.js for ESM * Update create-enterprise-issue.js for ESM * Import jest global for browser tests * Convert 'script/deploy' to ESM Co-authored-by: Grace Park <gracepark@github.com> Co-authored-by: James M. Greene <jamesmgreene@github.com>
256 lines
4.4 KiB
JavaScript
256 lines
4.4 KiB
JavaScript
// the tests in tests/graphql.js use this schema to ensure the integrity
|
|
// of the data in lib/graphql/static/*.json
|
|
|
|
// PREVIEWS
|
|
export const previewsValidator = {
|
|
properties: {
|
|
title: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
description: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
toggled_by: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
toggled_on: {
|
|
type: 'array',
|
|
required: true
|
|
},
|
|
owning_teams: {
|
|
type: 'array',
|
|
required: true
|
|
},
|
|
accept_header: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
href: {
|
|
type: 'string',
|
|
required: true
|
|
}
|
|
}
|
|
}
|
|
|
|
// UPCOMING CHANGES
|
|
export const upcomingChangesValidator = {
|
|
properties: {
|
|
location: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
description: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
reason: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
date: {
|
|
type: 'string',
|
|
required: true,
|
|
pattern: /^\d{4}-\d{2}-\d{2}$/
|
|
},
|
|
criticality: {
|
|
type: 'string',
|
|
required: true,
|
|
pattern: '(breaking|dangerous)'
|
|
},
|
|
owner: {
|
|
type: 'string',
|
|
required: true,
|
|
pattern: /^[\S]*$/
|
|
}
|
|
}
|
|
}
|
|
|
|
// SCHEMAS
|
|
// many GraphQL schema members have these core properties
|
|
const coreProps = {
|
|
properties: {
|
|
name: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
type: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
kind: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
id: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
href: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
description: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
isDeprecated: {
|
|
type: 'boolean',
|
|
required: false
|
|
},
|
|
preview: {
|
|
type: 'object',
|
|
required: false,
|
|
properties: previewsValidator.properties
|
|
}
|
|
}
|
|
}
|
|
|
|
// some GraphQL schema members have the core properties plus an 'args' object
|
|
const corePropsPlusArgs = dup(coreProps)
|
|
|
|
corePropsPlusArgs.properties.args = {
|
|
type: 'array',
|
|
required: false,
|
|
properties: coreProps.properties
|
|
}
|
|
|
|
// the args object can have defaultValue prop
|
|
corePropsPlusArgs.properties.args.properties.defaultValue = {
|
|
type: 'boolean',
|
|
required: false
|
|
}
|
|
|
|
const corePropsNoType = dup(coreProps)
|
|
delete corePropsNoType.properties.type
|
|
|
|
const corePropsNoDescription = dup(coreProps)
|
|
delete corePropsNoDescription.properties.description
|
|
|
|
// QUERY CONNECTIONS AND FIELDS
|
|
const queryConnections = corePropsPlusArgs
|
|
const queryFields = corePropsPlusArgs
|
|
|
|
// MUTATIONS
|
|
const mutations = dup(corePropsNoType)
|
|
|
|
mutations.properties.inputFields = {
|
|
type: 'array',
|
|
required: true,
|
|
properties: corePropsNoDescription.properties
|
|
}
|
|
|
|
mutations.properties.returnFields = {
|
|
type: 'array',
|
|
required: true,
|
|
properties: coreProps.properties
|
|
}
|
|
|
|
// OBJECTS
|
|
const objects = dup(corePropsNoType)
|
|
|
|
objects.properties.fields = {
|
|
type: 'array',
|
|
required: true,
|
|
properties: corePropsPlusArgs.properties
|
|
}
|
|
|
|
objects.properties.implements = {
|
|
type: 'array',
|
|
required: false,
|
|
properties: {
|
|
name: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
id: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
href: {
|
|
type: 'string',
|
|
required: true
|
|
}
|
|
}
|
|
}
|
|
|
|
// INTERFACES
|
|
const interfaces = dup(corePropsNoType)
|
|
|
|
interfaces.properties.fields = {
|
|
type: 'array',
|
|
required: true,
|
|
properties: corePropsPlusArgs.properties
|
|
}
|
|
|
|
// ENUMS
|
|
const enums = dup(corePropsNoType)
|
|
|
|
enums.properties.values = {
|
|
type: 'array',
|
|
required: true,
|
|
properties: {
|
|
name: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
description: {
|
|
type: 'string',
|
|
required: true
|
|
}
|
|
}
|
|
}
|
|
|
|
// UNIONS
|
|
const unions = dup(corePropsNoType)
|
|
|
|
unions.properties.possibleTypes = {
|
|
type: 'array',
|
|
required: true,
|
|
properties: {
|
|
name: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
id: {
|
|
type: 'string',
|
|
required: true
|
|
},
|
|
href: {
|
|
type: 'string',
|
|
required: true
|
|
}
|
|
}
|
|
}
|
|
|
|
// INPUT OBJECTS
|
|
const inputObjects = dup(corePropsNoType)
|
|
|
|
inputObjects.properties.inputFields = {
|
|
type: 'array',
|
|
required: true,
|
|
properties: coreProps.properties
|
|
}
|
|
|
|
// SCALARS
|
|
const scalars = dup(corePropsNoType)
|
|
scalars.properties.kind.required = false
|
|
|
|
function dup (obj) {
|
|
return JSON.parse(JSON.stringify(obj))
|
|
}
|
|
|
|
export const schemaValidator = {
|
|
queryConnections,
|
|
queryFields,
|
|
mutations,
|
|
objects,
|
|
interfaces,
|
|
enums,
|
|
unions,
|
|
inputObjects,
|
|
scalars
|
|
}
|