added graphql entegration and tested tanstack query
This commit is contained in:
parent
a67170daa8
commit
cf4f632afe
|
|
@ -19,6 +19,7 @@
|
||||||
"@nestjs/platform-express": "^11.0.1",
|
"@nestjs/platform-express": "^11.0.1",
|
||||||
"graphql": "^16.12.0",
|
"graphql": "^16.12.0",
|
||||||
"graphql-fields": "^2.0.3",
|
"graphql-fields": "^2.0.3",
|
||||||
|
"graphql-type-json": "^0.3.2",
|
||||||
"mongoose": "^8.19.3",
|
"mongoose": "^8.19.3",
|
||||||
"reflect-metadata": "^0.2.2",
|
"reflect-metadata": "^0.2.2",
|
||||||
"rxjs": "^7.8.1"
|
"rxjs": "^7.8.1"
|
||||||
|
|
@ -6769,6 +6770,15 @@
|
||||||
"graphql": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
"graphql": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/graphql-type-json": {
|
||||||
|
"version": "0.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/graphql-type-json/-/graphql-type-json-0.3.2.tgz",
|
||||||
|
"integrity": "sha512-J+vjof74oMlCWXSvt0DOf2APEdZOCdubEvGDUAlqH//VBYcOYsGgRW7Xzorr44LvkjiuvecWc8fChxuZZbChtg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"graphql": ">=0.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/graphql-ws": {
|
"node_modules/graphql-ws": {
|
||||||
"version": "6.0.6",
|
"version": "6.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/graphql-ws/-/graphql-ws-6.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/graphql-ws/-/graphql-ws-6.0.6.tgz",
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
"@nestjs/platform-express": "^11.0.1",
|
"@nestjs/platform-express": "^11.0.1",
|
||||||
"graphql": "^16.12.0",
|
"graphql": "^16.12.0",
|
||||||
"graphql-fields": "^2.0.3",
|
"graphql-fields": "^2.0.3",
|
||||||
|
"graphql-type-json": "^0.3.2",
|
||||||
"mongoose": "^8.19.3",
|
"mongoose": "^8.19.3",
|
||||||
"reflect-metadata": "^0.2.2",
|
"reflect-metadata": "^0.2.2",
|
||||||
"rxjs": "^7.8.1"
|
"rxjs": "^7.8.1"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { GraphQLJSONObject } from 'graphql-type-json';
|
||||||
|
import { Field, Int, InputType } from '@nestjs/graphql';
|
||||||
|
|
||||||
|
@InputType()
|
||||||
|
export class ListArguments {
|
||||||
|
@Field(() => GraphQLJSONObject, { nullable: true })
|
||||||
|
filters?: any;
|
||||||
|
|
||||||
|
@Field(() => GraphQLJSONObject, { nullable: true })
|
||||||
|
sort?: any;
|
||||||
|
|
||||||
|
@Field(() => Int, { defaultValue: 0 })
|
||||||
|
skip: number;
|
||||||
|
|
||||||
|
@Field(() => Int, { defaultValue: 10 })
|
||||||
|
limit: number;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { Field, ObjectType } from "@nestjs/graphql";
|
||||||
|
import { User } from "@/models/user.model";
|
||||||
|
import { Int } from "@nestjs/graphql";
|
||||||
|
|
||||||
|
@ObjectType()
|
||||||
|
export class UsersListResponse {
|
||||||
|
|
||||||
|
@Field(() => [User])
|
||||||
|
data: User[];
|
||||||
|
|
||||||
|
@Field(() => Int)
|
||||||
|
totalCount: number;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
mutation CreatePerson {
|
||||||
|
createPerson(
|
||||||
|
input: {
|
||||||
|
firstName: "John",
|
||||||
|
surname: "Doe",
|
||||||
|
middleName: "Michael",
|
||||||
|
sexCode: "M",
|
||||||
|
personRef: "REF12345",
|
||||||
|
personTag: "TAG001",
|
||||||
|
fatherName: "Robert",
|
||||||
|
motherName: "Jane",
|
||||||
|
countryCode: "US",
|
||||||
|
nationalIdentityId: "12345678901",
|
||||||
|
birthPlace: "New York",
|
||||||
|
birthDate: "1990-01-01T00:00:00.000Z",
|
||||||
|
taxNo: "987654321",
|
||||||
|
birthname: "Johnathan"
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
_id
|
||||||
|
firstName
|
||||||
|
surname
|
||||||
|
birthDate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query {
|
||||||
|
Persons {
|
||||||
|
firstName
|
||||||
|
surname
|
||||||
|
middleName
|
||||||
|
sexCode
|
||||||
|
personRef
|
||||||
|
personTag
|
||||||
|
fatherName
|
||||||
|
motherName
|
||||||
|
countryCode
|
||||||
|
nationalIdentityId
|
||||||
|
birthPlace
|
||||||
|
birthDate
|
||||||
|
taxNo
|
||||||
|
birthname
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query GetPerson {
|
||||||
|
Person(id: "AnID") {
|
||||||
|
_id
|
||||||
|
uuid
|
||||||
|
expiryStarts
|
||||||
|
expiryEnds
|
||||||
|
isConfirmed
|
||||||
|
deleted
|
||||||
|
active
|
||||||
|
crypUuId
|
||||||
|
createdCredentialsToken
|
||||||
|
updatedCredentialsToken
|
||||||
|
confirmedCredentialsToken
|
||||||
|
isNotificationSend
|
||||||
|
isEmailSend
|
||||||
|
refInt
|
||||||
|
refId
|
||||||
|
replicationId
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
|
||||||
|
firstName
|
||||||
|
surname
|
||||||
|
middleName
|
||||||
|
sexCode
|
||||||
|
birthDate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
mutation CreatePerson {
|
|
||||||
createPerson(input: {
|
|
||||||
firstName: "John",
|
|
||||||
surname: "Doe",
|
|
||||||
middleName: "Michael",
|
|
||||||
sexCode: "M",
|
|
||||||
personRef: "REF12345",
|
|
||||||
personTag: "TAG001",
|
|
||||||
fatherName: "Robert",
|
|
||||||
motherName: "Jane",
|
|
||||||
countryCode: "US",
|
|
||||||
nationalIdentityId: "12345678901",
|
|
||||||
birthPlace: "New York",
|
|
||||||
birthDate: "1990-01-01T00:00:00.000Z",
|
|
||||||
taxNo: "987654321",
|
|
||||||
birthname: "Johnathan"
|
|
||||||
}) {
|
|
||||||
_id
|
|
||||||
firstName
|
|
||||||
surname
|
|
||||||
birthDate
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
query GetPerson {
|
|
||||||
Person(id: "69175eec7baea04628ad126c") {
|
|
||||||
_id
|
|
||||||
firstName
|
|
||||||
surname
|
|
||||||
middleName
|
|
||||||
sexCode
|
|
||||||
birthDate
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
query {
|
|
||||||
Persons {
|
|
||||||
firstName
|
|
||||||
surname
|
|
||||||
middleName
|
|
||||||
sexCode
|
|
||||||
personRef
|
|
||||||
personTag
|
|
||||||
fatherName
|
|
||||||
motherName
|
|
||||||
countryCode
|
|
||||||
nationalIdentityId
|
|
||||||
birthPlace
|
|
||||||
birthDate
|
|
||||||
taxNo
|
|
||||||
birthname
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
mutation {
|
|
||||||
createUser(input: {
|
|
||||||
password: "secret123",
|
|
||||||
history: ["login1"],
|
|
||||||
tag: "admin",
|
|
||||||
email: "test@example.com",
|
|
||||||
phone: "555123456",
|
|
||||||
collectionTokens: {
|
|
||||||
default: "default-token",
|
|
||||||
tokens: [{ prefix: "main", token: "abc123" }]
|
|
||||||
},
|
|
||||||
person: "64f8b2a4e1234567890abcdef"
|
|
||||||
}) {
|
|
||||||
_id
|
|
||||||
password
|
|
||||||
tag
|
|
||||||
email
|
|
||||||
phone
|
|
||||||
tag
|
|
||||||
collectionTokens {
|
|
||||||
default
|
|
||||||
tokens {
|
|
||||||
prefix
|
|
||||||
token
|
|
||||||
}
|
|
||||||
}
|
|
||||||
person
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,120 @@
|
||||||
|
mutation {
|
||||||
|
createUser(input: {
|
||||||
|
password: "secret123",
|
||||||
|
history: ["login1"],
|
||||||
|
tag: "admin",
|
||||||
|
email: "test@example.com",
|
||||||
|
phone: "555123456",
|
||||||
|
collectionTokens: {
|
||||||
|
default: "default-token",
|
||||||
|
tokens: [{ prefix: "main", token: "abc123" }]
|
||||||
|
},
|
||||||
|
person: "64f8b2a4e1234567890abcdef"
|
||||||
|
}) {
|
||||||
|
_id
|
||||||
|
password
|
||||||
|
tag
|
||||||
|
email
|
||||||
|
phone
|
||||||
|
tag
|
||||||
|
collectionTokens {
|
||||||
|
default
|
||||||
|
tokens {
|
||||||
|
prefix
|
||||||
|
token
|
||||||
|
}
|
||||||
|
}
|
||||||
|
person
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query {
|
||||||
|
users(limit:1, skip: 0) {
|
||||||
|
_id
|
||||||
|
uuid
|
||||||
|
expiryStarts
|
||||||
|
expiryEnds
|
||||||
|
isConfirmed
|
||||||
|
deleted
|
||||||
|
active
|
||||||
|
crypUuId
|
||||||
|
createdCredentialsToken
|
||||||
|
updatedCredentialsToken
|
||||||
|
confirmedCredentialsToken
|
||||||
|
isNotificationSend
|
||||||
|
isEmailSend
|
||||||
|
refInt
|
||||||
|
refId
|
||||||
|
replicationId
|
||||||
|
|
||||||
|
expiresAt
|
||||||
|
resetToken
|
||||||
|
password
|
||||||
|
history
|
||||||
|
tag
|
||||||
|
email
|
||||||
|
phone
|
||||||
|
|
||||||
|
collectionTokens {
|
||||||
|
default
|
||||||
|
tokens {
|
||||||
|
prefix
|
||||||
|
token
|
||||||
|
}
|
||||||
|
}
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
query TestUsers(
|
||||||
|
$skip: Int
|
||||||
|
$limit: Int
|
||||||
|
$sort: JSON
|
||||||
|
$filters: JSON
|
||||||
|
) {
|
||||||
|
users(skip: $skip, limit: $limit, sort: $sort, filters: $filters) {
|
||||||
|
_id
|
||||||
|
email
|
||||||
|
phone
|
||||||
|
tag
|
||||||
|
createdAt
|
||||||
|
person {
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"skip": 0,
|
||||||
|
"limit": 5,
|
||||||
|
"sort": {
|
||||||
|
"createdAt": 1
|
||||||
|
},
|
||||||
|
"filters": {}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
"skip": 0,
|
||||||
|
"limit": 20,
|
||||||
|
"sort": { "email": -1 },
|
||||||
|
"filters": {
|
||||||
|
"email": {
|
||||||
|
"$regex": "@gmail.com",
|
||||||
|
"$options": "i"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
"skip": 0,
|
||||||
|
"limit": 50,
|
||||||
|
"sort": { "tag": 1 },
|
||||||
|
"filters": {
|
||||||
|
"$or": [
|
||||||
|
{ "email": { "$regex": "example", "$options": "i" }},
|
||||||
|
{ "phone": { "$regex": "555", "$options": "i" }}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,25 +2,21 @@ import { Resolver, Query, Args, ID, Info, Mutation, Int } from '@nestjs/graphql'
|
||||||
import { Types } from 'mongoose';
|
import { Types } from 'mongoose';
|
||||||
import { User } from '@/models/user.model';
|
import { User } from '@/models/user.model';
|
||||||
import { UsersService } from '@/users/users.service';
|
import { UsersService } from '@/users/users.service';
|
||||||
import type { GraphQLResolveInfo } from 'graphql';
|
|
||||||
import graphqlFields from 'graphql-fields';
|
|
||||||
import { CreateUserInput } from './dto/create-user.input';
|
import { CreateUserInput } from './dto/create-user.input';
|
||||||
|
import { ListArguments } from '@/dto/list.input';
|
||||||
|
import { UsersListResponse } from '@/people/dto/list-result.response';
|
||||||
|
import graphqlFields from 'graphql-fields';
|
||||||
|
import type { GraphQLResolveInfo } from 'graphql';
|
||||||
|
|
||||||
@Resolver(() => User)
|
@Resolver(() => User)
|
||||||
export class UsersResolver {
|
export class UsersResolver {
|
||||||
|
|
||||||
constructor(private readonly usersService: UsersService) { }
|
constructor(private readonly usersService: UsersService) { }
|
||||||
|
|
||||||
// Add pagination skip and limit arguments
|
@Query(() => UsersListResponse, { name: "users" })
|
||||||
@Query(() => [User], { name: 'users' })
|
async getUsers(@Info() info: GraphQLResolveInfo, @Args('input') input: ListArguments): Promise<UsersListResponse> {
|
||||||
async getUsers(
|
const fields = graphqlFields(info); const projection = this.usersService.buildProjection(fields?.data); const { skip, limit, sort, filters } = input;
|
||||||
@Info() info: GraphQLResolveInfo,
|
return await this.usersService.findAll(projection, skip, limit, sort, filters);
|
||||||
@Args('skip', { type: () => Int, defaultValue: 0 }) skip: number,
|
|
||||||
@Args('limit', { type: () => Int, defaultValue: 10 }) limit: number,
|
|
||||||
): Promise<User[]> {
|
|
||||||
const fields = graphqlFields(info);
|
|
||||||
const projection = this.usersService.buildProjection(fields);
|
|
||||||
return this.usersService.findAll(projection, skip, limit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Query(() => User, { name: 'user', nullable: true })
|
@Query(() => User, { name: 'user', nullable: true })
|
||||||
|
|
@ -29,8 +25,6 @@ export class UsersResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mutation(() => User, { name: 'createUser' })
|
@Mutation(() => User, { name: 'createUser' })
|
||||||
async createUser(@Args('input') input: CreateUserInput): Promise<User> {
|
async createUser(@Args('input') input: CreateUserInput): Promise<User> { return this.usersService.create(input) }
|
||||||
return this.usersService.create(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,26 @@ import { InjectModel } from '@nestjs/mongoose';
|
||||||
import { Types, Model } from 'mongoose';
|
import { Types, Model } from 'mongoose';
|
||||||
import { User, UserDocument } from '@/models/user.model';
|
import { User, UserDocument } from '@/models/user.model';
|
||||||
import { CreateUserInput } from './dto/create-user.input';
|
import { CreateUserInput } from './dto/create-user.input';
|
||||||
|
import { UsersListResponse } from '@/people/dto/list-result.response';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UsersService {
|
export class UsersService {
|
||||||
|
|
||||||
constructor(@InjectModel(User.name) private readonly userModel: Model<UserDocument>) { }
|
constructor(@InjectModel(User.name) private readonly userModel: Model<UserDocument>) { }
|
||||||
|
|
||||||
async findAll(projection?: any, skip: number = 0, limit: number = 10): Promise<UserDocument[]> { return this.userModel.find({}, projection, { lean: false }).skip(skip).limit(limit).exec() }
|
async findAll(projection: any, skip: number, limit: number, sort?: Record<string, 1 | -1>, filters?: Record<string, any>): Promise<UsersListResponse> {
|
||||||
|
const query: any = {}; if (filters && Object.keys(filters).length > 0) { Object.assign(query, filters) };
|
||||||
|
const totalCount = await this.userModel.countDocuments(query).exec();
|
||||||
|
const data = await this.userModel.find(query, projection, { lean: true }).skip(skip).limit(limit).sort(sort).exec()
|
||||||
|
return { data, totalCount };
|
||||||
|
}
|
||||||
|
|
||||||
async findById(id: Types.ObjectId, projection?: any): Promise<UserDocument | null> { return this.userModel.findById(id, projection, { lean: false }).populate({ path: 'person', select: projection?.person }).exec() }
|
async findById(id: Types.ObjectId, projection?: any): Promise<UserDocument | null> { return this.userModel.findById(id, projection, { lean: false }).populate({ path: 'person', select: projection?.person }).exec() }
|
||||||
|
|
||||||
async create(input: CreateUserInput): Promise<UserDocument> { const user = new this.userModel(input); return user.save() }
|
async create(input: CreateUserInput): Promise<UserDocument> { const user = new this.userModel(input); return user.save() }
|
||||||
|
|
||||||
buildProjection(fields: Record<string, any>): any { const projection: any = {}; for (const key in fields) { projection[key] = 1 }; return projection }
|
buildProjection(fields: Record<string, any>): Record<string, 1> {
|
||||||
|
const projection: Record<string, 1> = {}; for (const key in fields) { projection[key] = 1 }; console.dir({ fields, projection }, { depth: null }); return projection
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
'use server';
|
||||||
|
import { NextResponse } from 'next/server';
|
||||||
|
import { GraphQLClient, gql } from 'graphql-request';
|
||||||
|
|
||||||
|
const endpoint = process.env.GRAPHQL_URL || "http://localhost:3001/graphql";
|
||||||
|
|
||||||
|
export async function POST(request: Request) {
|
||||||
|
const body = await request.json();
|
||||||
|
const { limit, skip, sort, filters } = body;
|
||||||
|
try {
|
||||||
|
const client = new GraphQLClient(endpoint);
|
||||||
|
const query = gql`
|
||||||
|
query ListUsers($input: ListArguments!) {
|
||||||
|
users(input: $input) {
|
||||||
|
data {
|
||||||
|
_id
|
||||||
|
uuid
|
||||||
|
expiryStarts
|
||||||
|
expiryEnds
|
||||||
|
isConfirmed
|
||||||
|
deleted
|
||||||
|
active
|
||||||
|
crypUuId
|
||||||
|
createdCredentialsToken
|
||||||
|
updatedCredentialsToken
|
||||||
|
confirmedCredentialsToken
|
||||||
|
isNotificationSend
|
||||||
|
isEmailSend
|
||||||
|
refInt
|
||||||
|
refId
|
||||||
|
replicationId
|
||||||
|
expiresAt
|
||||||
|
resetToken
|
||||||
|
password
|
||||||
|
history
|
||||||
|
tag
|
||||||
|
email
|
||||||
|
phone
|
||||||
|
collectionTokens {
|
||||||
|
default
|
||||||
|
tokens {
|
||||||
|
prefix
|
||||||
|
token
|
||||||
|
}
|
||||||
|
}
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
}
|
||||||
|
totalCount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
console.dir({ limit, skip, sort, filters }, { depth: null });
|
||||||
|
const variables = { input: { limit, skip, sort, filters } };
|
||||||
|
const data = await client.request(query, variables);
|
||||||
|
return NextResponse.json({ data: data.users.data, totalCount: data.users.totalCount });
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error(err);
|
||||||
|
return NextResponse.json({ error: err.message }, { status: 500 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import DashboardPage from "@/pages/dashboard/page";
|
||||||
|
|
||||||
|
const PageDashboard = () => { return <DashboardPage /> };
|
||||||
|
|
||||||
|
export default PageDashboard;
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
const PeoplePage = () => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>People</h1>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PeoplePage;
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { PageUsers } from "@/pages/users/page";
|
||||||
|
|
||||||
|
const UserPage = () => { return <><PageUsers /></> }
|
||||||
|
|
||||||
|
export default UserPage;
|
||||||
|
|
@ -19,10 +19,10 @@ import {
|
||||||
IconUsers,
|
IconUsers,
|
||||||
} from "@tabler/icons-react"
|
} from "@tabler/icons-react"
|
||||||
|
|
||||||
import { NavMain } from "@/frontend/components/dashboard/nav-main"
|
import { NavMain } from "@/components/dashboard/nav-main"
|
||||||
import { NavSecondary } from "@/frontend/components/dashboard/nav-secondary"
|
import { NavSecondary } from "@/components/dashboard/nav-secondary"
|
||||||
import { NavUser } from "@/frontend/components/dashboard/nav-user"
|
import { NavUser } from "@/components/dashboard/nav-user"
|
||||||
import { NavDocuments } from "@/frontend/components/dashboard/nav-documents"
|
import { NavDocuments } from "@/components/dashboard/nav-documents"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Sidebar,
|
Sidebar,
|
||||||
|
|
@ -32,7 +32,7 @@ import {
|
||||||
SidebarMenu,
|
SidebarMenu,
|
||||||
SidebarMenuButton,
|
SidebarMenuButton,
|
||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
} from "@/frontend/components/ui/sidebar"
|
} from "@/components/ui/sidebar"
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
user: {
|
user: {
|
||||||
|
|
|
||||||
|
|
@ -11,24 +11,24 @@ import {
|
||||||
CardDescription,
|
CardDescription,
|
||||||
CardHeader,
|
CardHeader,
|
||||||
CardTitle,
|
CardTitle,
|
||||||
} from "@/frontend/components/ui/card"
|
} from "@/components/ui/card"
|
||||||
import {
|
import {
|
||||||
ChartConfig,
|
ChartConfig,
|
||||||
ChartContainer,
|
ChartContainer,
|
||||||
ChartTooltip,
|
ChartTooltip,
|
||||||
ChartTooltipContent,
|
ChartTooltipContent,
|
||||||
} from "@/frontend/components/ui/chart"
|
} from "@/components/ui/chart"
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/frontend/components/ui/select"
|
} from "@/components/ui/select"
|
||||||
import {
|
import {
|
||||||
ToggleGroup,
|
ToggleGroup,
|
||||||
ToggleGroupItem,
|
ToggleGroupItem,
|
||||||
} from "@/frontend/components/ui/toggle-group"
|
} from "@/components/ui/toggle-group"
|
||||||
|
|
||||||
export const description = "An interactive area chart"
|
export const description = "An interactive area chart"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,15 +54,15 @@ import { toast } from "sonner"
|
||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { useIsMobile } from "@/hooks/use-mobile"
|
import { useIsMobile } from "@/hooks/use-mobile"
|
||||||
import { Badge } from "@/frontend/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import { Button } from "@/frontend/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
ChartConfig,
|
ChartConfig,
|
||||||
ChartContainer,
|
ChartContainer,
|
||||||
ChartTooltip,
|
ChartTooltip,
|
||||||
ChartTooltipContent,
|
ChartTooltipContent,
|
||||||
} from "@/frontend/components/ui/chart"
|
} from "@/components/ui/chart"
|
||||||
import { Checkbox } from "@/frontend/components/ui/checkbox"
|
import { Checkbox } from "@/components/ui/checkbox"
|
||||||
import {
|
import {
|
||||||
Drawer,
|
Drawer,
|
||||||
DrawerClose,
|
DrawerClose,
|
||||||
|
|
@ -72,7 +72,7 @@ import {
|
||||||
DrawerHeader,
|
DrawerHeader,
|
||||||
DrawerTitle,
|
DrawerTitle,
|
||||||
DrawerTrigger,
|
DrawerTrigger,
|
||||||
} from "@/frontend/components/ui/drawer"
|
} from "@/components/ui/drawer"
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuCheckboxItem,
|
DropdownMenuCheckboxItem,
|
||||||
|
|
@ -80,17 +80,17 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/frontend/components/ui/dropdown-menu"
|
} from "@/components/ui/dropdown-menu"
|
||||||
import { Input } from "@/frontend/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
import { Label } from "@/frontend/components/ui/label"
|
import { Label } from "@/components/ui/label"
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/frontend/components/ui/select"
|
} from "@/components/ui/select"
|
||||||
import { Separator } from "@/frontend/components/ui/separator"
|
import { Separator } from "@/components/ui/separator"
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
|
|
@ -98,13 +98,13 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/frontend/components/ui/table"
|
} from "@/components/ui/table"
|
||||||
import {
|
import {
|
||||||
Tabs,
|
Tabs,
|
||||||
TabsContent,
|
TabsContent,
|
||||||
TabsList,
|
TabsList,
|
||||||
TabsTrigger,
|
TabsTrigger,
|
||||||
} from "@/frontend/components/ui/tabs"
|
} from "@/components/ui/tabs"
|
||||||
|
|
||||||
export const schema = z.object({
|
export const schema = z.object({
|
||||||
id: z.number(),
|
id: z.number(),
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/frontend/components/ui/dropdown-menu"
|
} from "@/components/ui/dropdown-menu"
|
||||||
import {
|
import {
|
||||||
SidebarGroup,
|
SidebarGroup,
|
||||||
SidebarGroupLabel,
|
SidebarGroupLabel,
|
||||||
|
|
@ -23,7 +23,7 @@ import {
|
||||||
SidebarMenuButton,
|
SidebarMenuButton,
|
||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
useSidebar,
|
useSidebar,
|
||||||
} from "@/frontend/components/ui/sidebar"
|
} from "@/components/ui/sidebar"
|
||||||
|
|
||||||
export function NavDocuments({
|
export function NavDocuments({
|
||||||
items,
|
items,
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,14 @@
|
||||||
|
|
||||||
import { IconCirclePlusFilled, IconMail, type Icon } from "@tabler/icons-react"
|
import { IconCirclePlusFilled, IconMail, type Icon } from "@tabler/icons-react"
|
||||||
|
|
||||||
import { Button } from "@/frontend/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
SidebarGroup,
|
SidebarGroup,
|
||||||
SidebarGroupContent,
|
SidebarGroupContent,
|
||||||
SidebarMenu,
|
SidebarMenu,
|
||||||
SidebarMenuButton,
|
SidebarMenuButton,
|
||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
} from "@/frontend/components/ui/sidebar"
|
} from "@/components/ui/sidebar"
|
||||||
|
|
||||||
export function NavMain({
|
export function NavMain({
|
||||||
items,
|
items,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import {
|
||||||
SidebarMenu,
|
SidebarMenu,
|
||||||
SidebarMenuButton,
|
SidebarMenuButton,
|
||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
} from "@/frontend/components/ui/sidebar"
|
} from "@/components/ui/sidebar"
|
||||||
|
|
||||||
export function NavSecondary({
|
export function NavSecondary({
|
||||||
items,
|
items,
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import {
|
||||||
Avatar,
|
Avatar,
|
||||||
AvatarFallback,
|
AvatarFallback,
|
||||||
AvatarImage,
|
AvatarImage,
|
||||||
} from "@/frontend/components/ui/avatar"
|
} from "@/components/ui/avatar"
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -21,13 +21,13 @@ import {
|
||||||
DropdownMenuLabel,
|
DropdownMenuLabel,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/frontend/components/ui/dropdown-menu"
|
} from "@/components/ui/dropdown-menu"
|
||||||
import {
|
import {
|
||||||
SidebarMenu,
|
SidebarMenu,
|
||||||
SidebarMenuButton,
|
SidebarMenuButton,
|
||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
useSidebar,
|
useSidebar,
|
||||||
} from "@/frontend/components/ui/sidebar"
|
} from "@/components/ui/sidebar"
|
||||||
|
|
||||||
export function NavUser({
|
export function NavUser({
|
||||||
user,
|
user,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { IconTrendingDown, IconTrendingUp } from "@tabler/icons-react"
|
import { IconTrendingDown, IconTrendingUp } from "@tabler/icons-react"
|
||||||
|
|
||||||
import { Badge } from "@/frontend/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardAction,
|
CardAction,
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
CardFooter,
|
CardFooter,
|
||||||
CardHeader,
|
CardHeader,
|
||||||
CardTitle,
|
CardTitle,
|
||||||
} from "@/frontend/components/ui/card"
|
} from "@/components/ui/card"
|
||||||
|
|
||||||
export function SectionCards() {
|
export function SectionCards() {
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { Button } from "@/frontend/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import { Separator } from "@/frontend/components/ui/separator"
|
import { Separator } from "@/components/ui/separator"
|
||||||
import { SidebarTrigger } from "@/frontend/components/ui/sidebar"
|
import { SidebarTrigger } from "@/components/ui/sidebar"
|
||||||
|
|
||||||
export function SiteHeader() {
|
export function SiteHeader() {
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -7,23 +7,23 @@ import { PanelLeftIcon } from "lucide-react"
|
||||||
|
|
||||||
import { useIsMobile } from "@/hooks/use-mobile"
|
import { useIsMobile } from "@/hooks/use-mobile"
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
import { Button } from "@/frontend/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import { Input } from "@/frontend/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
import { Separator } from "@/frontend/components/ui/separator"
|
import { Separator } from "@/components/ui/separator"
|
||||||
import {
|
import {
|
||||||
Sheet,
|
Sheet,
|
||||||
SheetContent,
|
SheetContent,
|
||||||
SheetDescription,
|
SheetDescription,
|
||||||
SheetHeader,
|
SheetHeader,
|
||||||
SheetTitle,
|
SheetTitle,
|
||||||
} from "@/frontend/components/ui/sheet"
|
} from "@/components/ui/sheet"
|
||||||
import { Skeleton } from "@/frontend/components/ui/skeleton"
|
import { Skeleton } from "@/components/ui/skeleton"
|
||||||
import {
|
import {
|
||||||
Tooltip,
|
Tooltip,
|
||||||
TooltipContent,
|
TooltipContent,
|
||||||
TooltipProvider,
|
TooltipProvider,
|
||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from "@/frontend/components/ui/tooltip"
|
} from "@/components/ui/tooltip"
|
||||||
|
|
||||||
const SIDEBAR_COOKIE_NAME = "sidebar_state"
|
const SIDEBAR_COOKIE_NAME = "sidebar_state"
|
||||||
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
|
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group"
|
||||||
import { type VariantProps } from "class-variance-authority"
|
import { type VariantProps } from "class-variance-authority"
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
import { toggleVariants } from "@/frontend/components/ui/toggle"
|
import { toggleVariants } from "@/components/ui/toggle"
|
||||||
|
|
||||||
const ToggleGroupContext = React.createContext<
|
const ToggleGroupContext = React.createContext<
|
||||||
VariantProps<typeof toggleVariants> & {
|
VariantProps<typeof toggleVariants> & {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
"@tanstack/react-table": "^8.21.3",
|
"@tanstack/react-table": "^8.21.3",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
|
"graphql-request": "^7.3.3",
|
||||||
|
"graphql-type-json": "^0.3.2",
|
||||||
"lucide-react": "^0.553.0",
|
"lucide-react": "^0.553.0",
|
||||||
"next": "16.0.2",
|
"next": "16.0.2",
|
||||||
"next-auth": "^4.24.7",
|
"next-auth": "^4.24.7",
|
||||||
|
|
@ -37,7 +39,8 @@
|
||||||
"recharts": "^2.15.4",
|
"recharts": "^2.15.4",
|
||||||
"sonner": "^2.0.7",
|
"sonner": "^2.0.7",
|
||||||
"tailwind-merge": "^3.4.0",
|
"tailwind-merge": "^3.4.0",
|
||||||
"vaul": "^1.1.2"
|
"vaul": "^1.1.2",
|
||||||
|
"zod": "^4.1.12"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/postcss": "^4",
|
"@tailwindcss/postcss": "^4",
|
||||||
|
|
@ -597,6 +600,15 @@
|
||||||
"integrity": "sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==",
|
"integrity": "sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@graphql-typed-document-node/core": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@graphql-typed-document-node/core/-/core-3.2.0.tgz",
|
||||||
|
"integrity": "sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@humanfs/core": {
|
"node_modules/@humanfs/core": {
|
||||||
"version": "0.19.1",
|
"version": "0.19.1",
|
||||||
"resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz",
|
"resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz",
|
||||||
|
|
@ -5942,6 +5954,37 @@
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/graphql": {
|
||||||
|
"version": "16.12.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/graphql/-/graphql-16.12.0.tgz",
|
||||||
|
"integrity": "sha512-DKKrynuQRne0PNpEbzuEdHlYOMksHSUI8Zc9Unei5gTsMNA2/vMpoMz/yKba50pejK56qj98qM0SjYxAKi13gQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
|
"engines": {
|
||||||
|
"node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/graphql-request": {
|
||||||
|
"version": "7.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/graphql-request/-/graphql-request-7.3.3.tgz",
|
||||||
|
"integrity": "sha512-I0ZSz53XTpDiQZ0/KGElwfnzIqsdNek/D6tcZgheL8QOVeSbkgE3qG7r1G/MKtnNenWtEjHbsDf2iPlXSWxFtw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@graphql-typed-document-node/core": "^3.2.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"graphql": "14 - 16"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/graphql-type-json": {
|
||||||
|
"version": "0.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/graphql-type-json/-/graphql-type-json-0.3.2.tgz",
|
||||||
|
"integrity": "sha512-J+vjof74oMlCWXSvt0DOf2APEdZOCdubEvGDUAlqH//VBYcOYsGgRW7Xzorr44LvkjiuvecWc8fChxuZZbChtg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"graphql": ">=0.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/has-bigints": {
|
"node_modules/has-bigints": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.1.0.tgz",
|
||||||
|
|
@ -9116,7 +9159,6 @@
|
||||||
"version": "4.1.12",
|
"version": "4.1.12",
|
||||||
"resolved": "https://registry.npmjs.org/zod/-/zod-4.1.12.tgz",
|
"resolved": "https://registry.npmjs.org/zod/-/zod-4.1.12.tgz",
|
||||||
"integrity": "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ==",
|
"integrity": "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"funding": {
|
"funding": {
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@
|
||||||
"@tanstack/react-table": "^8.21.3",
|
"@tanstack/react-table": "^8.21.3",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
|
"graphql-request": "^7.3.3",
|
||||||
|
"graphql-type-json": "^0.3.2",
|
||||||
"lucide-react": "^0.553.0",
|
"lucide-react": "^0.553.0",
|
||||||
"next": "16.0.2",
|
"next": "16.0.2",
|
||||||
"next-auth": "^4.24.7",
|
"next-auth": "^4.24.7",
|
||||||
|
|
@ -38,7 +40,8 @@
|
||||||
"recharts": "^2.15.4",
|
"recharts": "^2.15.4",
|
||||||
"sonner": "^2.0.7",
|
"sonner": "^2.0.7",
|
||||||
"tailwind-merge": "^3.4.0",
|
"tailwind-merge": "^3.4.0",
|
||||||
"vaul": "^1.1.2"
|
"vaul": "^1.1.2",
|
||||||
|
"zod": "^4.1.12"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/postcss": "^4",
|
"@tailwindcss/postcss": "^4",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,614 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"header": "Cover page",
|
||||||
|
"type": "Cover page",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "18",
|
||||||
|
"limit": "5",
|
||||||
|
"reviewer": "Eddie Lake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"header": "Table of contents",
|
||||||
|
"type": "Table of contents",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "29",
|
||||||
|
"limit": "24",
|
||||||
|
"reviewer": "Eddie Lake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"header": "Executive summary",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "10",
|
||||||
|
"limit": "13",
|
||||||
|
"reviewer": "Eddie Lake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"header": "Technical approach",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "27",
|
||||||
|
"limit": "23",
|
||||||
|
"reviewer": "Jamik Tashpulatov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 5,
|
||||||
|
"header": "Design",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "2",
|
||||||
|
"limit": "16",
|
||||||
|
"reviewer": "Jamik Tashpulatov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 6,
|
||||||
|
"header": "Capabilities",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "20",
|
||||||
|
"limit": "8",
|
||||||
|
"reviewer": "Jamik Tashpulatov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 7,
|
||||||
|
"header": "Integration with existing systems",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "19",
|
||||||
|
"limit": "21",
|
||||||
|
"reviewer": "Jamik Tashpulatov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 8,
|
||||||
|
"header": "Innovation and Advantages",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "25",
|
||||||
|
"limit": "26",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 9,
|
||||||
|
"header": "Overview of EMR's Innovative Solutions",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "7",
|
||||||
|
"limit": "23",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 10,
|
||||||
|
"header": "Advanced Algorithms and Machine Learning",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "30",
|
||||||
|
"limit": "28",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 11,
|
||||||
|
"header": "Adaptive Communication Protocols",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "9",
|
||||||
|
"limit": "31",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 12,
|
||||||
|
"header": "Advantages Over Current Technologies",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "12",
|
||||||
|
"limit": "0",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 13,
|
||||||
|
"header": "Past Performance",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "22",
|
||||||
|
"limit": "33",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 14,
|
||||||
|
"header": "Customer Feedback and Satisfaction Levels",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "15",
|
||||||
|
"limit": "34",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 15,
|
||||||
|
"header": "Implementation Challenges and Solutions",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "3",
|
||||||
|
"limit": "35",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 16,
|
||||||
|
"header": "Security Measures and Data Protection Policies",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "6",
|
||||||
|
"limit": "36",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 17,
|
||||||
|
"header": "Scalability and Future Proofing",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "4",
|
||||||
|
"limit": "37",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 18,
|
||||||
|
"header": "Cost-Benefit Analysis",
|
||||||
|
"type": "Plain language",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "14",
|
||||||
|
"limit": "38",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 19,
|
||||||
|
"header": "User Training and Onboarding Experience",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "17",
|
||||||
|
"limit": "39",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 20,
|
||||||
|
"header": "Future Development Roadmap",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "11",
|
||||||
|
"limit": "40",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 21,
|
||||||
|
"header": "System Architecture Overview",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "24",
|
||||||
|
"limit": "18",
|
||||||
|
"reviewer": "Maya Johnson"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 22,
|
||||||
|
"header": "Risk Management Plan",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "15",
|
||||||
|
"limit": "22",
|
||||||
|
"reviewer": "Carlos Rodriguez"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 23,
|
||||||
|
"header": "Compliance Documentation",
|
||||||
|
"type": "Legal",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "31",
|
||||||
|
"limit": "27",
|
||||||
|
"reviewer": "Sarah Chen"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 24,
|
||||||
|
"header": "API Documentation",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "8",
|
||||||
|
"limit": "12",
|
||||||
|
"reviewer": "Raj Patel"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 25,
|
||||||
|
"header": "User Interface Mockups",
|
||||||
|
"type": "Visual",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "19",
|
||||||
|
"limit": "25",
|
||||||
|
"reviewer": "Leila Ahmadi"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 26,
|
||||||
|
"header": "Database Schema",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "22",
|
||||||
|
"limit": "20",
|
||||||
|
"reviewer": "Thomas Wilson"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 27,
|
||||||
|
"header": "Testing Methodology",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "17",
|
||||||
|
"limit": "14",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 28,
|
||||||
|
"header": "Deployment Strategy",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "26",
|
||||||
|
"limit": "30",
|
||||||
|
"reviewer": "Eddie Lake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 29,
|
||||||
|
"header": "Budget Breakdown",
|
||||||
|
"type": "Financial",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "13",
|
||||||
|
"limit": "16",
|
||||||
|
"reviewer": "Jamik Tashpulatov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 30,
|
||||||
|
"header": "Market Analysis",
|
||||||
|
"type": "Research",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "29",
|
||||||
|
"limit": "32",
|
||||||
|
"reviewer": "Sophia Martinez"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 31,
|
||||||
|
"header": "Competitor Comparison",
|
||||||
|
"type": "Research",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "21",
|
||||||
|
"limit": "19",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 32,
|
||||||
|
"header": "Maintenance Plan",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "16",
|
||||||
|
"limit": "23",
|
||||||
|
"reviewer": "Alex Thompson"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 33,
|
||||||
|
"header": "User Personas",
|
||||||
|
"type": "Research",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "27",
|
||||||
|
"limit": "24",
|
||||||
|
"reviewer": "Nina Patel"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 34,
|
||||||
|
"header": "Accessibility Compliance",
|
||||||
|
"type": "Legal",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "18",
|
||||||
|
"limit": "21",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 35,
|
||||||
|
"header": "Performance Metrics",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "23",
|
||||||
|
"limit": "26",
|
||||||
|
"reviewer": "David Kim"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 36,
|
||||||
|
"header": "Disaster Recovery Plan",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "14",
|
||||||
|
"limit": "17",
|
||||||
|
"reviewer": "Jamik Tashpulatov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 37,
|
||||||
|
"header": "Third-party Integrations",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "25",
|
||||||
|
"limit": "28",
|
||||||
|
"reviewer": "Eddie Lake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 38,
|
||||||
|
"header": "User Feedback Summary",
|
||||||
|
"type": "Research",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "20",
|
||||||
|
"limit": "15",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 39,
|
||||||
|
"header": "Localization Strategy",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "12",
|
||||||
|
"limit": "19",
|
||||||
|
"reviewer": "Maria Garcia"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 40,
|
||||||
|
"header": "Mobile Compatibility",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "28",
|
||||||
|
"limit": "31",
|
||||||
|
"reviewer": "James Wilson"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 41,
|
||||||
|
"header": "Data Migration Plan",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "19",
|
||||||
|
"limit": "22",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 42,
|
||||||
|
"header": "Quality Assurance Protocols",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "30",
|
||||||
|
"limit": "33",
|
||||||
|
"reviewer": "Priya Singh"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 43,
|
||||||
|
"header": "Stakeholder Analysis",
|
||||||
|
"type": "Research",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "11",
|
||||||
|
"limit": "14",
|
||||||
|
"reviewer": "Eddie Lake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 44,
|
||||||
|
"header": "Environmental Impact Assessment",
|
||||||
|
"type": "Research",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "24",
|
||||||
|
"limit": "27",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 45,
|
||||||
|
"header": "Intellectual Property Rights",
|
||||||
|
"type": "Legal",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "17",
|
||||||
|
"limit": "20",
|
||||||
|
"reviewer": "Sarah Johnson"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 46,
|
||||||
|
"header": "Customer Support Framework",
|
||||||
|
"type": "Narrative",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "22",
|
||||||
|
"limit": "25",
|
||||||
|
"reviewer": "Jamik Tashpulatov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 47,
|
||||||
|
"header": "Version Control Strategy",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "15",
|
||||||
|
"limit": "18",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 48,
|
||||||
|
"header": "Continuous Integration Pipeline",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "26",
|
||||||
|
"limit": "29",
|
||||||
|
"reviewer": "Michael Chen"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 49,
|
||||||
|
"header": "Regulatory Compliance",
|
||||||
|
"type": "Legal",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "13",
|
||||||
|
"limit": "16",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 50,
|
||||||
|
"header": "User Authentication System",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "28",
|
||||||
|
"limit": "31",
|
||||||
|
"reviewer": "Eddie Lake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 51,
|
||||||
|
"header": "Data Analytics Framework",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "21",
|
||||||
|
"limit": "24",
|
||||||
|
"reviewer": "Jamik Tashpulatov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 52,
|
||||||
|
"header": "Cloud Infrastructure",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "16",
|
||||||
|
"limit": "19",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 53,
|
||||||
|
"header": "Network Security Measures",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "29",
|
||||||
|
"limit": "32",
|
||||||
|
"reviewer": "Lisa Wong"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 54,
|
||||||
|
"header": "Project Timeline",
|
||||||
|
"type": "Planning",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "14",
|
||||||
|
"limit": "17",
|
||||||
|
"reviewer": "Eddie Lake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 55,
|
||||||
|
"header": "Resource Allocation",
|
||||||
|
"type": "Planning",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "27",
|
||||||
|
"limit": "30",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 56,
|
||||||
|
"header": "Team Structure and Roles",
|
||||||
|
"type": "Planning",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "20",
|
||||||
|
"limit": "23",
|
||||||
|
"reviewer": "Jamik Tashpulatov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 57,
|
||||||
|
"header": "Communication Protocols",
|
||||||
|
"type": "Planning",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "15",
|
||||||
|
"limit": "18",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 58,
|
||||||
|
"header": "Success Metrics",
|
||||||
|
"type": "Planning",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "30",
|
||||||
|
"limit": "33",
|
||||||
|
"reviewer": "Eddie Lake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 59,
|
||||||
|
"header": "Internationalization Support",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "23",
|
||||||
|
"limit": "26",
|
||||||
|
"reviewer": "Jamik Tashpulatov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 60,
|
||||||
|
"header": "Backup and Recovery Procedures",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "18",
|
||||||
|
"limit": "21",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 61,
|
||||||
|
"header": "Monitoring and Alerting System",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "25",
|
||||||
|
"limit": "28",
|
||||||
|
"reviewer": "Daniel Park"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 62,
|
||||||
|
"header": "Code Review Guidelines",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "12",
|
||||||
|
"limit": "15",
|
||||||
|
"reviewer": "Eddie Lake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 63,
|
||||||
|
"header": "Documentation Standards",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "27",
|
||||||
|
"limit": "30",
|
||||||
|
"reviewer": "Jamik Tashpulatov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 64,
|
||||||
|
"header": "Release Management Process",
|
||||||
|
"type": "Planning",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "22",
|
||||||
|
"limit": "25",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 65,
|
||||||
|
"header": "Feature Prioritization Matrix",
|
||||||
|
"type": "Planning",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "19",
|
||||||
|
"limit": "22",
|
||||||
|
"reviewer": "Emma Davis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 66,
|
||||||
|
"header": "Technical Debt Assessment",
|
||||||
|
"type": "Technical content",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "24",
|
||||||
|
"limit": "27",
|
||||||
|
"reviewer": "Eddie Lake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 67,
|
||||||
|
"header": "Capacity Planning",
|
||||||
|
"type": "Planning",
|
||||||
|
"status": "In Process",
|
||||||
|
"target": "21",
|
||||||
|
"limit": "24",
|
||||||
|
"reviewer": "Jamik Tashpulatov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 68,
|
||||||
|
"header": "Service Level Agreements",
|
||||||
|
"type": "Legal",
|
||||||
|
"status": "Done",
|
||||||
|
"target": "26",
|
||||||
|
"limit": "29",
|
||||||
|
"reviewer": "Assign reviewer"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
import { AppSidebar } from "@/components/app-sidebar"
|
import { AppSidebar } from "@/components/dashboard/app-sidebar"
|
||||||
import { ChartAreaInteractive } from "@/components/chart-area-interactive"
|
import { ChartAreaInteractive } from "@/components/dashboard/chart-area-interactive"
|
||||||
import { DataTable } from "@/components/data-table"
|
import { DataTable } from "@/components/dashboard/data-table"
|
||||||
import { SectionCards } from "@/components/section-cards"
|
import { SectionCards } from "@/components/dashboard/section-cards"
|
||||||
import { SiteHeader } from "@/components/site-header"
|
import { SiteHeader } from "@/components/dashboard/site-header"
|
||||||
import {
|
import {
|
||||||
SidebarInset,
|
SidebarInset,
|
||||||
SidebarProvider,
|
SidebarProvider,
|
||||||
} from "@/frontend/components/ui/sidebar"
|
} from "@/components/ui/sidebar"
|
||||||
|
|
||||||
import data from "./data.json"
|
import data from "./data.json"
|
||||||
|
|
||||||
export default function Page() {
|
export default function DashboardPage() {
|
||||||
return (
|
return (
|
||||||
<SidebarProvider
|
<SidebarProvider
|
||||||
style={
|
style={
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
'use client';
|
||||||
|
import { useGraphQlUsersList } from './queries';
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
const PageUsers = () => {
|
||||||
|
const [page, setPage] = useState(1);
|
||||||
|
const [limit, setLimit] = useState(10);
|
||||||
|
const [sort, setSort] = useState({ createdAt: 'desc' });
|
||||||
|
const [filters, setFilters] = useState({});
|
||||||
|
const { data, isLoading, error } = useGraphQlUsersList({ limit, skip: (page - 1) * limit, sort, filters });
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>Users</h1>
|
||||||
|
{isLoading && <p>Loading...</p>}
|
||||||
|
{error && <p>Error: {error.message}</p>}
|
||||||
|
{data && <p>Total count: {data.totalCount}</p>}
|
||||||
|
<div>
|
||||||
|
{data && <p>Data: {JSON.stringify(data.data)}</p>}
|
||||||
|
<button onClick={() => setPage(page - 1)}>Previous</button>
|
||||||
|
<button onClick={() => setPage(page + 1)}>Next</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { PageUsers };
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
'use client'
|
||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
import { UsersListResponse } from './types'
|
||||||
|
import { ListArguments } from '@/types/listRequest'
|
||||||
|
|
||||||
|
const fetchGraphQlUsersList = async (params: ListArguments): Promise<UsersListResponse> => {
|
||||||
|
console.log('Fetching test data from local API');
|
||||||
|
const { limit, skip, sort, filters } = params;
|
||||||
|
try {
|
||||||
|
const res = await fetch('/api/users/list', { method: 'POST', cache: 'no-store', credentials: "include", body: JSON.stringify({ limit, skip, sort, filters }) });
|
||||||
|
if (!res.ok) { const errorText = await res.text(); console.error('Test data API error:', errorText); throw new Error(`API error: ${res.status} ${res.statusText}`) }
|
||||||
|
const data = await res.json();
|
||||||
|
return { data: data.data, totalCount: data.totalCount }
|
||||||
|
} catch (error) { console.error('Error fetching test data:', error); throw error }
|
||||||
|
};
|
||||||
|
|
||||||
|
export function useGraphQlUsersList(params: ListArguments) {
|
||||||
|
return useQuery({ queryKey: ['graphql-users-list', params], queryFn: () => fetchGraphQlUsersList(params) })
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
interface UserToken {
|
||||||
|
prefix: string;
|
||||||
|
token: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CollectionTokens {
|
||||||
|
default: string;
|
||||||
|
tokens: UserToken[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface User {
|
||||||
|
_id: string;
|
||||||
|
uuid: string;
|
||||||
|
expiryStarts: string;
|
||||||
|
expiryEnds: string;
|
||||||
|
isConfirmed: boolean;
|
||||||
|
deleted: boolean;
|
||||||
|
active: boolean;
|
||||||
|
crypUuId: string;
|
||||||
|
createdCredentialsToken: string;
|
||||||
|
updatedCredentialsToken: string;
|
||||||
|
confirmedCredentialsToken: string;
|
||||||
|
isNotificationSend: boolean;
|
||||||
|
isEmailSend: boolean;
|
||||||
|
refInt: number;
|
||||||
|
refId: string;
|
||||||
|
replicationId: number;
|
||||||
|
expiresAt: string;
|
||||||
|
resetToken?: string | null;
|
||||||
|
password: string;
|
||||||
|
history: string[];
|
||||||
|
tag: string;
|
||||||
|
email: string;
|
||||||
|
phone: string;
|
||||||
|
collectionTokens: CollectionTokens;
|
||||||
|
createdAt: string;
|
||||||
|
updatedAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UsersListResponse {
|
||||||
|
data: User[] | null;
|
||||||
|
totalCount: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export type { User, UsersListResponse }
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": [
|
"@/*": [
|
||||||
"./frontend/*"
|
"./*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -35,6 +35,8 @@
|
||||||
"frontend/.next/types/**/*.ts",
|
"frontend/.next/types/**/*.ts",
|
||||||
"frontend/.next/dev/types/**/*.ts",
|
"frontend/.next/dev/types/**/*.ts",
|
||||||
"**/*.mts",
|
"**/*.mts",
|
||||||
|
".next/types/**/*.ts",
|
||||||
|
".next/dev/types/**/*.ts"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
interface ListArguments {
|
||||||
|
filters?: Record<string, any>;
|
||||||
|
sort?: Record<string, any>;
|
||||||
|
skip: number;
|
||||||
|
limit: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { ListArguments };
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"name": "evyos-frontend-development",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"node_modules/@types/graphql": {
|
||||||
|
"version": "14.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/graphql/-/graphql-14.2.3.tgz",
|
||||||
|
"integrity": "sha512-UoCovaxbJIxagCvVfalfK7YaNhmxj3BQFRQ2RHQKLiu+9wNXhJnlbspsLHt/YQM99IaLUUFJNzCwzc6W0ypMeQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/graphql": {
|
||||||
|
"version": "16.12.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/graphql/-/graphql-16.12.0.tgz",
|
||||||
|
"integrity": "sha512-DKKrynuQRne0PNpEbzuEdHlYOMksHSUI8Zc9Unei5gTsMNA2/vMpoMz/yKba50pejK56qj98qM0SjYxAKi13gQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/graphql`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for graphql (https://github.com/graphql/graphql-js).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/graphql
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Mon, 22 Jul 2019 20:06:37 GMT
|
||||||
|
* Dependencies: none
|
||||||
|
* Global values: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by TonyYang <https://github.com/TonyPythoneer>, Caleb Meredith <https://github.com/calebmer>, Dominic Watson <https://github.com/intellix>, Firede <https://github.com/firede>, Kepennar <https://github.com/kepennar>, Mikhail Novikov <https://github.com/freiksenet>, Ivan Goncharov <https://github.com/IvanGoncharov>, Hagai Cohen <https://github.com/DxCx>, Ricardo Portugal <https://github.com/rportugal>, Tim Griesser <https://github.com/tgriesser>, Dylan Stewart <https://github.com/dyst5422>, Alessio Dionisi <https://github.com/adnsio>, Divyendu Singh <https://github.com/divyenduz>, Brad Zacher <https://github.com/bradzacher>, Curtis Layne <https://github.com/clayne11>, Jonathan Cardoso <https://github.com/JCMais>, Pavel Lang <https://github.com/langpavel>, Mark Caudill <https://github.com/mc0>, Martijn Walraven <https://github.com/martijnwalraven>, and Jed Mao <https://github.com/jedmao>.
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import { getLocation } from "../language";
|
||||||
|
import { ASTNode } from "../language/ast";
|
||||||
|
import { Source } from "../language/source";
|
||||||
|
import { SourceLocation } from "../language/location";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A GraphQLError describes an Error found during the parse, validate, or
|
||||||
|
* execute phases of performing a GraphQL operation. In addition to a message
|
||||||
|
* and stack trace, it also includes information about the locations in a
|
||||||
|
* GraphQL document and/or execution result that correspond to the Error.
|
||||||
|
*/
|
||||||
|
export class GraphQLError extends Error {
|
||||||
|
/**
|
||||||
|
* A message describing the Error for debugging purposes.
|
||||||
|
*
|
||||||
|
* Enumerable, and appears in the result of JSON.stringify().
|
||||||
|
*
|
||||||
|
* Note: should be treated as readonly, despite invariant usage.
|
||||||
|
*/
|
||||||
|
message: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array of { line, column } locations within the source GraphQL document
|
||||||
|
* which correspond to this error.
|
||||||
|
*
|
||||||
|
* Errors during validation often contain multiple locations, for example to
|
||||||
|
* point out two things with the same name. Errors during execution include a
|
||||||
|
* single location, the field which produced the error.
|
||||||
|
*
|
||||||
|
* Enumerable, and appears in the result of JSON.stringify().
|
||||||
|
*/
|
||||||
|
readonly locations: ReadonlyArray<SourceLocation> | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array describing the JSON-path into the execution response which
|
||||||
|
* corresponds to this error. Only included for errors during execution.
|
||||||
|
*
|
||||||
|
* Enumerable, and appears in the result of JSON.stringify().
|
||||||
|
*/
|
||||||
|
readonly path: ReadonlyArray<string | number> | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array of GraphQL AST Nodes corresponding to this error.
|
||||||
|
*/
|
||||||
|
readonly nodes: ReadonlyArray<ASTNode> | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The source GraphQL document corresponding to this error.
|
||||||
|
*/
|
||||||
|
readonly source: Source | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array of character offsets within the source GraphQL document
|
||||||
|
* which correspond to this error.
|
||||||
|
*/
|
||||||
|
readonly positions: ReadonlyArray<number> | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The original error thrown from a field resolver during execution.
|
||||||
|
*/
|
||||||
|
readonly originalError: Maybe<Error>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension fields to add to the formatted error.
|
||||||
|
*/
|
||||||
|
readonly extensions: { [key: string]: any } | undefined;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
message: string,
|
||||||
|
nodes?: ReadonlyArray<ASTNode> | ASTNode | undefined,
|
||||||
|
source?: Maybe<Source>,
|
||||||
|
positions?: Maybe<ReadonlyArray<number>>,
|
||||||
|
path?: Maybe<ReadonlyArray<string | number>>,
|
||||||
|
originalError?: Maybe<Error>,
|
||||||
|
extensions?: Maybe<{ [key: string]: any }>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
import { GraphQLError } from "./GraphQLError";
|
||||||
|
import { SourceLocation } from "../language/location";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a GraphQLError, format it according to the rules described by the
|
||||||
|
* Response Format, Errors section of the GraphQL Specification.
|
||||||
|
*/
|
||||||
|
export function formatError(error: GraphQLError): GraphQLFormattedError;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
||||||
|
*/
|
||||||
|
export interface GraphQLFormattedError<
|
||||||
|
TExtensions extends Record<string, any> = Record<string, any>
|
||||||
|
> {
|
||||||
|
/**
|
||||||
|
* A short, human-readable summary of the problem that **SHOULD NOT** change
|
||||||
|
* from occurrence to occurrence of the problem, except for purposes of
|
||||||
|
* localization.
|
||||||
|
*/
|
||||||
|
readonly message: string
|
||||||
|
/**
|
||||||
|
* If an error can be associated to a particular point in the requested
|
||||||
|
* GraphQL document, it should contain a list of locations.
|
||||||
|
*/
|
||||||
|
readonly locations?: ReadonlyArray<SourceLocation>
|
||||||
|
/**
|
||||||
|
* If an error can be associated to a particular field in the GraphQL result,
|
||||||
|
* it _must_ contain an entry with the key `path` that details the path of
|
||||||
|
* the response field which experienced the error. This allows clients to
|
||||||
|
* identify whether a null result is intentional or caused by a runtime error.
|
||||||
|
*/
|
||||||
|
readonly path?: ReadonlyArray<string | number>
|
||||||
|
/**
|
||||||
|
* Reserved for implementors to extend the protocol however they see fit,
|
||||||
|
* and hence there are no additional restrictions on its contents.
|
||||||
|
*/
|
||||||
|
readonly extensions?: TExtensions
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
export { GraphQLError } from "./GraphQLError";
|
||||||
|
export { syntaxError } from "./syntaxError";
|
||||||
|
export { locatedError } from "./locatedError";
|
||||||
|
export { printError } from "./printError";
|
||||||
|
export { formatError, GraphQLFormattedError } from "./formatError";
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { GraphQLError } from "./GraphQLError";
|
||||||
|
import { ASTNode } from "../language/ast";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given an arbitrary Error, presumably thrown while attempting to execute a
|
||||||
|
* GraphQL operation, produce a new GraphQLError aware of the location in the
|
||||||
|
* document responsible for the original Error.
|
||||||
|
*/
|
||||||
|
export function locatedError(
|
||||||
|
originalError: Error | GraphQLError,
|
||||||
|
nodes: ReadonlyArray<ASTNode>,
|
||||||
|
path: ReadonlyArray<string | number>
|
||||||
|
): GraphQLError;
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { GraphQLError } from "./GraphQLError";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints a GraphQLError to a string, representing useful location information
|
||||||
|
* about the error's position in the source.
|
||||||
|
*/
|
||||||
|
export function printError(error: GraphQLError): string;
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { Source } from "../language/source";
|
||||||
|
import { GraphQLError } from "./GraphQLError";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Produces a GraphQLError representing a syntax error, containing useful
|
||||||
|
* descriptive information about the syntax error's position in the source.
|
||||||
|
*/
|
||||||
|
export function syntaxError(source: Source, position: number, description: string): GraphQLError;
|
||||||
|
|
@ -0,0 +1,187 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import { GraphQLError, locatedError } from "../error";
|
||||||
|
import { GraphQLSchema } from "../type/schema";
|
||||||
|
import {
|
||||||
|
GraphQLField,
|
||||||
|
GraphQLFieldResolver,
|
||||||
|
ResponsePath,
|
||||||
|
GraphQLObjectType,
|
||||||
|
GraphQLResolveInfo,
|
||||||
|
} from "../type/definition";
|
||||||
|
import {
|
||||||
|
DirectiveNode,
|
||||||
|
DocumentNode,
|
||||||
|
OperationDefinitionNode,
|
||||||
|
SelectionSetNode,
|
||||||
|
FieldNode,
|
||||||
|
InlineFragmentNode,
|
||||||
|
FragmentDefinitionNode,
|
||||||
|
} from "../language/ast";
|
||||||
|
import { PromiseOrValue } from "../jsutils/PromiseOrValue";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data that must be available at all points during query execution.
|
||||||
|
*
|
||||||
|
* Namely, schema of the type system that is currently executing,
|
||||||
|
* and the fragments defined in the query document
|
||||||
|
*/
|
||||||
|
export interface ExecutionContext {
|
||||||
|
schema: GraphQLSchema;
|
||||||
|
fragments: { [key: string]: FragmentDefinitionNode };
|
||||||
|
rootValue: any;
|
||||||
|
contextValue: any;
|
||||||
|
operation: OperationDefinitionNode;
|
||||||
|
variableValues: { [key: string]: any };
|
||||||
|
fieldResolver: GraphQLFieldResolver<any, any>;
|
||||||
|
errors: GraphQLError[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ExecutionResultDataDefault {
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The result of GraphQL execution.
|
||||||
|
*
|
||||||
|
* - `errors` is included when any errors occurred as a non-empty array.
|
||||||
|
* - `data` is the result of a successful execution of the query.
|
||||||
|
*/
|
||||||
|
export interface ExecutionResult<TData = ExecutionResultDataDefault> {
|
||||||
|
errors?: ReadonlyArray<GraphQLError>;
|
||||||
|
data?: TData;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ExecutionArgs = {
|
||||||
|
schema: GraphQLSchema;
|
||||||
|
document: DocumentNode;
|
||||||
|
rootValue?: any;
|
||||||
|
contextValue?: any;
|
||||||
|
variableValues?: Maybe<{ [key: string]: any }>;
|
||||||
|
operationName?: Maybe<string>;
|
||||||
|
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements the "Evaluating requests" section of the GraphQL specification.
|
||||||
|
*
|
||||||
|
* Returns either a synchronous ExecutionResult (if all encountered resolvers
|
||||||
|
* are synchronous), or a Promise of an ExecutionResult that will eventually be
|
||||||
|
* resolved and never rejected.
|
||||||
|
*
|
||||||
|
* If the arguments to this function do not result in a legal execution context,
|
||||||
|
* a GraphQLError will be thrown immediately explaining the invalid input.
|
||||||
|
*
|
||||||
|
* Accepts either an object with named arguments, or individual arguments.
|
||||||
|
*/
|
||||||
|
export function execute<TData = ExecutionResultDataDefault>(
|
||||||
|
args: ExecutionArgs
|
||||||
|
): PromiseOrValue<ExecutionResult<TData>>;
|
||||||
|
export function execute<TData = ExecutionResultDataDefault>(
|
||||||
|
schema: GraphQLSchema,
|
||||||
|
document: DocumentNode,
|
||||||
|
rootValue?: any,
|
||||||
|
contextValue?: any,
|
||||||
|
variableValues?: Maybe<{ [key: string]: any }>,
|
||||||
|
operationName?: Maybe<string>,
|
||||||
|
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
|
||||||
|
): PromiseOrValue<ExecutionResult<TData>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a ResponsePath (found in the `path` entry in the information provided
|
||||||
|
* as the last argument to a field resolver), return an Array of the path keys.
|
||||||
|
*/
|
||||||
|
export function responsePathAsArray(path: ResponsePath): ReadonlyArray<string | number>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a ResponsePath and a key, return a new ResponsePath containing the
|
||||||
|
* new key.
|
||||||
|
|
||||||
|
*/
|
||||||
|
export function addPath(
|
||||||
|
prev: ResponsePath | undefined,
|
||||||
|
key: string | number
|
||||||
|
): { prev: ResponsePath | undefined; key: string | number };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Essential assertions before executing to provide developer feedback for
|
||||||
|
* improper use of the GraphQL library.
|
||||||
|
*/
|
||||||
|
export function assertValidExecutionArguments(
|
||||||
|
schema: GraphQLSchema,
|
||||||
|
document: DocumentNode,
|
||||||
|
rawVariableValues: Maybe<{ [key: string]: any }>
|
||||||
|
): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a ExecutionContext object from the arguments passed to
|
||||||
|
* execute, which we will pass throughout the other execution methods.
|
||||||
|
*
|
||||||
|
* Throws a GraphQLError if a valid execution context cannot be created.
|
||||||
|
*/
|
||||||
|
export function buildExecutionContext(
|
||||||
|
schema: GraphQLSchema,
|
||||||
|
document: DocumentNode,
|
||||||
|
rootValue: any,
|
||||||
|
contextValue: any,
|
||||||
|
rawVariableValues: Maybe<{ [key: string]: any }>,
|
||||||
|
operationName: Maybe<string>,
|
||||||
|
fieldResolver: Maybe<GraphQLFieldResolver<any, any>>
|
||||||
|
): ReadonlyArray<GraphQLError> | ExecutionContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a selectionSet, adds all of the fields in that selection to
|
||||||
|
* the passed in map of fields, and returns it at the end.
|
||||||
|
*
|
||||||
|
* CollectFields requires the "runtime type" of an object. For a field which
|
||||||
|
* returns an Interface or Union type, the "runtime type" will be the actual
|
||||||
|
* Object type returned by that field.
|
||||||
|
*/
|
||||||
|
export function collectFields(
|
||||||
|
exeContext: ExecutionContext,
|
||||||
|
runtimeType: GraphQLObjectType,
|
||||||
|
selectionSet: SelectionSetNode,
|
||||||
|
fields: { [key: string]: Array<FieldNode> },
|
||||||
|
visitedFragmentNames: { [key: string]: boolean }
|
||||||
|
): { [key: string]: Array<FieldNode> };
|
||||||
|
|
||||||
|
export function buildResolveInfo(
|
||||||
|
exeContext: ExecutionContext,
|
||||||
|
fieldDef: GraphQLField<any, any>,
|
||||||
|
fieldNodes: ReadonlyArray<FieldNode>,
|
||||||
|
parentType: GraphQLObjectType,
|
||||||
|
path: ResponsePath
|
||||||
|
): GraphQLResolveInfo;
|
||||||
|
|
||||||
|
// Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
|
||||||
|
// function. Returns the result of resolveFn or the abrupt-return Error object.
|
||||||
|
export function resolveFieldValueOrError<TSource>(
|
||||||
|
exeContext: ExecutionContext,
|
||||||
|
fieldDef: GraphQLField<TSource, any>,
|
||||||
|
fieldNodes: ReadonlyArray<FieldNode>,
|
||||||
|
resolveFn: GraphQLFieldResolver<TSource, any>,
|
||||||
|
source: TSource,
|
||||||
|
info: GraphQLResolveInfo
|
||||||
|
): Error | any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a resolve function is not given, then a default resolve behavior is used
|
||||||
|
* which takes the property of the source object of the same name as the field
|
||||||
|
* and returns it as the result, or if it's a function, returns the result
|
||||||
|
* of calling that function while passing along args and context.
|
||||||
|
*/
|
||||||
|
export const defaultFieldResolver: GraphQLFieldResolver<any, any>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method looks up the field on the given type defintion.
|
||||||
|
* It has special casing for the two introspection fields, __schema
|
||||||
|
* and __typename. __typename is special because it can always be
|
||||||
|
* queried as a field, even in situations where no other fields
|
||||||
|
* are allowed, like on a Union. __schema could get automatically
|
||||||
|
* added to the query type, but that would require mutating type
|
||||||
|
* definitions, which would cause issues.
|
||||||
|
*/
|
||||||
|
export function getFieldDef(
|
||||||
|
schema: GraphQLSchema,
|
||||||
|
parentType: GraphQLObjectType,
|
||||||
|
fieldName: string
|
||||||
|
): Maybe<GraphQLField<any, any>>;
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
export { execute, defaultFieldResolver, responsePathAsArray, ExecutionArgs, ExecutionResult } from "./execute";
|
||||||
|
|
||||||
|
export { getDirectiveValues } from "./values";
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import { GraphQLError } from "../error/GraphQLError";
|
||||||
|
import { GraphQLInputType, GraphQLField, GraphQLArgument } from "../type/definition";
|
||||||
|
import { GraphQLDirective } from "../type/directives";
|
||||||
|
import { GraphQLSchema } from "../type/schema";
|
||||||
|
import { FieldNode, DirectiveNode, VariableDefinitionNode } from "../language/ast";
|
||||||
|
|
||||||
|
interface CoercedVariableValues {
|
||||||
|
errors: ReadonlyArray<GraphQLError> | undefined;
|
||||||
|
coerced: { [key: string]: any } | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares an object map of variableValues of the correct type based on the
|
||||||
|
* provided variable definitions and arbitrary input. If the input cannot be
|
||||||
|
* parsed to match the variable definitions, a GraphQLError will be thrown.
|
||||||
|
*
|
||||||
|
* Note: The returned value is a plain Object with a prototype, since it is
|
||||||
|
* exposed to user code. Care should be taken to not pull values from the
|
||||||
|
* Object prototype.
|
||||||
|
*/
|
||||||
|
export function getVariableValues(
|
||||||
|
schema: GraphQLSchema,
|
||||||
|
varDefNodes: VariableDefinitionNode[],
|
||||||
|
inputs: { [key: string]: any }
|
||||||
|
): CoercedVariableValues;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares an object map of argument values given a list of argument
|
||||||
|
* definitions and list of argument AST nodes.
|
||||||
|
*
|
||||||
|
* Note: The returned value is a plain Object with a prototype, since it is
|
||||||
|
* exposed to user code. Care should be taken to not pull values from the
|
||||||
|
* Object prototype.
|
||||||
|
*/
|
||||||
|
export function getArgumentValues(
|
||||||
|
def: GraphQLField<any, any> | GraphQLDirective,
|
||||||
|
node: FieldNode | DirectiveNode,
|
||||||
|
variableValues?: Maybe<{ [key: string]: any }>
|
||||||
|
): { [key: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares an object map of argument values given a directive definition
|
||||||
|
* and a AST node which may contain directives. Optionally also accepts a map
|
||||||
|
* of variable values.
|
||||||
|
*
|
||||||
|
* If the directive does not exist on the node, returns undefined.
|
||||||
|
*
|
||||||
|
* Note: The returned value is a plain Object with a prototype, since it is
|
||||||
|
* exposed to user code. Care should be taken to not pull values from the
|
||||||
|
* Object prototype.
|
||||||
|
*/
|
||||||
|
export function getDirectiveValues(
|
||||||
|
directiveDef: GraphQLDirective,
|
||||||
|
node: {
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
},
|
||||||
|
variableValues?: Maybe<{ [key: string]: any }>
|
||||||
|
): undefined | { [key: string]: any };
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
import Maybe from "./tsutils/Maybe";
|
||||||
|
import { Source } from "./language/source";
|
||||||
|
import { GraphQLFieldResolver } from "./type/definition";
|
||||||
|
import { GraphQLSchema } from "./type/schema";
|
||||||
|
import { ExecutionResult, ExecutionResultDataDefault } from "./execution/execute";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the primary entry point function for fulfilling GraphQL operations
|
||||||
|
* by parsing, validating, and executing a GraphQL document along side a
|
||||||
|
* GraphQL schema.
|
||||||
|
*
|
||||||
|
* More sophisticated GraphQL servers, such as those which persist queries,
|
||||||
|
* may wish to separate the validation and execution phases to a static time
|
||||||
|
* tooling step, and a server runtime step.
|
||||||
|
*
|
||||||
|
* Accepts either an object with named arguments, or individual arguments:
|
||||||
|
*
|
||||||
|
* schema:
|
||||||
|
* The GraphQL type system to use when validating and executing a query.
|
||||||
|
* source:
|
||||||
|
* A GraphQL language formatted string representing the requested operation.
|
||||||
|
* rootValue:
|
||||||
|
* The value provided as the first argument to resolver functions on the top
|
||||||
|
* level type (e.g. the query object type).
|
||||||
|
* contextValue:
|
||||||
|
* The context value is provided as an argument to resolver functions after
|
||||||
|
* field arguments. It is used to pass shared information useful at any point
|
||||||
|
* during executing this query, for example the currently logged in user and
|
||||||
|
* connections to databases or other services.
|
||||||
|
* variableValues:
|
||||||
|
* A mapping of variable name to runtime value to use for all variables
|
||||||
|
* defined in the requestString.
|
||||||
|
* operationName:
|
||||||
|
* The name of the operation to use if requestString contains multiple
|
||||||
|
* possible operations. Can be omitted if requestString contains only
|
||||||
|
* one operation.
|
||||||
|
* fieldResolver:
|
||||||
|
* A resolver function to use when one is not provided by the schema.
|
||||||
|
* If not provided, the default field resolver is used (which looks for a
|
||||||
|
* value or method on the source value with the field's name).
|
||||||
|
*/
|
||||||
|
export interface GraphQLArgs {
|
||||||
|
schema: GraphQLSchema;
|
||||||
|
source: Source | string;
|
||||||
|
rootValue?: any;
|
||||||
|
contextValue?: any;
|
||||||
|
variableValues?: Maybe<{ [key: string]: any }>;
|
||||||
|
operationName?: Maybe<string>;
|
||||||
|
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function graphql<TData = ExecutionResultDataDefault>(args: GraphQLArgs): Promise<ExecutionResult<TData>>;
|
||||||
|
export function graphql<TData = ExecutionResultDataDefault>(
|
||||||
|
schema: GraphQLSchema,
|
||||||
|
source: Source | string,
|
||||||
|
rootValue?: any,
|
||||||
|
contextValue?: any,
|
||||||
|
variableValues?: Maybe<{ [key: string]: any }>,
|
||||||
|
operationName?: Maybe<string>,
|
||||||
|
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
|
||||||
|
): Promise<ExecutionResult<TData>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The graphqlSync function also fulfills GraphQL operations by parsing,
|
||||||
|
* validating, and executing a GraphQL document along side a GraphQL schema.
|
||||||
|
* However, it guarantees to complete synchronously (or throw an error) assuming
|
||||||
|
* that all field resolvers are also synchronous.
|
||||||
|
*/
|
||||||
|
export function graphqlSync<TData = ExecutionResultDataDefault>(args: GraphQLArgs): ExecutionResult<TData>;
|
||||||
|
export function graphqlSync<TData = ExecutionResultDataDefault>(
|
||||||
|
schema: GraphQLSchema,
|
||||||
|
source: Source | string,
|
||||||
|
rootValue?: any,
|
||||||
|
contextValue?: any,
|
||||||
|
variableValues?: Maybe<{ [key: string]: any }>,
|
||||||
|
operationName?: Maybe<string>,
|
||||||
|
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
|
||||||
|
): ExecutionResult<TData>;
|
||||||
|
|
@ -0,0 +1,411 @@
|
||||||
|
// Type definitions for graphql 14.2
|
||||||
|
// Project: https://github.com/graphql/graphql-js
|
||||||
|
// Definitions by: TonyYang <https://github.com/TonyPythoneer>
|
||||||
|
// Caleb Meredith <https://github.com/calebmer>
|
||||||
|
// Dominic Watson <https://github.com/intellix>
|
||||||
|
// Firede <https://github.com/firede>
|
||||||
|
// Kepennar <https://github.com/kepennar>
|
||||||
|
// Mikhail Novikov <https://github.com/freiksenet>
|
||||||
|
// Ivan Goncharov <https://github.com/IvanGoncharov>
|
||||||
|
// Hagai Cohen <https://github.com/DxCx>
|
||||||
|
// Ricardo Portugal <https://github.com/rportugal>
|
||||||
|
// Tim Griesser <https://github.com/tgriesser>
|
||||||
|
// Dylan Stewart <https://github.com/dyst5422>
|
||||||
|
// Alessio Dionisi <https://github.com/adnsio>
|
||||||
|
// Divyendu Singh <https://github.com/divyenduz>
|
||||||
|
// Brad Zacher <https://github.com/bradzacher>
|
||||||
|
// Curtis Layne <https://github.com/clayne11>
|
||||||
|
// Jonathan Cardoso <https://github.com/JCMais>
|
||||||
|
// Pavel Lang <https://github.com/langpavel>
|
||||||
|
// Mark Caudill <https://github.com/mc0>
|
||||||
|
// Martijn Walraven <https://github.com/martijnwalraven>
|
||||||
|
// Jed Mao <https://github.com/jedmao>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
// TypeScript Version: 2.6
|
||||||
|
|
||||||
|
// The primary entry point into fulfilling a GraphQL request.
|
||||||
|
export { graphql, graphqlSync, GraphQLArgs } from "./graphql";
|
||||||
|
|
||||||
|
// Create and operate on GraphQL type definitions and schema.
|
||||||
|
export {
|
||||||
|
GraphQLSchema,
|
||||||
|
// Definitions
|
||||||
|
GraphQLScalarType,
|
||||||
|
GraphQLObjectType,
|
||||||
|
GraphQLInterfaceType,
|
||||||
|
GraphQLUnionType,
|
||||||
|
GraphQLEnumType,
|
||||||
|
GraphQLInputObjectType,
|
||||||
|
GraphQLList,
|
||||||
|
GraphQLNonNull,
|
||||||
|
GraphQLDirective,
|
||||||
|
// "Enum" of Type Kinds
|
||||||
|
TypeKind,
|
||||||
|
// Scalars
|
||||||
|
specifiedScalarTypes,
|
||||||
|
GraphQLInt,
|
||||||
|
GraphQLFloat,
|
||||||
|
GraphQLString,
|
||||||
|
GraphQLBoolean,
|
||||||
|
GraphQLID,
|
||||||
|
// Built-in Directives defined by the Spec
|
||||||
|
specifiedDirectives,
|
||||||
|
GraphQLIncludeDirective,
|
||||||
|
GraphQLSkipDirective,
|
||||||
|
GraphQLDeprecatedDirective,
|
||||||
|
// Constant Deprecation Reason
|
||||||
|
DEFAULT_DEPRECATION_REASON,
|
||||||
|
// Meta-field definitions.
|
||||||
|
SchemaMetaFieldDef,
|
||||||
|
TypeMetaFieldDef,
|
||||||
|
TypeNameMetaFieldDef,
|
||||||
|
// GraphQL Types for introspection.
|
||||||
|
introspectionTypes,
|
||||||
|
__Schema,
|
||||||
|
__Directive,
|
||||||
|
__DirectiveLocation,
|
||||||
|
__Type,
|
||||||
|
__Field,
|
||||||
|
__InputValue,
|
||||||
|
__EnumValue,
|
||||||
|
__TypeKind,
|
||||||
|
// Predicates
|
||||||
|
isSchema,
|
||||||
|
isDirective,
|
||||||
|
isType,
|
||||||
|
isScalarType,
|
||||||
|
isObjectType,
|
||||||
|
isInterfaceType,
|
||||||
|
isUnionType,
|
||||||
|
isEnumType,
|
||||||
|
isInputObjectType,
|
||||||
|
isListType,
|
||||||
|
isNonNullType,
|
||||||
|
isInputType,
|
||||||
|
isOutputType,
|
||||||
|
isLeafType,
|
||||||
|
isCompositeType,
|
||||||
|
isAbstractType,
|
||||||
|
isWrappingType,
|
||||||
|
isNullableType,
|
||||||
|
isNamedType,
|
||||||
|
isRequiredArgument,
|
||||||
|
isRequiredInputField,
|
||||||
|
isSpecifiedScalarType,
|
||||||
|
isIntrospectionType,
|
||||||
|
isSpecifiedDirective,
|
||||||
|
// Assertions
|
||||||
|
assertType,
|
||||||
|
assertScalarType,
|
||||||
|
assertObjectType,
|
||||||
|
assertInterfaceType,
|
||||||
|
assertUnionType,
|
||||||
|
assertEnumType,
|
||||||
|
assertInputObjectType,
|
||||||
|
assertListType,
|
||||||
|
assertNonNullType,
|
||||||
|
assertInputType,
|
||||||
|
assertOutputType,
|
||||||
|
assertLeafType,
|
||||||
|
assertCompositeType,
|
||||||
|
assertAbstractType,
|
||||||
|
assertWrappingType,
|
||||||
|
assertNullableType,
|
||||||
|
assertNamedType,
|
||||||
|
// Un-modifiers
|
||||||
|
getNullableType,
|
||||||
|
getNamedType,
|
||||||
|
// Validate GraphQL schema.
|
||||||
|
validateSchema,
|
||||||
|
assertValidSchema,
|
||||||
|
// type
|
||||||
|
GraphQLType,
|
||||||
|
GraphQLInputType,
|
||||||
|
GraphQLOutputType,
|
||||||
|
GraphQLLeafType,
|
||||||
|
GraphQLCompositeType,
|
||||||
|
GraphQLAbstractType,
|
||||||
|
GraphQLWrappingType,
|
||||||
|
GraphQLNullableType,
|
||||||
|
GraphQLNamedType,
|
||||||
|
Thunk,
|
||||||
|
GraphQLSchemaConfig,
|
||||||
|
GraphQLArgument,
|
||||||
|
GraphQLArgumentConfig,
|
||||||
|
GraphQLEnumTypeConfig,
|
||||||
|
GraphQLEnumValue,
|
||||||
|
GraphQLEnumValueConfig,
|
||||||
|
GraphQLEnumValueConfigMap,
|
||||||
|
GraphQLField,
|
||||||
|
GraphQLFieldConfig,
|
||||||
|
GraphQLFieldConfigArgumentMap,
|
||||||
|
GraphQLFieldConfigMap,
|
||||||
|
GraphQLFieldMap,
|
||||||
|
GraphQLFieldResolver,
|
||||||
|
GraphQLInputField,
|
||||||
|
GraphQLInputFieldConfig,
|
||||||
|
GraphQLInputFieldConfigMap,
|
||||||
|
GraphQLInputFieldMap,
|
||||||
|
GraphQLInputObjectTypeConfig,
|
||||||
|
GraphQLInterfaceTypeConfig,
|
||||||
|
GraphQLIsTypeOfFn,
|
||||||
|
GraphQLObjectTypeConfig,
|
||||||
|
GraphQLResolveInfo,
|
||||||
|
ResponsePath,
|
||||||
|
GraphQLScalarTypeConfig,
|
||||||
|
GraphQLTypeResolver,
|
||||||
|
GraphQLUnionTypeConfig,
|
||||||
|
GraphQLDirectiveConfig,
|
||||||
|
GraphQLScalarSerializer,
|
||||||
|
GraphQLScalarValueParser,
|
||||||
|
GraphQLScalarLiteralParser,
|
||||||
|
} from "./type";
|
||||||
|
|
||||||
|
// Parse and operate on GraphQL language source files.
|
||||||
|
export {
|
||||||
|
Source,
|
||||||
|
getLocation,
|
||||||
|
// Parse
|
||||||
|
parse,
|
||||||
|
parseValue,
|
||||||
|
parseType,
|
||||||
|
// Print
|
||||||
|
print,
|
||||||
|
// Visit
|
||||||
|
visit,
|
||||||
|
visitInParallel,
|
||||||
|
visitWithTypeInfo,
|
||||||
|
getVisitFn,
|
||||||
|
Kind,
|
||||||
|
TokenKind,
|
||||||
|
DirectiveLocation,
|
||||||
|
BREAK,
|
||||||
|
// Predicates
|
||||||
|
isDefinitionNode,
|
||||||
|
isExecutableDefinitionNode,
|
||||||
|
isSelectionNode,
|
||||||
|
isValueNode,
|
||||||
|
isTypeNode,
|
||||||
|
isTypeSystemDefinitionNode,
|
||||||
|
isTypeDefinitionNode,
|
||||||
|
isTypeSystemExtensionNode,
|
||||||
|
isTypeExtensionNode,
|
||||||
|
// type
|
||||||
|
Lexer,
|
||||||
|
ParseOptions,
|
||||||
|
SourceLocation,
|
||||||
|
// Visitor utilities
|
||||||
|
ASTVisitor,
|
||||||
|
Visitor,
|
||||||
|
VisitFn,
|
||||||
|
VisitorKeyMap,
|
||||||
|
// AST nodes
|
||||||
|
Location,
|
||||||
|
Token,
|
||||||
|
ASTNode,
|
||||||
|
ASTKindToNode,
|
||||||
|
NameNode,
|
||||||
|
DocumentNode,
|
||||||
|
DefinitionNode,
|
||||||
|
ExecutableDefinitionNode,
|
||||||
|
OperationDefinitionNode,
|
||||||
|
OperationTypeNode,
|
||||||
|
VariableDefinitionNode,
|
||||||
|
VariableNode,
|
||||||
|
SelectionSetNode,
|
||||||
|
SelectionNode,
|
||||||
|
FieldNode,
|
||||||
|
ArgumentNode,
|
||||||
|
FragmentSpreadNode,
|
||||||
|
InlineFragmentNode,
|
||||||
|
FragmentDefinitionNode,
|
||||||
|
ValueNode,
|
||||||
|
IntValueNode,
|
||||||
|
FloatValueNode,
|
||||||
|
StringValueNode,
|
||||||
|
BooleanValueNode,
|
||||||
|
NullValueNode,
|
||||||
|
EnumValueNode,
|
||||||
|
ListValueNode,
|
||||||
|
ObjectValueNode,
|
||||||
|
ObjectFieldNode,
|
||||||
|
DirectiveNode,
|
||||||
|
TypeNode,
|
||||||
|
NamedTypeNode,
|
||||||
|
ListTypeNode,
|
||||||
|
NonNullTypeNode,
|
||||||
|
TypeSystemDefinitionNode,
|
||||||
|
SchemaDefinitionNode,
|
||||||
|
OperationTypeDefinitionNode,
|
||||||
|
TypeDefinitionNode,
|
||||||
|
ScalarTypeDefinitionNode,
|
||||||
|
ObjectTypeDefinitionNode,
|
||||||
|
FieldDefinitionNode,
|
||||||
|
InputValueDefinitionNode,
|
||||||
|
InterfaceTypeDefinitionNode,
|
||||||
|
UnionTypeDefinitionNode,
|
||||||
|
EnumTypeDefinitionNode,
|
||||||
|
EnumValueDefinitionNode,
|
||||||
|
InputObjectTypeDefinitionNode,
|
||||||
|
DirectiveDefinitionNode,
|
||||||
|
TypeSystemExtensionNode,
|
||||||
|
SchemaExtensionNode,
|
||||||
|
TypeExtensionNode,
|
||||||
|
ScalarTypeExtensionNode,
|
||||||
|
ObjectTypeExtensionNode,
|
||||||
|
InterfaceTypeExtensionNode,
|
||||||
|
UnionTypeExtensionNode,
|
||||||
|
EnumTypeExtensionNode,
|
||||||
|
InputObjectTypeExtensionNode,
|
||||||
|
KindEnum,
|
||||||
|
TokenKindEnum,
|
||||||
|
DirectiveLocationEnum,
|
||||||
|
} from "./language";
|
||||||
|
|
||||||
|
// Execute GraphQL queries.
|
||||||
|
export {
|
||||||
|
execute,
|
||||||
|
defaultFieldResolver,
|
||||||
|
responsePathAsArray,
|
||||||
|
getDirectiveValues,
|
||||||
|
// type
|
||||||
|
ExecutionArgs,
|
||||||
|
ExecutionResult,
|
||||||
|
} from "./execution";
|
||||||
|
|
||||||
|
export { subscribe, createSourceEventStream } from "./subscription";
|
||||||
|
|
||||||
|
// Validate GraphQL queries.
|
||||||
|
export {
|
||||||
|
validate,
|
||||||
|
ValidationContext,
|
||||||
|
// All validation rules in the GraphQL Specification.
|
||||||
|
specifiedRules,
|
||||||
|
// Individual validation rules.
|
||||||
|
FieldsOnCorrectTypeRule,
|
||||||
|
FragmentsOnCompositeTypesRule,
|
||||||
|
KnownArgumentNamesRule,
|
||||||
|
KnownDirectivesRule,
|
||||||
|
KnownFragmentNamesRule,
|
||||||
|
KnownTypeNamesRule,
|
||||||
|
LoneAnonymousOperationRule,
|
||||||
|
NoFragmentCyclesRule,
|
||||||
|
NoUndefinedVariablesRule,
|
||||||
|
NoUnusedFragmentsRule,
|
||||||
|
NoUnusedVariablesRule,
|
||||||
|
OverlappingFieldsCanBeMergedRule,
|
||||||
|
PossibleFragmentSpreadsRule,
|
||||||
|
ProvidedRequiredArgumentsRule,
|
||||||
|
ScalarLeafsRule,
|
||||||
|
SingleFieldSubscriptionsRule,
|
||||||
|
UniqueArgumentNamesRule,
|
||||||
|
UniqueDirectivesPerLocationRule,
|
||||||
|
UniqueFragmentNamesRule,
|
||||||
|
UniqueInputFieldNamesRule,
|
||||||
|
UniqueOperationNamesRule,
|
||||||
|
UniqueVariableNamesRule,
|
||||||
|
ValuesOfCorrectTypeRule,
|
||||||
|
VariablesAreInputTypesRule,
|
||||||
|
VariablesInAllowedPositionRule,
|
||||||
|
} from "./validation";
|
||||||
|
|
||||||
|
// Create and format GraphQL errors.
|
||||||
|
export { GraphQLError, formatError, printError, GraphQLFormattedError } from "./error";
|
||||||
|
|
||||||
|
// Utilities for operating on GraphQL type schema and parsed sources.
|
||||||
|
export {
|
||||||
|
// Produce the GraphQL query recommended for a full schema introspection.
|
||||||
|
// Accepts optional IntrospectionOptions.
|
||||||
|
getIntrospectionQuery,
|
||||||
|
// @deprecated: use getIntrospectionQuery - will be removed in v15
|
||||||
|
introspectionQuery,
|
||||||
|
// Gets the target Operation from a Document
|
||||||
|
getOperationAST,
|
||||||
|
// Gets the Type for the target Operation AST.
|
||||||
|
getOperationRootType,
|
||||||
|
// Convert a GraphQLSchema to an IntrospectionQuery
|
||||||
|
introspectionFromSchema,
|
||||||
|
// Build a GraphQLSchema from an introspection result.
|
||||||
|
buildClientSchema,
|
||||||
|
// Build a GraphQLSchema from a parsed GraphQL Schema language AST.
|
||||||
|
buildASTSchema,
|
||||||
|
// Build a GraphQLSchema from a GraphQL schema language document.
|
||||||
|
buildSchema,
|
||||||
|
// @deprecated: Get the description from a schema AST node and supports legacy
|
||||||
|
// syntax for specifying descriptions - will be removed in v16
|
||||||
|
getDescription,
|
||||||
|
// Extends an existing GraphQLSchema from a parsed GraphQL Schema
|
||||||
|
// language AST.
|
||||||
|
extendSchema,
|
||||||
|
// Sort a GraphQLSchema.
|
||||||
|
lexicographicSortSchema,
|
||||||
|
// Print a GraphQLSchema to GraphQL Schema language.
|
||||||
|
printSchema,
|
||||||
|
// Prints the built-in introspection schema in the Schema Language
|
||||||
|
// format.
|
||||||
|
printIntrospectionSchema,
|
||||||
|
// Print a GraphQLType to GraphQL Schema language.
|
||||||
|
printType,
|
||||||
|
// Create a GraphQLType from a GraphQL language AST.
|
||||||
|
typeFromAST,
|
||||||
|
// Create a JavaScript value from a GraphQL language AST with a Type.
|
||||||
|
valueFromAST,
|
||||||
|
// Create a JavaScript value from a GraphQL language AST without a Type.
|
||||||
|
valueFromASTUntyped,
|
||||||
|
// Create a GraphQL language AST from a JavaScript value.
|
||||||
|
astFromValue,
|
||||||
|
// A helper to use within recursive-descent visitors which need to be aware of
|
||||||
|
// the GraphQL type system.
|
||||||
|
TypeInfo,
|
||||||
|
// Coerces a JavaScript value to a GraphQL type, or produces errors.
|
||||||
|
coerceValue,
|
||||||
|
// @deprecated use coerceValue - will be removed in v15
|
||||||
|
isValidJSValue,
|
||||||
|
// @deprecated use validation - will be removed in v15
|
||||||
|
isValidLiteralValue,
|
||||||
|
// Concatenates multiple AST together.
|
||||||
|
concatAST,
|
||||||
|
// Separates an AST into an AST per Operation.
|
||||||
|
separateOperations,
|
||||||
|
// Comparators for types
|
||||||
|
isEqualType,
|
||||||
|
isTypeSubTypeOf,
|
||||||
|
doTypesOverlap,
|
||||||
|
// Asserts a string is a valid GraphQL name.
|
||||||
|
assertValidName,
|
||||||
|
// Determine if a string is a valid GraphQL name.
|
||||||
|
isValidNameError,
|
||||||
|
// Compares two GraphQLSchemas and detects breaking changes.
|
||||||
|
findBreakingChanges,
|
||||||
|
findDangerousChanges,
|
||||||
|
BreakingChangeType,
|
||||||
|
DangerousChangeType,
|
||||||
|
// Report all deprecated usage within a GraphQL document.
|
||||||
|
findDeprecatedUsages,
|
||||||
|
// type
|
||||||
|
BuildSchemaOptions,
|
||||||
|
BreakingChange,
|
||||||
|
DangerousChange,
|
||||||
|
IntrospectionOptions,
|
||||||
|
IntrospectionDirective,
|
||||||
|
IntrospectionEnumType,
|
||||||
|
IntrospectionEnumValue,
|
||||||
|
IntrospectionField,
|
||||||
|
IntrospectionInputObjectType,
|
||||||
|
IntrospectionInputType,
|
||||||
|
IntrospectionInputTypeRef,
|
||||||
|
IntrospectionInputValue,
|
||||||
|
IntrospectionInterfaceType,
|
||||||
|
IntrospectionListTypeRef,
|
||||||
|
IntrospectionNamedTypeRef,
|
||||||
|
IntrospectionNonNullTypeRef,
|
||||||
|
IntrospectionObjectType,
|
||||||
|
IntrospectionOutputType,
|
||||||
|
IntrospectionOutputTypeRef,
|
||||||
|
IntrospectionQuery,
|
||||||
|
IntrospectionScalarType,
|
||||||
|
IntrospectionSchema,
|
||||||
|
IntrospectionType,
|
||||||
|
IntrospectionTypeRef,
|
||||||
|
IntrospectionUnionType,
|
||||||
|
} from "./utilities";
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export type PromiseOrValue<T> = Promise<T> | T;
|
||||||
|
|
@ -0,0 +1,565 @@
|
||||||
|
import { Source } from "./source";
|
||||||
|
import { TokenKindEnum } from "./lexer";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains a range of UTF-8 character offsets and token references that
|
||||||
|
* identify the region of the source from which the AST derived.
|
||||||
|
*/
|
||||||
|
export interface Location {
|
||||||
|
/**
|
||||||
|
* The character offset at which this Node begins.
|
||||||
|
*/
|
||||||
|
readonly start: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The character offset at which this Node ends.
|
||||||
|
*/
|
||||||
|
readonly end: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Token at which this Node begins.
|
||||||
|
*/
|
||||||
|
readonly startToken: Token;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Token at which this Node ends.
|
||||||
|
*/
|
||||||
|
readonly endToken: Token;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Source document the AST represents.
|
||||||
|
*/
|
||||||
|
readonly source: Source;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a range of characters represented by a lexical token
|
||||||
|
* within a Source.
|
||||||
|
*/
|
||||||
|
export interface Token {
|
||||||
|
/**
|
||||||
|
* The kind of Token.
|
||||||
|
*/
|
||||||
|
readonly kind: TokenKindEnum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The character offset at which this Node begins.
|
||||||
|
*/
|
||||||
|
readonly start: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The character offset at which this Node ends.
|
||||||
|
*/
|
||||||
|
readonly end: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 1-indexed line number on which this Token appears.
|
||||||
|
*/
|
||||||
|
readonly line: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 1-indexed column number at which this Token begins.
|
||||||
|
*/
|
||||||
|
readonly column: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For non-punctuation tokens, represents the interpreted value of the token.
|
||||||
|
*/
|
||||||
|
readonly value: string | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tokens exist as nodes in a double-linked-list amongst all tokens
|
||||||
|
* including ignored tokens. <SOF> is always the first node and <EOF>
|
||||||
|
* the last.
|
||||||
|
*/
|
||||||
|
readonly prev: Token | null;
|
||||||
|
readonly next: Token | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of all possible AST node types.
|
||||||
|
*/
|
||||||
|
export type ASTNode =
|
||||||
|
| NameNode
|
||||||
|
| DocumentNode
|
||||||
|
| OperationDefinitionNode
|
||||||
|
| VariableDefinitionNode
|
||||||
|
| VariableNode
|
||||||
|
| SelectionSetNode
|
||||||
|
| FieldNode
|
||||||
|
| ArgumentNode
|
||||||
|
| FragmentSpreadNode
|
||||||
|
| InlineFragmentNode
|
||||||
|
| FragmentDefinitionNode
|
||||||
|
| IntValueNode
|
||||||
|
| FloatValueNode
|
||||||
|
| StringValueNode
|
||||||
|
| BooleanValueNode
|
||||||
|
| NullValueNode
|
||||||
|
| EnumValueNode
|
||||||
|
| ListValueNode
|
||||||
|
| ObjectValueNode
|
||||||
|
| ObjectFieldNode
|
||||||
|
| DirectiveNode
|
||||||
|
| NamedTypeNode
|
||||||
|
| ListTypeNode
|
||||||
|
| NonNullTypeNode
|
||||||
|
| SchemaDefinitionNode
|
||||||
|
| OperationTypeDefinitionNode
|
||||||
|
| ScalarTypeDefinitionNode
|
||||||
|
| ObjectTypeDefinitionNode
|
||||||
|
| FieldDefinitionNode
|
||||||
|
| InputValueDefinitionNode
|
||||||
|
| InterfaceTypeDefinitionNode
|
||||||
|
| UnionTypeDefinitionNode
|
||||||
|
| EnumTypeDefinitionNode
|
||||||
|
| EnumValueDefinitionNode
|
||||||
|
| InputObjectTypeDefinitionNode
|
||||||
|
| DirectiveDefinitionNode
|
||||||
|
| SchemaExtensionNode
|
||||||
|
| ScalarTypeExtensionNode
|
||||||
|
| ObjectTypeExtensionNode
|
||||||
|
| InterfaceTypeExtensionNode
|
||||||
|
| UnionTypeExtensionNode
|
||||||
|
| EnumTypeExtensionNode
|
||||||
|
| InputObjectTypeExtensionNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility type listing all nodes indexed by their kind.
|
||||||
|
*/
|
||||||
|
export interface ASTKindToNode {
|
||||||
|
Name: NameNode;
|
||||||
|
Document: DocumentNode;
|
||||||
|
OperationDefinition: OperationDefinitionNode;
|
||||||
|
VariableDefinition: VariableDefinitionNode;
|
||||||
|
Variable: VariableNode;
|
||||||
|
SelectionSet: SelectionSetNode;
|
||||||
|
Field: FieldNode;
|
||||||
|
Argument: ArgumentNode;
|
||||||
|
FragmentSpread: FragmentSpreadNode;
|
||||||
|
InlineFragment: InlineFragmentNode;
|
||||||
|
FragmentDefinition: FragmentDefinitionNode;
|
||||||
|
IntValue: IntValueNode;
|
||||||
|
FloatValue: FloatValueNode;
|
||||||
|
StringValue: StringValueNode;
|
||||||
|
BooleanValue: BooleanValueNode;
|
||||||
|
NullValue: NullValueNode;
|
||||||
|
EnumValue: EnumValueNode;
|
||||||
|
ListValue: ListValueNode;
|
||||||
|
ObjectValue: ObjectValueNode;
|
||||||
|
ObjectField: ObjectFieldNode;
|
||||||
|
Directive: DirectiveNode;
|
||||||
|
NamedType: NamedTypeNode;
|
||||||
|
ListType: ListTypeNode;
|
||||||
|
NonNullType: NonNullTypeNode;
|
||||||
|
SchemaDefinition: SchemaDefinitionNode;
|
||||||
|
OperationTypeDefinition: OperationTypeDefinitionNode;
|
||||||
|
ScalarTypeDefinition: ScalarTypeDefinitionNode;
|
||||||
|
ObjectTypeDefinition: ObjectTypeDefinitionNode;
|
||||||
|
FieldDefinition: FieldDefinitionNode;
|
||||||
|
InputValueDefinition: InputValueDefinitionNode;
|
||||||
|
InterfaceTypeDefinition: InterfaceTypeDefinitionNode;
|
||||||
|
UnionTypeDefinition: UnionTypeDefinitionNode;
|
||||||
|
EnumTypeDefinition: EnumTypeDefinitionNode;
|
||||||
|
EnumValueDefinition: EnumValueDefinitionNode;
|
||||||
|
InputObjectTypeDefinition: InputObjectTypeDefinitionNode;
|
||||||
|
DirectiveDefinition: DirectiveDefinitionNode;
|
||||||
|
SchemaExtension: SchemaExtensionNode;
|
||||||
|
ScalarTypeExtension: ScalarTypeExtensionNode;
|
||||||
|
ObjectTypeExtension: ObjectTypeExtensionNode;
|
||||||
|
InterfaceTypeExtension: InterfaceTypeExtensionNode;
|
||||||
|
UnionTypeExtension: UnionTypeExtensionNode;
|
||||||
|
EnumTypeExtension: EnumTypeExtensionNode;
|
||||||
|
InputObjectTypeExtension: InputObjectTypeExtensionNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name
|
||||||
|
|
||||||
|
export interface NameNode {
|
||||||
|
readonly kind: "Name";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly value: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Document
|
||||||
|
|
||||||
|
export interface DocumentNode {
|
||||||
|
readonly kind: "Document";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly definitions: ReadonlyArray<DefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type DefinitionNode = ExecutableDefinitionNode | TypeSystemDefinitionNode | TypeSystemExtensionNode;
|
||||||
|
|
||||||
|
export type ExecutableDefinitionNode = OperationDefinitionNode | FragmentDefinitionNode;
|
||||||
|
|
||||||
|
export interface OperationDefinitionNode {
|
||||||
|
readonly kind: "OperationDefinition";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly operation: OperationTypeNode;
|
||||||
|
readonly name?: NameNode;
|
||||||
|
readonly variableDefinitions?: ReadonlyArray<VariableDefinitionNode>;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly selectionSet: SelectionSetNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type OperationTypeNode = "query" | "mutation" | "subscription";
|
||||||
|
|
||||||
|
export interface VariableDefinitionNode {
|
||||||
|
readonly kind: "VariableDefinition";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly variable: VariableNode;
|
||||||
|
readonly type: TypeNode;
|
||||||
|
readonly defaultValue?: ValueNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface VariableNode {
|
||||||
|
readonly kind: "Variable";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly name: NameNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SelectionSetNode {
|
||||||
|
kind: "SelectionSet";
|
||||||
|
loc?: Location;
|
||||||
|
selections: ReadonlyArray<SelectionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SelectionNode = FieldNode | FragmentSpreadNode | InlineFragmentNode;
|
||||||
|
|
||||||
|
export interface FieldNode {
|
||||||
|
readonly kind: "Field";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly alias?: NameNode;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly arguments?: ReadonlyArray<ArgumentNode>;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly selectionSet?: SelectionSetNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ArgumentNode {
|
||||||
|
readonly kind: "Argument";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly value: ValueNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fragments
|
||||||
|
|
||||||
|
export interface FragmentSpreadNode {
|
||||||
|
readonly kind: "FragmentSpread";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InlineFragmentNode {
|
||||||
|
readonly kind: "InlineFragment";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly typeCondition?: NamedTypeNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly selectionSet: SelectionSetNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FragmentDefinitionNode {
|
||||||
|
readonly kind: "FragmentDefinition";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly name: NameNode;
|
||||||
|
// Note: fragment variable definitions are experimental and may be changed
|
||||||
|
// or removed in the future.
|
||||||
|
readonly variableDefinitions?: ReadonlyArray<VariableDefinitionNode>;
|
||||||
|
readonly typeCondition: NamedTypeNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly selectionSet: SelectionSetNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Values
|
||||||
|
|
||||||
|
export type ValueNode =
|
||||||
|
| VariableNode
|
||||||
|
| IntValueNode
|
||||||
|
| FloatValueNode
|
||||||
|
| StringValueNode
|
||||||
|
| BooleanValueNode
|
||||||
|
| NullValueNode
|
||||||
|
| EnumValueNode
|
||||||
|
| ListValueNode
|
||||||
|
| ObjectValueNode;
|
||||||
|
|
||||||
|
export interface IntValueNode {
|
||||||
|
readonly kind: "IntValue";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly value: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FloatValueNode {
|
||||||
|
readonly kind: "FloatValue";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly value: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StringValueNode {
|
||||||
|
readonly kind: "StringValue";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly value: string;
|
||||||
|
readonly block?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BooleanValueNode {
|
||||||
|
readonly kind: "BooleanValue";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly value: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NullValueNode {
|
||||||
|
readonly kind: "NullValue";
|
||||||
|
readonly loc?: Location;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EnumValueNode {
|
||||||
|
readonly kind: "EnumValue";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly value: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ListValueNode {
|
||||||
|
readonly kind: "ListValue";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly values: ReadonlyArray<ValueNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ObjectValueNode {
|
||||||
|
readonly kind: "ObjectValue";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly fields: ReadonlyArray<ObjectFieldNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ObjectFieldNode {
|
||||||
|
readonly kind: "ObjectField";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly value: ValueNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Directives
|
||||||
|
|
||||||
|
export interface DirectiveNode {
|
||||||
|
readonly kind: "Directive";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly arguments?: ReadonlyArray<ArgumentNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type Reference
|
||||||
|
|
||||||
|
export type TypeNode = NamedTypeNode | ListTypeNode | NonNullTypeNode;
|
||||||
|
|
||||||
|
export interface NamedTypeNode {
|
||||||
|
readonly kind: "NamedType";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly name: NameNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ListTypeNode {
|
||||||
|
readonly kind: "ListType";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly type: TypeNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NonNullTypeNode {
|
||||||
|
readonly kind: "NonNullType";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly type: NamedTypeNode | ListTypeNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type System Definition
|
||||||
|
|
||||||
|
export type TypeSystemDefinitionNode = SchemaDefinitionNode | TypeDefinitionNode | DirectiveDefinitionNode;
|
||||||
|
|
||||||
|
export interface SchemaDefinitionNode {
|
||||||
|
readonly kind: "SchemaDefinition";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly operationTypes: ReadonlyArray<OperationTypeDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OperationTypeDefinitionNode {
|
||||||
|
readonly kind: "OperationTypeDefinition";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly operation: OperationTypeNode;
|
||||||
|
readonly type: NamedTypeNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type Definition
|
||||||
|
|
||||||
|
export type TypeDefinitionNode =
|
||||||
|
| ScalarTypeDefinitionNode
|
||||||
|
| ObjectTypeDefinitionNode
|
||||||
|
| InterfaceTypeDefinitionNode
|
||||||
|
| UnionTypeDefinitionNode
|
||||||
|
| EnumTypeDefinitionNode
|
||||||
|
| InputObjectTypeDefinitionNode;
|
||||||
|
|
||||||
|
export interface ScalarTypeDefinitionNode {
|
||||||
|
readonly kind: "ScalarTypeDefinition";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly description?: StringValueNode;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ObjectTypeDefinitionNode {
|
||||||
|
readonly kind: "ObjectTypeDefinition";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly description?: StringValueNode;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly interfaces?: ReadonlyArray<NamedTypeNode>;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly fields?: ReadonlyArray<FieldDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FieldDefinitionNode {
|
||||||
|
readonly kind: "FieldDefinition";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly description?: StringValueNode;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly arguments?: ReadonlyArray<InputValueDefinitionNode>;
|
||||||
|
readonly type: TypeNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InputValueDefinitionNode {
|
||||||
|
readonly kind: "InputValueDefinition";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly description?: StringValueNode;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly type: TypeNode;
|
||||||
|
readonly defaultValue?: ValueNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InterfaceTypeDefinitionNode {
|
||||||
|
readonly kind: "InterfaceTypeDefinition";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly description?: StringValueNode;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly fields?: ReadonlyArray<FieldDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UnionTypeDefinitionNode {
|
||||||
|
readonly kind: "UnionTypeDefinition";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly description?: StringValueNode;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly types?: ReadonlyArray<NamedTypeNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EnumTypeDefinitionNode {
|
||||||
|
readonly kind: "EnumTypeDefinition";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly description?: StringValueNode;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly values?: ReadonlyArray<EnumValueDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EnumValueDefinitionNode {
|
||||||
|
readonly kind: "EnumValueDefinition";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly description?: StringValueNode;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InputObjectTypeDefinitionNode {
|
||||||
|
readonly kind: "InputObjectTypeDefinition";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly description?: StringValueNode;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly fields?: ReadonlyArray<InputValueDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Directive Definitions
|
||||||
|
|
||||||
|
export interface DirectiveDefinitionNode {
|
||||||
|
readonly kind: "DirectiveDefinition";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly description?: StringValueNode;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly arguments?: ReadonlyArray<InputValueDefinitionNode>;
|
||||||
|
readonly repeatable: boolean;
|
||||||
|
readonly locations: ReadonlyArray<NameNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type System Extensions
|
||||||
|
|
||||||
|
export type TypeSystemExtensionNode = SchemaExtensionNode | TypeExtensionNode;
|
||||||
|
|
||||||
|
export type SchemaExtensionNode = {
|
||||||
|
readonly kind: "SchemaExtension";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly operationTypes?: ReadonlyArray<OperationTypeDefinitionNode>;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Type Extensions
|
||||||
|
|
||||||
|
export type TypeExtensionNode =
|
||||||
|
| ScalarTypeExtensionNode
|
||||||
|
| ObjectTypeExtensionNode
|
||||||
|
| InterfaceTypeExtensionNode
|
||||||
|
| UnionTypeExtensionNode
|
||||||
|
| EnumTypeExtensionNode
|
||||||
|
| InputObjectTypeExtensionNode;
|
||||||
|
|
||||||
|
export interface ScalarTypeExtensionNode {
|
||||||
|
readonly kind: "ScalarTypeExtension";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ObjectTypeExtensionNode {
|
||||||
|
readonly kind: "ObjectTypeExtension";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly interfaces?: ReadonlyArray<NamedTypeNode>;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly fields?: ReadonlyArray<FieldDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InterfaceTypeExtensionNode {
|
||||||
|
readonly kind: "InterfaceTypeExtension";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly fields?: ReadonlyArray<FieldDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UnionTypeExtensionNode {
|
||||||
|
readonly kind: "UnionTypeExtension";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly types?: ReadonlyArray<NamedTypeNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EnumTypeExtensionNode {
|
||||||
|
readonly kind: "EnumTypeExtension";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly values?: ReadonlyArray<EnumValueDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InputObjectTypeExtensionNode {
|
||||||
|
readonly kind: "InputObjectTypeExtension";
|
||||||
|
readonly loc?: Location;
|
||||||
|
readonly name: NameNode;
|
||||||
|
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||||
|
readonly fields?: ReadonlyArray<InputValueDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
/**
|
||||||
|
* Produces the value of a block string from its parsed raw value, similar to
|
||||||
|
* Coffeescript's block string, Python's docstring trim or Ruby's strip_heredoc.
|
||||||
|
*
|
||||||
|
* This implements the GraphQL spec's BlockStringValue() static algorithm.
|
||||||
|
*/
|
||||||
|
export function dedentBlockStringValue(rawString: string): string;
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
/**
|
||||||
|
* The set of allowed directive location values.
|
||||||
|
*/
|
||||||
|
export const DirectiveLocation: _DirectiveLocation;
|
||||||
|
|
||||||
|
// @internal
|
||||||
|
type _DirectiveLocation = {
|
||||||
|
// Request Definitions
|
||||||
|
QUERY: "QUERY";
|
||||||
|
MUTATION: "MUTATION";
|
||||||
|
SUBSCRIPTION: "SUBSCRIPTION";
|
||||||
|
FIELD: "FIELD";
|
||||||
|
FRAGMENT_DEFINITION: "FRAGMENT_DEFINITION";
|
||||||
|
FRAGMENT_SPREAD: "FRAGMENT_SPREAD";
|
||||||
|
INLINE_FRAGMENT: "INLINE_FRAGMENT";
|
||||||
|
VARIABLE_DEFINITION: "VARIABLE_DEFINITION";
|
||||||
|
|
||||||
|
// Type System Definitions
|
||||||
|
SCHEMA: "SCHEMA";
|
||||||
|
SCALAR: "SCALAR";
|
||||||
|
OBJECT: "OBJECT";
|
||||||
|
FIELD_DEFINITION: "FIELD_DEFINITION";
|
||||||
|
ARGUMENT_DEFINITION: "ARGUMENT_DEFINITION";
|
||||||
|
INTERFACE: "INTERFACE";
|
||||||
|
UNION: "UNION";
|
||||||
|
ENUM: "ENUM";
|
||||||
|
ENUM_VALUE: "ENUM_VALUE";
|
||||||
|
INPUT_OBJECT: "INPUT_OBJECT";
|
||||||
|
INPUT_FIELD_DEFINITION: "INPUT_FIELD_DEFINITION";
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The enum type representing the directive location values.
|
||||||
|
*/
|
||||||
|
export type DirectiveLocationEnum = _DirectiveLocation[keyof _DirectiveLocation];
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
export { getLocation, SourceLocation } from "./location";
|
||||||
|
export { Kind, KindEnum } from "./kinds";
|
||||||
|
export { createLexer, TokenKind, Lexer, TokenKindEnum } from "./lexer";
|
||||||
|
export { parse, parseValue, parseType, ParseOptions } from "./parser";
|
||||||
|
export { print } from "./printer";
|
||||||
|
export { Source } from "./source";
|
||||||
|
export {
|
||||||
|
visit,
|
||||||
|
visitInParallel,
|
||||||
|
visitWithTypeInfo,
|
||||||
|
getVisitFn,
|
||||||
|
BREAK,
|
||||||
|
// type
|
||||||
|
ASTVisitor,
|
||||||
|
Visitor,
|
||||||
|
VisitFn,
|
||||||
|
VisitorKeyMap,
|
||||||
|
} from "./visitor";
|
||||||
|
|
||||||
|
export {
|
||||||
|
Location,
|
||||||
|
Token,
|
||||||
|
ASTNode,
|
||||||
|
ASTKindToNode,
|
||||||
|
// Each kind of AST node
|
||||||
|
NameNode,
|
||||||
|
DocumentNode,
|
||||||
|
DefinitionNode,
|
||||||
|
ExecutableDefinitionNode,
|
||||||
|
OperationDefinitionNode,
|
||||||
|
OperationTypeNode,
|
||||||
|
VariableDefinitionNode,
|
||||||
|
VariableNode,
|
||||||
|
SelectionSetNode,
|
||||||
|
SelectionNode,
|
||||||
|
FieldNode,
|
||||||
|
ArgumentNode,
|
||||||
|
FragmentSpreadNode,
|
||||||
|
InlineFragmentNode,
|
||||||
|
FragmentDefinitionNode,
|
||||||
|
ValueNode,
|
||||||
|
IntValueNode,
|
||||||
|
FloatValueNode,
|
||||||
|
StringValueNode,
|
||||||
|
BooleanValueNode,
|
||||||
|
NullValueNode,
|
||||||
|
EnumValueNode,
|
||||||
|
ListValueNode,
|
||||||
|
ObjectValueNode,
|
||||||
|
ObjectFieldNode,
|
||||||
|
DirectiveNode,
|
||||||
|
TypeNode,
|
||||||
|
NamedTypeNode,
|
||||||
|
ListTypeNode,
|
||||||
|
NonNullTypeNode,
|
||||||
|
TypeSystemDefinitionNode,
|
||||||
|
SchemaDefinitionNode,
|
||||||
|
OperationTypeDefinitionNode,
|
||||||
|
TypeDefinitionNode,
|
||||||
|
ScalarTypeDefinitionNode,
|
||||||
|
ObjectTypeDefinitionNode,
|
||||||
|
FieldDefinitionNode,
|
||||||
|
InputValueDefinitionNode,
|
||||||
|
InterfaceTypeDefinitionNode,
|
||||||
|
UnionTypeDefinitionNode,
|
||||||
|
EnumTypeDefinitionNode,
|
||||||
|
EnumValueDefinitionNode,
|
||||||
|
InputObjectTypeDefinitionNode,
|
||||||
|
DirectiveDefinitionNode,
|
||||||
|
TypeSystemExtensionNode,
|
||||||
|
SchemaExtensionNode,
|
||||||
|
TypeExtensionNode,
|
||||||
|
ScalarTypeExtensionNode,
|
||||||
|
ObjectTypeExtensionNode,
|
||||||
|
InterfaceTypeExtensionNode,
|
||||||
|
UnionTypeExtensionNode,
|
||||||
|
EnumTypeExtensionNode,
|
||||||
|
InputObjectTypeExtensionNode,
|
||||||
|
} from "./ast";
|
||||||
|
|
||||||
|
export {
|
||||||
|
isDefinitionNode,
|
||||||
|
isExecutableDefinitionNode,
|
||||||
|
isSelectionNode,
|
||||||
|
isValueNode,
|
||||||
|
isTypeNode,
|
||||||
|
isTypeSystemDefinitionNode,
|
||||||
|
isTypeDefinitionNode,
|
||||||
|
isTypeSystemExtensionNode,
|
||||||
|
isTypeExtensionNode,
|
||||||
|
} from "./predicates";
|
||||||
|
|
||||||
|
export { DirectiveLocation, DirectiveLocationEnum } from "./directiveLocation";
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
/**
|
||||||
|
* The set of allowed kind values for AST nodes.
|
||||||
|
*/
|
||||||
|
export const Kind: _Kind;
|
||||||
|
|
||||||
|
// @internal
|
||||||
|
type _Kind = {
|
||||||
|
// Name
|
||||||
|
NAME: "Name";
|
||||||
|
|
||||||
|
// Document
|
||||||
|
DOCUMENT: "Document";
|
||||||
|
OPERATION_DEFINITION: "OperationDefinition";
|
||||||
|
VARIABLE_DEFINITION: "VariableDefinition";
|
||||||
|
SELECTION_SET: "SelectionSet";
|
||||||
|
FIELD: "Field";
|
||||||
|
ARGUMENT: "Argument";
|
||||||
|
|
||||||
|
// Fragments
|
||||||
|
FRAGMENT_SPREAD: "FragmentSpread";
|
||||||
|
INLINE_FRAGMENT: "InlineFragment";
|
||||||
|
FRAGMENT_DEFINITION: "FragmentDefinition";
|
||||||
|
|
||||||
|
// Values
|
||||||
|
VARIABLE: "Variable";
|
||||||
|
INT: "IntValue";
|
||||||
|
FLOAT: "FloatValue";
|
||||||
|
STRING: "StringValue";
|
||||||
|
BOOLEAN: "BooleanValue";
|
||||||
|
NULL: "NullValue";
|
||||||
|
ENUM: "EnumValue";
|
||||||
|
LIST: "ListValue";
|
||||||
|
OBJECT: "ObjectValue";
|
||||||
|
OBJECT_FIELD: "ObjectField";
|
||||||
|
|
||||||
|
// Directives
|
||||||
|
DIRECTIVE: "Directive";
|
||||||
|
|
||||||
|
// Types
|
||||||
|
NAMED_TYPE: "NamedType";
|
||||||
|
LIST_TYPE: "ListType";
|
||||||
|
NON_NULL_TYPE: "NonNullType";
|
||||||
|
|
||||||
|
// Type System Definitions
|
||||||
|
SCHEMA_DEFINITION: "SchemaDefinition";
|
||||||
|
OPERATION_TYPE_DEFINITION: "OperationTypeDefinition";
|
||||||
|
|
||||||
|
// Type Definitions
|
||||||
|
SCALAR_TYPE_DEFINITION: "ScalarTypeDefinition";
|
||||||
|
OBJECT_TYPE_DEFINITION: "ObjectTypeDefinition";
|
||||||
|
FIELD_DEFINITION: "FieldDefinition";
|
||||||
|
INPUT_VALUE_DEFINITION: "InputValueDefinition";
|
||||||
|
INTERFACE_TYPE_DEFINITION: "InterfaceTypeDefinition";
|
||||||
|
UNION_TYPE_DEFINITION: "UnionTypeDefinition";
|
||||||
|
ENUM_TYPE_DEFINITION: "EnumTypeDefinition";
|
||||||
|
ENUM_VALUE_DEFINITION: "EnumValueDefinition";
|
||||||
|
INPUT_OBJECT_TYPE_DEFINITION: "InputObjectTypeDefinition";
|
||||||
|
|
||||||
|
// Directive Definitions
|
||||||
|
DIRECTIVE_DEFINITION: "DirectiveDefinition";
|
||||||
|
|
||||||
|
// Type System Extensions
|
||||||
|
SCHEMA_EXTENSION: "SchemaExtension";
|
||||||
|
|
||||||
|
// Type Extensions
|
||||||
|
SCALAR_TYPE_EXTENSION: "ScalarTypeExtension";
|
||||||
|
OBJECT_TYPE_EXTENSION: "ObjectTypeExtension";
|
||||||
|
INTERFACE_TYPE_EXTENSION: "InterfaceTypeExtension";
|
||||||
|
UNION_TYPE_EXTENSION: "UnionTypeExtension";
|
||||||
|
ENUM_TYPE_EXTENSION: "EnumTypeExtension";
|
||||||
|
INPUT_OBJECT_TYPE_EXTENSION: "InputObjectTypeExtension";
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The enum type representing the possible kind values of AST nodes.
|
||||||
|
*/
|
||||||
|
export type KindEnum = _Kind[keyof _Kind];
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
import { Token } from "./ast";
|
||||||
|
import { Source } from "./source";
|
||||||
|
import { syntaxError } from "../error";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a Source object, this returns a Lexer for that source.
|
||||||
|
* A Lexer is a stateful stream generator in that every time
|
||||||
|
* it is advanced, it returns the next token in the Source. Assuming the
|
||||||
|
* source lexes, the final Token emitted by the lexer will be of kind
|
||||||
|
* EOF, after which the lexer will repeatedly return the same EOF token
|
||||||
|
* whenever called.
|
||||||
|
*/
|
||||||
|
export function createLexer<TOptions>(source: Source, options: TOptions): Lexer<TOptions>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The return type of createLexer.
|
||||||
|
*/
|
||||||
|
export interface Lexer<TOptions> {
|
||||||
|
source: Source;
|
||||||
|
options: TOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The previously focused non-ignored token.
|
||||||
|
*/
|
||||||
|
lastToken: Token;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The currently focused non-ignored token.
|
||||||
|
*/
|
||||||
|
token: Token;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The (1-indexed) line containing the current token.
|
||||||
|
*/
|
||||||
|
line: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The character offset at which the current line begins.
|
||||||
|
*/
|
||||||
|
lineStart: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Advances the token stream to the next non-ignored token.
|
||||||
|
*/
|
||||||
|
advance(): Token;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Looks ahead and returns the next non-ignored token, but does not change
|
||||||
|
* the Lexer's state.
|
||||||
|
*/
|
||||||
|
lookahead(): Token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An exported enum describing the different kinds of tokens that the
|
||||||
|
* lexer emits.
|
||||||
|
*/
|
||||||
|
export const TokenKind: _TokenKind;
|
||||||
|
|
||||||
|
// @internal
|
||||||
|
type _TokenKind = {
|
||||||
|
SOF: "<SOF>";
|
||||||
|
EOF: "<EOF>";
|
||||||
|
BANG: "!";
|
||||||
|
DOLLAR: "$";
|
||||||
|
AMP: "&";
|
||||||
|
PAREN_L: "(";
|
||||||
|
PAREN_R: ")";
|
||||||
|
SPREAD: "...";
|
||||||
|
COLON: ":";
|
||||||
|
EQUALS: "=";
|
||||||
|
AT: "@";
|
||||||
|
BRACKET_L: "[";
|
||||||
|
BRACKET_R: "]";
|
||||||
|
BRACE_L: "{";
|
||||||
|
PIPE: "|";
|
||||||
|
BRACE_R: "}";
|
||||||
|
NAME: "Name";
|
||||||
|
INT: "Int";
|
||||||
|
FLOAT: "Float";
|
||||||
|
STRING: "String";
|
||||||
|
BLOCK_STRING: "BlockString";
|
||||||
|
COMMENT: "Comment";
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The enum type representing the token kinds values.
|
||||||
|
*/
|
||||||
|
export type TokenKindEnum = _TokenKind[keyof _TokenKind];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A helper function to describe a token as a string for debugging
|
||||||
|
*/
|
||||||
|
export function getTokenDesc(token: Token): string;
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { Source } from "./source";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a location in a Source.
|
||||||
|
*/
|
||||||
|
export interface SourceLocation {
|
||||||
|
readonly line: number;
|
||||||
|
readonly column: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes a Source and a UTF-8 character offset, and returns the corresponding
|
||||||
|
* line and column as a SourceLocation.
|
||||||
|
*/
|
||||||
|
export function getLocation(source: Source, position: number): SourceLocation;
|
||||||
|
|
@ -0,0 +1,106 @@
|
||||||
|
import { NamedTypeNode, TypeNode, ValueNode, DocumentNode } from "./ast";
|
||||||
|
import { Source } from "./source";
|
||||||
|
import { Lexer } from "./lexer";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration options to control parser behavior
|
||||||
|
*/
|
||||||
|
export interface ParseOptions {
|
||||||
|
/**
|
||||||
|
* By default, the parser creates AST nodes that know the location
|
||||||
|
* in the source that they correspond to. This configuration flag
|
||||||
|
* disables that behavior for performance or testing.
|
||||||
|
*/
|
||||||
|
noLocation?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled, the parser will parse empty fields sets in the Schema
|
||||||
|
* Definition Language. Otherwise, the parser will follow the current
|
||||||
|
* specification.
|
||||||
|
*
|
||||||
|
* This option is provided to ease adoption of the final SDL specification
|
||||||
|
* and will be removed in v16.
|
||||||
|
*/
|
||||||
|
allowLegacySDLEmptyFields?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled, the parser will parse implemented interfaces with no `&`
|
||||||
|
* character between each interface. Otherwise, the parser will follow the
|
||||||
|
* current specification.
|
||||||
|
*
|
||||||
|
* This option is provided to ease adoption of the final SDL specification
|
||||||
|
* and will be removed in v16.
|
||||||
|
*/
|
||||||
|
allowLegacySDLImplementsInterfaces?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EXPERIMENTAL:
|
||||||
|
*
|
||||||
|
* If enabled, the parser will understand and parse variable definitions
|
||||||
|
* contained in a fragment definition. They'll be represented in the
|
||||||
|
* `variableDefinitions` field of the FragmentDefinitionNode.
|
||||||
|
*
|
||||||
|
* The syntax is identical to normal, query-defined variables. For example:
|
||||||
|
*
|
||||||
|
* fragment A($var: Boolean = false) on T {
|
||||||
|
* ...
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* Note: this feature is experimental and may change or be removed in the
|
||||||
|
* future.
|
||||||
|
*/
|
||||||
|
experimentalFragmentVariables?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EXPERIMENTAL:
|
||||||
|
*
|
||||||
|
* If enabled, the parser understands directives on variable definitions:
|
||||||
|
*
|
||||||
|
* query Foo($var: String = "abc" @variable_definition_directive) {
|
||||||
|
* ...
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
experimentalVariableDefinitionDirectives?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a GraphQL source, parses it into a Document.
|
||||||
|
* Throws GraphQLError if a syntax error is encountered.
|
||||||
|
*/
|
||||||
|
export function parse(source: string | Source, options?: ParseOptions): DocumentNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a string containing a GraphQL value, parse the AST for that value.
|
||||||
|
* Throws GraphQLError if a syntax error is encountered.
|
||||||
|
*
|
||||||
|
* This is useful within tools that operate upon GraphQL Values directly and
|
||||||
|
* in isolation of complete GraphQL documents.
|
||||||
|
*/
|
||||||
|
export function parseValue(source: string | Source, options?: ParseOptions): ValueNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for
|
||||||
|
* that type.
|
||||||
|
* Throws GraphQLError if a syntax error is encountered.
|
||||||
|
*
|
||||||
|
* This is useful within tools that operate upon GraphQL Types directly and
|
||||||
|
* in isolation of complete GraphQL documents.
|
||||||
|
*
|
||||||
|
* Consider providing the results to the utility function: typeFromAST().
|
||||||
|
*/
|
||||||
|
export function parseType(source: string | Source, options?: ParseOptions): TypeNode;
|
||||||
|
|
||||||
|
export function parseConstValue<TOptions>(lexer: Lexer<TOptions>): ValueNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type :
|
||||||
|
* - NamedType
|
||||||
|
* - ListType
|
||||||
|
* - NonNullType
|
||||||
|
*/
|
||||||
|
export function parseTypeReference<TOptions>(lexer: Lexer<TOptions>): TypeNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NamedType : Name
|
||||||
|
*/
|
||||||
|
export function parseNamedType<TOptions>(lexer: Lexer<TOptions>): NamedTypeNode;
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
import {
|
||||||
|
ASTNode,
|
||||||
|
DefinitionNode,
|
||||||
|
ExecutableDefinitionNode,
|
||||||
|
SelectionNode,
|
||||||
|
ValueNode,
|
||||||
|
TypeNode,
|
||||||
|
TypeSystemDefinitionNode,
|
||||||
|
TypeDefinitionNode,
|
||||||
|
TypeSystemExtensionNode,
|
||||||
|
TypeExtensionNode,
|
||||||
|
} from "./ast";
|
||||||
|
|
||||||
|
export function isDefinitionNode(node: ASTNode): node is DefinitionNode;
|
||||||
|
|
||||||
|
export function isExecutableDefinitionNode(node: ASTNode): node is ExecutableDefinitionNode;
|
||||||
|
|
||||||
|
export function isSelectionNode(node: ASTNode): node is SelectionNode;
|
||||||
|
|
||||||
|
export function isValueNode(node: ASTNode): node is ValueNode;
|
||||||
|
|
||||||
|
export function isTypeNode(node: ASTNode): node is TypeNode;
|
||||||
|
|
||||||
|
export function isTypeSystemDefinitionNode(node: ASTNode): node is TypeSystemDefinitionNode;
|
||||||
|
|
||||||
|
export function isTypeDefinitionNode(node: ASTNode): node is TypeDefinitionNode;
|
||||||
|
|
||||||
|
export function isTypeSystemExtensionNode(node: ASTNode): node is TypeSystemExtensionNode;
|
||||||
|
|
||||||
|
export function isTypeExtensionNode(node: ASTNode): node is TypeExtensionNode;
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { ASTNode } from "./ast";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts an AST into a string, using one set of reasonable
|
||||||
|
* formatting rules.
|
||||||
|
*/
|
||||||
|
export function print(ast: ASTNode): string;
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
interface Location {
|
||||||
|
line: number;
|
||||||
|
column: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A representation of source input to GraphQL.
|
||||||
|
* `name` and `locationOffset` are optional. They are useful for clients who
|
||||||
|
* store GraphQL documents in source files; for example, if the GraphQL input
|
||||||
|
* starts at line 40 in a file named Foo.graphql, it might be useful for name to
|
||||||
|
* be "Foo.graphql" and location to be `{ line: 40, column: 0 }`.
|
||||||
|
* line and column in locationOffset are 1-indexed
|
||||||
|
*/
|
||||||
|
export class Source {
|
||||||
|
body: string;
|
||||||
|
name: string;
|
||||||
|
locationOffset: Location;
|
||||||
|
constructor(body: string, name?: string, locationOffset?: Location);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,161 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import { ASTNode, ASTKindToNode } from "./ast";
|
||||||
|
import { TypeInfo } from "../utilities/TypeInfo";
|
||||||
|
|
||||||
|
interface EnterLeave<T> {
|
||||||
|
readonly enter?: T;
|
||||||
|
readonly leave?: T;
|
||||||
|
}
|
||||||
|
|
||||||
|
type EnterLeaveVisitor<KindToNode, Nodes> = EnterLeave<
|
||||||
|
VisitFn<Nodes> | { [K in keyof KindToNode]?: VisitFn<Nodes, KindToNode[K]> }
|
||||||
|
>;
|
||||||
|
|
||||||
|
type ShapeMapVisitor<KindToNode, Nodes> = {
|
||||||
|
[K in keyof KindToNode]?: VisitFn<Nodes, KindToNode[K]> | EnterLeave<VisitFn<Nodes, KindToNode[K]>>
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ASTVisitor = Visitor<ASTKindToNode>;
|
||||||
|
export type Visitor<KindToNode, Nodes = KindToNode[keyof KindToNode]> =
|
||||||
|
| EnterLeaveVisitor<KindToNode, Nodes>
|
||||||
|
| ShapeMapVisitor<KindToNode, Nodes>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A visitor is comprised of visit functions, which are called on each node
|
||||||
|
* during the visitor's traversal.
|
||||||
|
*/
|
||||||
|
export type VisitFn<TAnyNode, TVisitedNode = TAnyNode> = (
|
||||||
|
// The current node being visiting.
|
||||||
|
node: TVisitedNode,
|
||||||
|
// The index or key to this node from the parent node or Array.
|
||||||
|
key: string | number | undefined,
|
||||||
|
// The parent immediately above this node, which may be an Array.
|
||||||
|
parent: TAnyNode | ReadonlyArray<TAnyNode> | undefined,
|
||||||
|
// The key path to get to this node from the root node.
|
||||||
|
path: ReadonlyArray<string | number>,
|
||||||
|
// All nodes and Arrays visited before reaching parent of this node.
|
||||||
|
// These correspond to array indices in `path`.
|
||||||
|
// Note: ancestors includes arrays which contain the parent of visited node.
|
||||||
|
ancestors: ReadonlyArray<TAnyNode | ReadonlyArray<TAnyNode>>
|
||||||
|
) => any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A KeyMap describes each the traversable properties of each kind of node.
|
||||||
|
*/
|
||||||
|
export type VisitorKeyMap<T> = { [P in keyof T]: ReadonlyArray<keyof T[P]> };
|
||||||
|
|
||||||
|
export const QueryDocumentKeys: { [key: string]: string[] };
|
||||||
|
|
||||||
|
export const BREAK: any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* visit() will walk through an AST using a depth first traversal, calling
|
||||||
|
* the visitor's enter function at each node in the traversal, and calling the
|
||||||
|
* leave function after visiting that node and all of its child nodes.
|
||||||
|
*
|
||||||
|
* By returning different values from the enter and leave functions, the
|
||||||
|
* behavior of the visitor can be altered, including skipping over a sub-tree of
|
||||||
|
* the AST (by returning false), editing the AST by returning a value or null
|
||||||
|
* to remove the value, or to stop the whole traversal by returning BREAK.
|
||||||
|
*
|
||||||
|
* When using visit() to edit an AST, the original AST will not be modified, and
|
||||||
|
* a new version of the AST with the changes applied will be returned from the
|
||||||
|
* visit function.
|
||||||
|
*
|
||||||
|
* const editedAST = visit(ast, {
|
||||||
|
* enter(node, key, parent, path, ancestors) {
|
||||||
|
* // @return
|
||||||
|
* // undefined: no action
|
||||||
|
* // false: skip visiting this node
|
||||||
|
* // visitor.BREAK: stop visiting altogether
|
||||||
|
* // null: delete this node
|
||||||
|
* // any value: replace this node with the returned value
|
||||||
|
* },
|
||||||
|
* leave(node, key, parent, path, ancestors) {
|
||||||
|
* // @return
|
||||||
|
* // undefined: no action
|
||||||
|
* // false: no action
|
||||||
|
* // visitor.BREAK: stop visiting altogether
|
||||||
|
* // null: delete this node
|
||||||
|
* // any value: replace this node with the returned value
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* Alternatively to providing enter() and leave() functions, a visitor can
|
||||||
|
* instead provide functions named the same as the kinds of AST nodes, or
|
||||||
|
* enter/leave visitors at a named key, leading to four permutations of
|
||||||
|
* visitor API:
|
||||||
|
*
|
||||||
|
* 1) Named visitors triggered when entering a node a specific kind.
|
||||||
|
*
|
||||||
|
* visit(ast, {
|
||||||
|
* Kind(node) {
|
||||||
|
* // enter the "Kind" node
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* 2) Named visitors that trigger upon entering and leaving a node of
|
||||||
|
* a specific kind.
|
||||||
|
*
|
||||||
|
* visit(ast, {
|
||||||
|
* Kind: {
|
||||||
|
* enter(node) {
|
||||||
|
* // enter the "Kind" node
|
||||||
|
* }
|
||||||
|
* leave(node) {
|
||||||
|
* // leave the "Kind" node
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* 3) Generic visitors that trigger upon entering and leaving any node.
|
||||||
|
*
|
||||||
|
* visit(ast, {
|
||||||
|
* enter(node) {
|
||||||
|
* // enter any node
|
||||||
|
* },
|
||||||
|
* leave(node) {
|
||||||
|
* // leave any node
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* 4) Parallel visitors for entering and leaving nodes of a specific kind.
|
||||||
|
*
|
||||||
|
* visit(ast, {
|
||||||
|
* enter: {
|
||||||
|
* Kind(node) {
|
||||||
|
* // enter the "Kind" node
|
||||||
|
* }
|
||||||
|
* },
|
||||||
|
* leave: {
|
||||||
|
* Kind(node) {
|
||||||
|
* // leave the "Kind" node
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*/
|
||||||
|
export function visit(
|
||||||
|
root: ASTNode,
|
||||||
|
visitor: Visitor<ASTKindToNode>,
|
||||||
|
visitorKeys?: VisitorKeyMap<ASTKindToNode> // default: QueryDocumentKeys
|
||||||
|
): any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new visitor instance which delegates to many visitors to run in
|
||||||
|
* parallel. Each visitor will be visited for each node before moving on.
|
||||||
|
*
|
||||||
|
* If a prior visitor edits a node, no following visitors will see that node.
|
||||||
|
*/
|
||||||
|
export function visitInParallel(visitors: Array<Visitor<ASTKindToNode>>): Visitor<ASTKindToNode>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new visitor instance which maintains a provided TypeInfo instance
|
||||||
|
* along with visiting visitor.
|
||||||
|
*/
|
||||||
|
export function visitWithTypeInfo(typeInfo: TypeInfo, visitor: Visitor<ASTKindToNode>): Visitor<ASTKindToNode>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a visitor instance, if it is leaving or not, and a node kind, return
|
||||||
|
* the function the visitor runtime should call.
|
||||||
|
*/
|
||||||
|
export function getVisitFn(visitor: Visitor<any>, kind: string, isLeaving: boolean): Maybe<VisitFn<any>>;
|
||||||
|
|
@ -0,0 +1,119 @@
|
||||||
|
{
|
||||||
|
"name": "@types/graphql",
|
||||||
|
"version": "14.2.3",
|
||||||
|
"description": "TypeScript definitions for graphql",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "TonyYang",
|
||||||
|
"url": "https://github.com/TonyPythoneer",
|
||||||
|
"githubUsername": "TonyPythoneer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Caleb Meredith",
|
||||||
|
"url": "https://github.com/calebmer",
|
||||||
|
"githubUsername": "calebmer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Dominic Watson",
|
||||||
|
"url": "https://github.com/intellix",
|
||||||
|
"githubUsername": "intellix"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Firede",
|
||||||
|
"url": "https://github.com/firede",
|
||||||
|
"githubUsername": "firede"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Kepennar",
|
||||||
|
"url": "https://github.com/kepennar",
|
||||||
|
"githubUsername": "kepennar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Mikhail Novikov",
|
||||||
|
"url": "https://github.com/freiksenet",
|
||||||
|
"githubUsername": "freiksenet"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Ivan Goncharov",
|
||||||
|
"url": "https://github.com/IvanGoncharov",
|
||||||
|
"githubUsername": "IvanGoncharov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Hagai Cohen",
|
||||||
|
"url": "https://github.com/DxCx",
|
||||||
|
"githubUsername": "DxCx"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Ricardo Portugal",
|
||||||
|
"url": "https://github.com/rportugal",
|
||||||
|
"githubUsername": "rportugal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Tim Griesser",
|
||||||
|
"url": "https://github.com/tgriesser",
|
||||||
|
"githubUsername": "tgriesser"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Dylan Stewart",
|
||||||
|
"url": "https://github.com/dyst5422",
|
||||||
|
"githubUsername": "dyst5422"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Alessio Dionisi",
|
||||||
|
"url": "https://github.com/adnsio",
|
||||||
|
"githubUsername": "adnsio"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Divyendu Singh",
|
||||||
|
"url": "https://github.com/divyenduz",
|
||||||
|
"githubUsername": "divyenduz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Brad Zacher",
|
||||||
|
"url": "https://github.com/bradzacher",
|
||||||
|
"githubUsername": "bradzacher"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Curtis Layne",
|
||||||
|
"url": "https://github.com/clayne11",
|
||||||
|
"githubUsername": "clayne11"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jonathan Cardoso",
|
||||||
|
"url": "https://github.com/JCMais",
|
||||||
|
"githubUsername": "JCMais"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Pavel Lang",
|
||||||
|
"url": "https://github.com/langpavel",
|
||||||
|
"githubUsername": "langpavel"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Mark Caudill",
|
||||||
|
"url": "https://github.com/mc0",
|
||||||
|
"githubUsername": "mc0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Martijn Walraven",
|
||||||
|
"url": "https://github.com/martijnwalraven",
|
||||||
|
"githubUsername": "martijnwalraven"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jed Mao",
|
||||||
|
"url": "https://github.com/jedmao",
|
||||||
|
"githubUsername": "jedmao"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||||
|
"directory": "types/graphql"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {},
|
||||||
|
"typesPublisherContentHash": "9aa8839a3e40d2e230ae68d349603e9eba421e137eaa9a1e841de1867881c7b4",
|
||||||
|
"typeScriptVersion": "2.6"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export { subscribe, createSourceEventStream } from "./subscribe";
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import { GraphQLSchema } from "../type/schema";
|
||||||
|
import { DocumentNode } from "../language/ast";
|
||||||
|
import { GraphQLFieldResolver } from "../type/definition";
|
||||||
|
import { ExecutionResult, ExecutionResultDataDefault } from "../execution/execute";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements the "Subscribe" algorithm described in the GraphQL specification.
|
||||||
|
*
|
||||||
|
* Returns a Promise which resolves to either an AsyncIterator (if successful)
|
||||||
|
* or an ExecutionResult (client error). The promise will be rejected if a
|
||||||
|
* server error occurs.
|
||||||
|
*
|
||||||
|
* If the client-provided arguments to this function do not result in a
|
||||||
|
* compliant subscription, a GraphQL Response (ExecutionResult) with
|
||||||
|
* descriptive errors and no data will be returned.
|
||||||
|
*
|
||||||
|
* If the the source stream could not be created due to faulty subscription
|
||||||
|
* resolver logic or underlying systems, the promise will resolve to a single
|
||||||
|
* ExecutionResult containing `errors` and no `data`.
|
||||||
|
*
|
||||||
|
* If the operation succeeded, the promise resolves to an AsyncIterator, which
|
||||||
|
* yields a stream of ExecutionResults representing the response stream.
|
||||||
|
*
|
||||||
|
* Accepts either an object with named arguments, or individual arguments.
|
||||||
|
*/
|
||||||
|
export function subscribe<TData = ExecutionResultDataDefault>(args: {
|
||||||
|
schema: GraphQLSchema;
|
||||||
|
document: DocumentNode;
|
||||||
|
rootValue?: any;
|
||||||
|
contextValue?: any;
|
||||||
|
variableValues?: Maybe<{ [key: string]: any }>;
|
||||||
|
operationName?: Maybe<string>;
|
||||||
|
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
|
||||||
|
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
|
||||||
|
}): Promise<AsyncIterableIterator<ExecutionResult<TData>> | ExecutionResult<TData>>;
|
||||||
|
|
||||||
|
export function subscribe<TData = ExecutionResultDataDefault>(
|
||||||
|
schema: GraphQLSchema,
|
||||||
|
document: DocumentNode,
|
||||||
|
rootValue?: any,
|
||||||
|
contextValue?: any,
|
||||||
|
variableValues?: Maybe<{ [key: string]: any }>,
|
||||||
|
operationName?: Maybe<string>,
|
||||||
|
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>,
|
||||||
|
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
|
||||||
|
): Promise<AsyncIterableIterator<ExecutionResult<TData>> | ExecutionResult<TData>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements the "CreateSourceEventStream" algorithm described in the
|
||||||
|
* GraphQL specification, resolving the subscription source event stream.
|
||||||
|
*
|
||||||
|
* Returns a Promise<AsyncIterable>.
|
||||||
|
*
|
||||||
|
* If the client-provided invalid arguments, the source stream could not be
|
||||||
|
* created, or the resolver did not return an AsyncIterable, this function will
|
||||||
|
* will throw an error, which should be caught and handled by the caller.
|
||||||
|
*
|
||||||
|
* A Source Event Stream represents a sequence of events, each of which triggers
|
||||||
|
* a GraphQL execution for that event.
|
||||||
|
*
|
||||||
|
* This may be useful when hosting the stateful subscription service in a
|
||||||
|
* different process or machine than the stateless GraphQL execution engine,
|
||||||
|
* or otherwise separating these two steps. For more on this, see the
|
||||||
|
* "Supporting Subscriptions at Scale" information in the GraphQL specification.
|
||||||
|
*/
|
||||||
|
export function createSourceEventStream<TData = ExecutionResultDataDefault>(
|
||||||
|
schema: GraphQLSchema,
|
||||||
|
document: DocumentNode,
|
||||||
|
rootValue?: any,
|
||||||
|
contextValue?: any,
|
||||||
|
variableValues?: { [key: string]: any },
|
||||||
|
operationName?: Maybe<string>,
|
||||||
|
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
|
||||||
|
): Promise<AsyncIterable<any> | ExecutionResult<TData>>;
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
// Conveniently represents flow's "Maybe" type https://flow.org/en/docs/types/maybe/
|
||||||
|
type Maybe<T> = null | undefined | T;
|
||||||
|
|
||||||
|
export default Maybe;
|
||||||
|
|
@ -0,0 +1,715 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import { PromiseOrValue } from "../jsutils/PromiseOrValue";
|
||||||
|
import {
|
||||||
|
ScalarTypeDefinitionNode,
|
||||||
|
ObjectTypeDefinitionNode,
|
||||||
|
FieldDefinitionNode,
|
||||||
|
InputValueDefinitionNode,
|
||||||
|
InterfaceTypeDefinitionNode,
|
||||||
|
UnionTypeDefinitionNode,
|
||||||
|
EnumTypeDefinitionNode,
|
||||||
|
EnumValueDefinitionNode,
|
||||||
|
InputObjectTypeDefinitionNode,
|
||||||
|
ObjectTypeExtensionNode,
|
||||||
|
InterfaceTypeExtensionNode,
|
||||||
|
OperationDefinitionNode,
|
||||||
|
FieldNode,
|
||||||
|
FragmentDefinitionNode,
|
||||||
|
ValueNode,
|
||||||
|
ScalarTypeExtensionNode,
|
||||||
|
UnionTypeExtensionNode,
|
||||||
|
EnumTypeExtensionNode,
|
||||||
|
InputObjectTypeExtensionNode,
|
||||||
|
} from "../language/ast";
|
||||||
|
import { GraphQLSchema } from "./schema";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These are all of the possible kinds of types.
|
||||||
|
*/
|
||||||
|
export type GraphQLType =
|
||||||
|
| GraphQLScalarType
|
||||||
|
| GraphQLObjectType
|
||||||
|
| GraphQLInterfaceType
|
||||||
|
| GraphQLUnionType
|
||||||
|
| GraphQLEnumType
|
||||||
|
| GraphQLInputObjectType
|
||||||
|
| GraphQLList<any>
|
||||||
|
| GraphQLNonNull<any>;
|
||||||
|
|
||||||
|
export function isType(type: any): type is GraphQLType;
|
||||||
|
|
||||||
|
export function assertType(type: any): GraphQLType;
|
||||||
|
|
||||||
|
export function isScalarType(type: any): type is GraphQLScalarType;
|
||||||
|
|
||||||
|
export function assertScalarType(type: any): GraphQLScalarType;
|
||||||
|
|
||||||
|
export function isObjectType(type: any): type is GraphQLObjectType;
|
||||||
|
|
||||||
|
export function assertObjectType(type: any): GraphQLObjectType;
|
||||||
|
|
||||||
|
export function isInterfaceType(type: any): type is GraphQLInterfaceType;
|
||||||
|
|
||||||
|
export function assertInterfaceType(type: any): GraphQLInterfaceType;
|
||||||
|
|
||||||
|
export function isUnionType(type: any): type is GraphQLUnionType;
|
||||||
|
|
||||||
|
export function assertUnionType(type: any): GraphQLUnionType;
|
||||||
|
|
||||||
|
export function isEnumType(type: any): type is GraphQLEnumType;
|
||||||
|
|
||||||
|
export function assertEnumType(type: any): GraphQLEnumType;
|
||||||
|
|
||||||
|
export function isInputObjectType(type: any): type is GraphQLInputObjectType;
|
||||||
|
|
||||||
|
export function assertInputObjectType(type: any): GraphQLInputObjectType;
|
||||||
|
|
||||||
|
export function isListType(type: any): type is GraphQLList<any>;
|
||||||
|
|
||||||
|
export function assertListType(type: any): GraphQLList<any>;
|
||||||
|
|
||||||
|
export function isNonNullType(type: any): type is GraphQLNonNull<any>;
|
||||||
|
|
||||||
|
export function assertNonNullType(type: any): GraphQLNonNull<any>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These types may be used as input types for arguments and directives.
|
||||||
|
*/
|
||||||
|
export type GraphQLInputType =
|
||||||
|
| GraphQLScalarType
|
||||||
|
| GraphQLEnumType
|
||||||
|
| GraphQLInputObjectType
|
||||||
|
| GraphQLList<any>
|
||||||
|
| GraphQLNonNull<GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList<any>>;
|
||||||
|
|
||||||
|
export function isInputType(type: any): type is GraphQLInputType;
|
||||||
|
|
||||||
|
export function assertInputType(type: any): GraphQLInputType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These types may be used as output types as the result of fields.
|
||||||
|
*/
|
||||||
|
export type GraphQLOutputType =
|
||||||
|
| GraphQLScalarType
|
||||||
|
| GraphQLObjectType
|
||||||
|
| GraphQLInterfaceType
|
||||||
|
| GraphQLUnionType
|
||||||
|
| GraphQLEnumType
|
||||||
|
| GraphQLList<any>
|
||||||
|
| GraphQLNonNull<
|
||||||
|
| GraphQLScalarType
|
||||||
|
| GraphQLObjectType
|
||||||
|
| GraphQLInterfaceType
|
||||||
|
| GraphQLUnionType
|
||||||
|
| GraphQLEnumType
|
||||||
|
| GraphQLList<any>
|
||||||
|
>;
|
||||||
|
|
||||||
|
export function isOutputType(type: any): type is GraphQLOutputType;
|
||||||
|
|
||||||
|
export function assertOutputType(type: any): GraphQLOutputType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These types may describe types which may be leaf values.
|
||||||
|
*/
|
||||||
|
export type GraphQLLeafType = GraphQLScalarType | GraphQLEnumType;
|
||||||
|
|
||||||
|
export function isLeafType(type: any): type is GraphQLLeafType;
|
||||||
|
|
||||||
|
export function assertLeafType(type: any): GraphQLLeafType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These types may describe the parent context of a selection set.
|
||||||
|
*/
|
||||||
|
export type GraphQLCompositeType = GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType;
|
||||||
|
|
||||||
|
export function isCompositeType(type: any): type is GraphQLCompositeType;
|
||||||
|
|
||||||
|
export function assertCompositeType(type: any): GraphQLCompositeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These types may describe the parent context of a selection set.
|
||||||
|
*/
|
||||||
|
export type GraphQLAbstractType = GraphQLInterfaceType | GraphQLUnionType;
|
||||||
|
|
||||||
|
export function isAbstractType(type: any): type is GraphQLAbstractType;
|
||||||
|
|
||||||
|
export function assertAbstractType(type: any): GraphQLAbstractType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List Modifier
|
||||||
|
*
|
||||||
|
* A list is a kind of type marker, a wrapping type which points to another
|
||||||
|
* type. Lists are often created within the context of defining the fields
|
||||||
|
* of an object type.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* const PersonType = new GraphQLObjectType({
|
||||||
|
* name: 'Person',
|
||||||
|
* fields: () => ({
|
||||||
|
* parents: { type: new GraphQLList(Person) },
|
||||||
|
* children: { type: new GraphQLList(Person) },
|
||||||
|
* })
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
interface GraphQLList<T extends GraphQLType> {
|
||||||
|
readonly ofType: T;
|
||||||
|
toString(): string;
|
||||||
|
toJSON(): string;
|
||||||
|
inspect(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface _GraphQLList<T extends GraphQLType> {
|
||||||
|
(type: T): GraphQLList<T>;
|
||||||
|
new (type: T): GraphQLList<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const GraphQLList: _GraphQLList<GraphQLType>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Non-Null Modifier
|
||||||
|
*
|
||||||
|
* A non-null is a kind of type marker, a wrapping type which points to another
|
||||||
|
* type. Non-null types enforce that their values are never null and can ensure
|
||||||
|
* an error is raised if this ever occurs during a request. It is useful for
|
||||||
|
* fields which you can make a strong guarantee on non-nullability, for example
|
||||||
|
* usually the id field of a database row will never be null.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* const RowType = new GraphQLObjectType({
|
||||||
|
* name: 'Row',
|
||||||
|
* fields: () => ({
|
||||||
|
* id: { type: new GraphQLNonNull(GraphQLString) },
|
||||||
|
* })
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* Note: the enforcement of non-nullability occurs within the executor.
|
||||||
|
*/
|
||||||
|
interface GraphQLNonNull<T extends GraphQLNullableType> {
|
||||||
|
readonly ofType: T;
|
||||||
|
toString(): string;
|
||||||
|
toJSON(): string;
|
||||||
|
inspect(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface _GraphQLNonNull<T extends GraphQLNullableType> {
|
||||||
|
(type: T): GraphQLNonNull<T>;
|
||||||
|
new (type: T): GraphQLNonNull<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const GraphQLNonNull: _GraphQLNonNull<GraphQLNullableType>;
|
||||||
|
|
||||||
|
export type GraphQLWrappingType = GraphQLList<any> | GraphQLNonNull<any>;
|
||||||
|
|
||||||
|
export function isWrappingType(type: any): type is GraphQLWrappingType;
|
||||||
|
|
||||||
|
export function assertWrappingType(type: any): GraphQLWrappingType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These types can all accept null as a value.
|
||||||
|
*/
|
||||||
|
export type GraphQLNullableType =
|
||||||
|
| GraphQLScalarType
|
||||||
|
| GraphQLObjectType
|
||||||
|
| GraphQLInterfaceType
|
||||||
|
| GraphQLUnionType
|
||||||
|
| GraphQLEnumType
|
||||||
|
| GraphQLInputObjectType
|
||||||
|
| GraphQLList<any>;
|
||||||
|
|
||||||
|
export function isNullableType(type: any): type is GraphQLNullableType;
|
||||||
|
|
||||||
|
export function assertNullableType(type: any): GraphQLNullableType;
|
||||||
|
|
||||||
|
export function getNullableType(type: void): undefined;
|
||||||
|
export function getNullableType<T extends GraphQLNullableType>(type: T): T;
|
||||||
|
export function getNullableType<T extends GraphQLNullableType>(type: GraphQLNonNull<T>): T;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These named types do not include modifiers like List or NonNull.
|
||||||
|
*/
|
||||||
|
export type GraphQLNamedType =
|
||||||
|
| GraphQLScalarType
|
||||||
|
| GraphQLObjectType
|
||||||
|
| GraphQLInterfaceType
|
||||||
|
| GraphQLUnionType
|
||||||
|
| GraphQLEnumType
|
||||||
|
| GraphQLInputObjectType;
|
||||||
|
|
||||||
|
export function isNamedType(type: any): type is GraphQLNamedType;
|
||||||
|
|
||||||
|
export function assertNamedType(type: any): GraphQLNamedType;
|
||||||
|
|
||||||
|
export function getNamedType(type: void): undefined;
|
||||||
|
export function getNamedType(type: GraphQLType): GraphQLNamedType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used while defining GraphQL types to allow for circular references in
|
||||||
|
* otherwise immutable type definitions.
|
||||||
|
*/
|
||||||
|
export type Thunk<T> = (() => T) | T;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scalar Type Definition
|
||||||
|
*
|
||||||
|
* The leaf values of any request and input values to arguments are
|
||||||
|
* Scalars (or Enums) and are defined with a name and a series of functions
|
||||||
|
* used to parse input from ast or variables and to ensure validity.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* const OddType = new GraphQLScalarType({
|
||||||
|
* name: 'Odd',
|
||||||
|
* serialize(value) {
|
||||||
|
* return value % 2 === 1 ? value : null;
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export class GraphQLScalarType {
|
||||||
|
name: string;
|
||||||
|
description: Maybe<string>;
|
||||||
|
serialize: GraphQLScalarSerializer<any>;
|
||||||
|
parseValue: GraphQLScalarValueParser<any>;
|
||||||
|
parseLiteral: GraphQLScalarLiteralParser<any>;
|
||||||
|
astNode: Maybe<ScalarTypeDefinitionNode>;
|
||||||
|
extensionASTNodes: Maybe<ReadonlyArray<ScalarTypeExtensionNode>>;
|
||||||
|
constructor(config: GraphQLScalarTypeConfig<any, any>);
|
||||||
|
|
||||||
|
toConfig(): GraphQLScalarTypeConfig<any, any> & {
|
||||||
|
parseValue: GraphQLScalarValueParser<any>;
|
||||||
|
parseLiteral: GraphQLScalarLiteralParser<any>;
|
||||||
|
extensionASTNodes: ReadonlyArray<ScalarTypeExtensionNode>;
|
||||||
|
};
|
||||||
|
|
||||||
|
toString(): string;
|
||||||
|
toJSON(): string;
|
||||||
|
inspect(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type GraphQLScalarSerializer<TExternal> = (value: any) => Maybe<TExternal>;
|
||||||
|
export type GraphQLScalarValueParser<TInternal> = (value: any) => Maybe<TInternal>;
|
||||||
|
export type GraphQLScalarLiteralParser<TInternal> = (
|
||||||
|
valueNode: ValueNode,
|
||||||
|
variables: Maybe<{ [key: string]: any }>
|
||||||
|
) => Maybe<TInternal>;
|
||||||
|
|
||||||
|
export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
|
||||||
|
name: string;
|
||||||
|
description?: Maybe<string>;
|
||||||
|
// Serializes an internal value to include in a response.
|
||||||
|
serialize: GraphQLScalarSerializer<TExternal>;
|
||||||
|
// Parses an externally provided value to use as an input.
|
||||||
|
parseValue?: GraphQLScalarValueParser<TInternal>;
|
||||||
|
// Parses an externally provided literal value to use as an input.
|
||||||
|
parseLiteral?: GraphQLScalarLiteralParser<TInternal>;
|
||||||
|
astNode?: Maybe<ScalarTypeDefinitionNode>;
|
||||||
|
extensionASTNodes?: Maybe<ReadonlyArray<ScalarTypeExtensionNode>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object Type Definition
|
||||||
|
*
|
||||||
|
* Almost all of the GraphQL types you define will be object types. Object types
|
||||||
|
* have a name, but most importantly describe their fields.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* const AddressType = new GraphQLObjectType({
|
||||||
|
* name: 'Address',
|
||||||
|
* fields: {
|
||||||
|
* street: { type: GraphQLString },
|
||||||
|
* number: { type: GraphQLInt },
|
||||||
|
* formatted: {
|
||||||
|
* type: GraphQLString,
|
||||||
|
* resolve(obj) {
|
||||||
|
* return obj.number + ' ' + obj.street
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* When two types need to refer to each other, or a type needs to refer to
|
||||||
|
* itself in a field, you can use a function expression (aka a closure or a
|
||||||
|
* thunk) to supply the fields lazily.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* const PersonType = new GraphQLObjectType({
|
||||||
|
* name: 'Person',
|
||||||
|
* fields: () => ({
|
||||||
|
* name: { type: GraphQLString },
|
||||||
|
* bestFriend: { type: PersonType },
|
||||||
|
* })
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export class GraphQLObjectType<TSource = any, TContext = any, TArgs = { [key: string]: any }> {
|
||||||
|
name: string;
|
||||||
|
description: Maybe<string>;
|
||||||
|
astNode: Maybe<ObjectTypeDefinitionNode>;
|
||||||
|
extensionASTNodes: Maybe<ReadonlyArray<ObjectTypeExtensionNode>>;
|
||||||
|
isTypeOf: Maybe<GraphQLIsTypeOfFn<TSource, TContext>>;
|
||||||
|
|
||||||
|
constructor(config: GraphQLObjectTypeConfig<TSource, TContext, TArgs>);
|
||||||
|
getFields(): GraphQLFieldMap<any, TContext, TArgs>;
|
||||||
|
getInterfaces(): GraphQLInterfaceType[];
|
||||||
|
|
||||||
|
toConfig(): GraphQLObjectTypeConfig<any, any> & {
|
||||||
|
interfaces: GraphQLInterfaceType[];
|
||||||
|
fields: GraphQLFieldConfigMap<any, any>;
|
||||||
|
extensionASTNodes: ReadonlyArray<ObjectTypeExtensionNode>;
|
||||||
|
};
|
||||||
|
|
||||||
|
toString(): string;
|
||||||
|
toJSON(): string;
|
||||||
|
inspect(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GraphQLObjectTypeConfig<TSource, TContext, TArgs = { [key: string]: any }> {
|
||||||
|
name: string;
|
||||||
|
interfaces?: Thunk<Maybe<GraphQLInterfaceType[]>>;
|
||||||
|
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext, TArgs>>;
|
||||||
|
isTypeOf?: Maybe<GraphQLIsTypeOfFn<TSource, TContext>>;
|
||||||
|
description?: Maybe<string>;
|
||||||
|
astNode?: Maybe<ObjectTypeDefinitionNode>;
|
||||||
|
extensionASTNodes?: Maybe<ReadonlyArray<ObjectTypeExtensionNode>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type GraphQLTypeResolver<TSource, TContext, TArgs = { [key: string]: any }> = (
|
||||||
|
value: TSource,
|
||||||
|
context: TContext,
|
||||||
|
info: GraphQLResolveInfo
|
||||||
|
) => PromiseOrValue<Maybe<GraphQLObjectType<TSource, TContext, TArgs> | string>>;
|
||||||
|
|
||||||
|
export type GraphQLIsTypeOfFn<TSource, TContext> = (
|
||||||
|
source: TSource,
|
||||||
|
context: TContext,
|
||||||
|
info: GraphQLResolveInfo
|
||||||
|
) => PromiseOrValue<boolean>;
|
||||||
|
|
||||||
|
export type GraphQLFieldResolver<TSource, TContext, TArgs = { [argName: string]: any }> = (
|
||||||
|
source: TSource,
|
||||||
|
args: TArgs,
|
||||||
|
context: TContext,
|
||||||
|
info: GraphQLResolveInfo
|
||||||
|
) => any;
|
||||||
|
|
||||||
|
export interface GraphQLResolveInfo {
|
||||||
|
readonly fieldName: string;
|
||||||
|
readonly fieldNodes: ReadonlyArray<FieldNode>;
|
||||||
|
readonly returnType: GraphQLOutputType;
|
||||||
|
readonly parentType: GraphQLObjectType;
|
||||||
|
readonly path: ResponsePath;
|
||||||
|
readonly schema: GraphQLSchema;
|
||||||
|
readonly fragments: { [key: string]: FragmentDefinitionNode };
|
||||||
|
readonly rootValue: any;
|
||||||
|
readonly operation: OperationDefinitionNode;
|
||||||
|
readonly variableValues: { [variableName: string]: any };
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ResponsePath = {
|
||||||
|
readonly prev: ResponsePath | undefined;
|
||||||
|
readonly key: string | number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface GraphQLFieldConfig<TSource, TContext, TArgs = { [argName: string]: any }> {
|
||||||
|
type: GraphQLOutputType;
|
||||||
|
args?: GraphQLFieldConfigArgumentMap;
|
||||||
|
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
|
||||||
|
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>;
|
||||||
|
deprecationReason?: Maybe<string>;
|
||||||
|
description?: Maybe<string>;
|
||||||
|
astNode?: Maybe<FieldDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type GraphQLFieldConfigArgumentMap = { [key: string]: GraphQLArgumentConfig };
|
||||||
|
|
||||||
|
export interface GraphQLArgumentConfig {
|
||||||
|
type: GraphQLInputType;
|
||||||
|
defaultValue?: any;
|
||||||
|
description?: Maybe<string>;
|
||||||
|
astNode?: Maybe<InputValueDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type GraphQLFieldConfigMap<TSource, TContext, TArgs = { [key: string]: any }> = {
|
||||||
|
[key: string]: GraphQLFieldConfig<TSource, TContext, TArgs>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface GraphQLField<TSource, TContext, TArgs = { [key: string]: any }> {
|
||||||
|
name: string;
|
||||||
|
description: Maybe<string>;
|
||||||
|
type: GraphQLOutputType;
|
||||||
|
args: GraphQLArgument[];
|
||||||
|
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
|
||||||
|
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>;
|
||||||
|
isDeprecated?: boolean;
|
||||||
|
deprecationReason?: Maybe<string>;
|
||||||
|
astNode?: Maybe<FieldDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GraphQLArgument {
|
||||||
|
name: string;
|
||||||
|
type: GraphQLInputType;
|
||||||
|
defaultValue?: any;
|
||||||
|
description?: Maybe<string>;
|
||||||
|
astNode?: Maybe<InputValueDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isRequiredArgument(arg: GraphQLArgument): boolean;
|
||||||
|
|
||||||
|
export type GraphQLFieldMap<TSource, TContext, TArgs = { [key: string]: any }> = {
|
||||||
|
[key: string]: GraphQLField<TSource, TContext, TArgs>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface Type Definition
|
||||||
|
*
|
||||||
|
* When a field can return one of a heterogeneous set of types, a Interface type
|
||||||
|
* is used to describe what types are possible, what fields are in common across
|
||||||
|
* all types, as well as a function to determine which type is actually used
|
||||||
|
* when the field is resolved.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* const EntityType = new GraphQLInterfaceType({
|
||||||
|
* name: 'Entity',
|
||||||
|
* fields: {
|
||||||
|
* name: { type: GraphQLString }
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export class GraphQLInterfaceType {
|
||||||
|
name: string;
|
||||||
|
description: Maybe<string>;
|
||||||
|
astNode?: Maybe<InterfaceTypeDefinitionNode>;
|
||||||
|
extensionASTNodes: Maybe<ReadonlyArray<InterfaceTypeExtensionNode>>;
|
||||||
|
resolveType: Maybe<GraphQLTypeResolver<any, any>>;
|
||||||
|
|
||||||
|
constructor(config: GraphQLInterfaceTypeConfig<any, any>);
|
||||||
|
|
||||||
|
getFields(): GraphQLFieldMap<any, any>;
|
||||||
|
|
||||||
|
toConfig(): GraphQLInterfaceTypeConfig<any, any> & {
|
||||||
|
fields: GraphQLFieldConfigMap<any, any>;
|
||||||
|
extensionASTNodes: ReadonlyArray<InterfaceTypeExtensionNode>;
|
||||||
|
};
|
||||||
|
|
||||||
|
toString(): string;
|
||||||
|
toJSON(): string;
|
||||||
|
inspect(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GraphQLInterfaceTypeConfig<TSource, TContext, TArgs = { [key: string]: any }> {
|
||||||
|
name: string;
|
||||||
|
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext, TArgs>>;
|
||||||
|
/**
|
||||||
|
* Optionally provide a custom type resolver function. If one is not provided,
|
||||||
|
* the default implementation will call `isTypeOf` on each implementing
|
||||||
|
* Object type.
|
||||||
|
*/
|
||||||
|
resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext, TArgs>>;
|
||||||
|
description?: Maybe<string>;
|
||||||
|
astNode?: Maybe<InterfaceTypeDefinitionNode>;
|
||||||
|
extensionASTNodes?: Maybe<ReadonlyArray<InterfaceTypeExtensionNode>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Union Type Definition
|
||||||
|
*
|
||||||
|
* When a field can return one of a heterogeneous set of types, a Union type
|
||||||
|
* is used to describe what types are possible as well as providing a function
|
||||||
|
* to determine which type is actually used when the field is resolved.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* const PetType = new GraphQLUnionType({
|
||||||
|
* name: 'Pet',
|
||||||
|
* types: [ DogType, CatType ],
|
||||||
|
* resolveType(value) {
|
||||||
|
* if (value instanceof Dog) {
|
||||||
|
* return DogType;
|
||||||
|
* }
|
||||||
|
* if (value instanceof Cat) {
|
||||||
|
* return CatType;
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export class GraphQLUnionType {
|
||||||
|
name: string;
|
||||||
|
description: Maybe<string>;
|
||||||
|
astNode: Maybe<UnionTypeDefinitionNode>;
|
||||||
|
extensionASTNodes: Maybe<ReadonlyArray<UnionTypeExtensionNode>>;
|
||||||
|
resolveType: Maybe<GraphQLTypeResolver<any, any>>;
|
||||||
|
|
||||||
|
constructor(config: GraphQLUnionTypeConfig<any, any>);
|
||||||
|
|
||||||
|
getTypes(): GraphQLObjectType[];
|
||||||
|
|
||||||
|
toConfig(): GraphQLUnionTypeConfig<any, any> & {
|
||||||
|
types: GraphQLObjectType[];
|
||||||
|
extensionASTNodes: ReadonlyArray<UnionTypeExtensionNode>;
|
||||||
|
};
|
||||||
|
|
||||||
|
toString(): string;
|
||||||
|
toJSON(): string;
|
||||||
|
inspect(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GraphQLUnionTypeConfig<TSource, TContext> {
|
||||||
|
name: string;
|
||||||
|
types: Thunk<GraphQLObjectType[]>;
|
||||||
|
/**
|
||||||
|
* Optionally provide a custom type resolver function. If one is not provided,
|
||||||
|
* the default implementation will call `isTypeOf` on each implementing
|
||||||
|
* Object type.
|
||||||
|
*/
|
||||||
|
resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext>>;
|
||||||
|
description?: Maybe<string>;
|
||||||
|
astNode?: Maybe<UnionTypeDefinitionNode>;
|
||||||
|
extensionASTNodes?: Maybe<ReadonlyArray<UnionTypeExtensionNode>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum Type Definition
|
||||||
|
*
|
||||||
|
* Some leaf values of requests and input values are Enums. GraphQL serializes
|
||||||
|
* Enum values as strings, however internally Enums can be represented by any
|
||||||
|
* kind of type, often integers.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* const RGBType = new GraphQLEnumType({
|
||||||
|
* name: 'RGB',
|
||||||
|
* values: {
|
||||||
|
* RED: { value: 0 },
|
||||||
|
* GREEN: { value: 1 },
|
||||||
|
* BLUE: { value: 2 }
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* Note: If a value is not provided in a definition, the name of the enum value
|
||||||
|
* will be used as its internal value.
|
||||||
|
*/
|
||||||
|
export class GraphQLEnumType {
|
||||||
|
name: string;
|
||||||
|
description: Maybe<string>;
|
||||||
|
astNode: Maybe<EnumTypeDefinitionNode>;
|
||||||
|
extensionASTNodes: Maybe<ReadonlyArray<EnumTypeExtensionNode>>;
|
||||||
|
|
||||||
|
constructor(config: GraphQLEnumTypeConfig);
|
||||||
|
getValues(): GraphQLEnumValue[];
|
||||||
|
getValue(name: string): Maybe<GraphQLEnumValue>;
|
||||||
|
serialize(value: any): Maybe<string>;
|
||||||
|
parseValue(value: any): Maybe<any>;
|
||||||
|
parseLiteral(valueNode: ValueNode, _variables: Maybe<{ [key: string]: any }>): Maybe<any>;
|
||||||
|
|
||||||
|
toConfig(): GraphQLEnumTypeConfig & {
|
||||||
|
extensionASTNodes: ReadonlyArray<EnumTypeExtensionNode>;
|
||||||
|
};
|
||||||
|
|
||||||
|
toString(): string;
|
||||||
|
toJSON(): string;
|
||||||
|
inspect(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GraphQLEnumTypeConfig {
|
||||||
|
name: string;
|
||||||
|
values: GraphQLEnumValueConfigMap;
|
||||||
|
description?: Maybe<string>;
|
||||||
|
astNode?: Maybe<EnumTypeDefinitionNode>;
|
||||||
|
extensionASTNodes?: Maybe<ReadonlyArray<EnumTypeExtensionNode>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type GraphQLEnumValueConfigMap = { [key: string]: GraphQLEnumValueConfig };
|
||||||
|
|
||||||
|
export interface GraphQLEnumValueConfig {
|
||||||
|
value?: any;
|
||||||
|
deprecationReason?: Maybe<string>;
|
||||||
|
description?: Maybe<string>;
|
||||||
|
astNode?: Maybe<EnumValueDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GraphQLEnumValue {
|
||||||
|
name: string;
|
||||||
|
description: Maybe<string>;
|
||||||
|
isDeprecated?: boolean;
|
||||||
|
deprecationReason: Maybe<string>;
|
||||||
|
astNode?: Maybe<EnumValueDefinitionNode>;
|
||||||
|
value: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Input Object Type Definition
|
||||||
|
*
|
||||||
|
* An input object defines a structured collection of fields which may be
|
||||||
|
* supplied to a field argument.
|
||||||
|
*
|
||||||
|
* Using `NonNull` will ensure that a value must be provided by the query
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* const GeoPoint = new GraphQLInputObjectType({
|
||||||
|
* name: 'GeoPoint',
|
||||||
|
* fields: {
|
||||||
|
* lat: { type: new GraphQLNonNull(GraphQLFloat) },
|
||||||
|
* lon: { type: new GraphQLNonNull(GraphQLFloat) },
|
||||||
|
* alt: { type: GraphQLFloat, defaultValue: 0 },
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export class GraphQLInputObjectType {
|
||||||
|
name: string;
|
||||||
|
description: Maybe<string>;
|
||||||
|
astNode: Maybe<InputObjectTypeDefinitionNode>;
|
||||||
|
extensionASTNodes: Maybe<ReadonlyArray<InputObjectTypeExtensionNode>>;
|
||||||
|
constructor(config: GraphQLInputObjectTypeConfig);
|
||||||
|
getFields(): GraphQLInputFieldMap;
|
||||||
|
|
||||||
|
toConfig(): GraphQLInputObjectTypeConfig & {
|
||||||
|
fields: GraphQLInputFieldConfigMap;
|
||||||
|
extensionASTNodes: ReadonlyArray<InputObjectTypeExtensionNode>;
|
||||||
|
};
|
||||||
|
|
||||||
|
toString(): string;
|
||||||
|
toJSON(): string;
|
||||||
|
inspect(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GraphQLInputObjectTypeConfig {
|
||||||
|
name: string;
|
||||||
|
fields: Thunk<GraphQLInputFieldConfigMap>;
|
||||||
|
description?: Maybe<string>;
|
||||||
|
astNode?: Maybe<InputObjectTypeDefinitionNode>;
|
||||||
|
extensionASTNodes?: Maybe<ReadonlyArray<InputObjectTypeExtensionNode>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GraphQLInputFieldConfig {
|
||||||
|
type: GraphQLInputType;
|
||||||
|
defaultValue?: any;
|
||||||
|
description?: Maybe<string>;
|
||||||
|
astNode?: Maybe<InputValueDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type GraphQLInputFieldConfigMap = {
|
||||||
|
[key: string]: GraphQLInputFieldConfig;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface GraphQLInputField {
|
||||||
|
name: string;
|
||||||
|
type: GraphQLInputType;
|
||||||
|
defaultValue?: any;
|
||||||
|
description?: Maybe<string>;
|
||||||
|
astNode?: Maybe<InputValueDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isRequiredInputField(field: GraphQLInputField): boolean;
|
||||||
|
|
||||||
|
export type GraphQLInputFieldMap = { [key: string]: GraphQLInputField };
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import { GraphQLFieldConfigArgumentMap, GraphQLArgument } from "./definition";
|
||||||
|
import { DirectiveDefinitionNode } from "../language/ast";
|
||||||
|
import { DirectiveLocationEnum } from "../language/directiveLocation";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if the given value is a GraphQL directive.
|
||||||
|
*/
|
||||||
|
export function isDirective(directive: any): directive is GraphQLDirective;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Directives are used by the GraphQL runtime as a way of modifying execution
|
||||||
|
* behavior. Type system creators will usually not create these directly.
|
||||||
|
*/
|
||||||
|
export class GraphQLDirective {
|
||||||
|
name: string;
|
||||||
|
description: Maybe<string>;
|
||||||
|
locations: DirectiveLocationEnum[];
|
||||||
|
isRepeatable: boolean;
|
||||||
|
args: GraphQLArgument[];
|
||||||
|
astNode: Maybe<DirectiveDefinitionNode>;
|
||||||
|
|
||||||
|
constructor(config: GraphQLDirectiveConfig);
|
||||||
|
|
||||||
|
toConfig(): GraphQLDirectiveConfig & {
|
||||||
|
args: GraphQLFieldConfigArgumentMap;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GraphQLDirectiveConfig {
|
||||||
|
name: string;
|
||||||
|
description?: Maybe<string>;
|
||||||
|
locations: DirectiveLocationEnum[];
|
||||||
|
args?: Maybe<GraphQLFieldConfigArgumentMap>;
|
||||||
|
isRepeatable?: Maybe<boolean>;
|
||||||
|
astNode?: Maybe<DirectiveDefinitionNode>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to conditionally include fields or fragments.
|
||||||
|
*/
|
||||||
|
export const GraphQLIncludeDirective: GraphQLDirective;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to conditionally skip (exclude) fields or fragments.
|
||||||
|
*/
|
||||||
|
export const GraphQLSkipDirective: GraphQLDirective;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constant string used for default reason for a deprecation.
|
||||||
|
*/
|
||||||
|
export const DEFAULT_DEPRECATION_REASON: "No longer supported";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to declare element of a GraphQL schema as deprecated.
|
||||||
|
*/
|
||||||
|
export const GraphQLDeprecatedDirective: GraphQLDirective;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The full list of specified directives.
|
||||||
|
*/
|
||||||
|
export const specifiedDirectives: ReadonlyArray<GraphQLDirective>;
|
||||||
|
|
||||||
|
export function isSpecifiedDirective(directive: GraphQLDirective): boolean;
|
||||||
|
|
@ -0,0 +1,150 @@
|
||||||
|
export {
|
||||||
|
// Predicate
|
||||||
|
isSchema,
|
||||||
|
// GraphQL Schema definition
|
||||||
|
GraphQLSchema,
|
||||||
|
GraphQLSchemaConfig,
|
||||||
|
} from "./schema";
|
||||||
|
|
||||||
|
export {
|
||||||
|
// Predicates
|
||||||
|
isType,
|
||||||
|
isScalarType,
|
||||||
|
isObjectType,
|
||||||
|
isInterfaceType,
|
||||||
|
isUnionType,
|
||||||
|
isEnumType,
|
||||||
|
isInputObjectType,
|
||||||
|
isListType,
|
||||||
|
isNonNullType,
|
||||||
|
isInputType,
|
||||||
|
isOutputType,
|
||||||
|
isLeafType,
|
||||||
|
isCompositeType,
|
||||||
|
isAbstractType,
|
||||||
|
isWrappingType,
|
||||||
|
isNullableType,
|
||||||
|
isNamedType,
|
||||||
|
isRequiredArgument,
|
||||||
|
isRequiredInputField,
|
||||||
|
// Assertions
|
||||||
|
assertType,
|
||||||
|
assertScalarType,
|
||||||
|
assertObjectType,
|
||||||
|
assertInterfaceType,
|
||||||
|
assertUnionType,
|
||||||
|
assertEnumType,
|
||||||
|
assertInputObjectType,
|
||||||
|
assertListType,
|
||||||
|
assertNonNullType,
|
||||||
|
assertInputType,
|
||||||
|
assertOutputType,
|
||||||
|
assertLeafType,
|
||||||
|
assertCompositeType,
|
||||||
|
assertAbstractType,
|
||||||
|
assertWrappingType,
|
||||||
|
assertNullableType,
|
||||||
|
assertNamedType,
|
||||||
|
// Un-modifiers
|
||||||
|
getNullableType,
|
||||||
|
getNamedType,
|
||||||
|
// Definitions
|
||||||
|
GraphQLScalarType,
|
||||||
|
GraphQLObjectType,
|
||||||
|
GraphQLInterfaceType,
|
||||||
|
GraphQLUnionType,
|
||||||
|
GraphQLEnumType,
|
||||||
|
GraphQLInputObjectType,
|
||||||
|
// Type Wrappers
|
||||||
|
GraphQLList,
|
||||||
|
GraphQLNonNull,
|
||||||
|
// type
|
||||||
|
GraphQLType,
|
||||||
|
GraphQLInputType,
|
||||||
|
GraphQLOutputType,
|
||||||
|
GraphQLLeafType,
|
||||||
|
GraphQLCompositeType,
|
||||||
|
GraphQLAbstractType,
|
||||||
|
GraphQLWrappingType,
|
||||||
|
GraphQLNullableType,
|
||||||
|
GraphQLNamedType,
|
||||||
|
Thunk,
|
||||||
|
GraphQLArgument,
|
||||||
|
GraphQLArgumentConfig,
|
||||||
|
GraphQLEnumTypeConfig,
|
||||||
|
GraphQLEnumValue,
|
||||||
|
GraphQLEnumValueConfig,
|
||||||
|
GraphQLEnumValueConfigMap,
|
||||||
|
GraphQLField,
|
||||||
|
GraphQLFieldConfig,
|
||||||
|
GraphQLFieldConfigArgumentMap,
|
||||||
|
GraphQLFieldConfigMap,
|
||||||
|
GraphQLFieldMap,
|
||||||
|
GraphQLFieldResolver,
|
||||||
|
GraphQLInputField,
|
||||||
|
GraphQLInputFieldConfig,
|
||||||
|
GraphQLInputFieldConfigMap,
|
||||||
|
GraphQLInputFieldMap,
|
||||||
|
GraphQLInputObjectTypeConfig,
|
||||||
|
GraphQLInterfaceTypeConfig,
|
||||||
|
GraphQLIsTypeOfFn,
|
||||||
|
GraphQLObjectTypeConfig,
|
||||||
|
GraphQLResolveInfo,
|
||||||
|
ResponsePath,
|
||||||
|
GraphQLScalarTypeConfig,
|
||||||
|
GraphQLTypeResolver,
|
||||||
|
GraphQLUnionTypeConfig,
|
||||||
|
GraphQLScalarSerializer,
|
||||||
|
GraphQLScalarValueParser,
|
||||||
|
GraphQLScalarLiteralParser,
|
||||||
|
} from "./definition";
|
||||||
|
|
||||||
|
export {
|
||||||
|
// Predicate
|
||||||
|
isDirective,
|
||||||
|
// Directives Definition
|
||||||
|
GraphQLDirective,
|
||||||
|
// Built-in Directives defined by the Spec
|
||||||
|
isSpecifiedDirective,
|
||||||
|
specifiedDirectives,
|
||||||
|
GraphQLIncludeDirective,
|
||||||
|
GraphQLSkipDirective,
|
||||||
|
GraphQLDeprecatedDirective,
|
||||||
|
// Constant Deprecation Reason
|
||||||
|
DEFAULT_DEPRECATION_REASON,
|
||||||
|
// type
|
||||||
|
GraphQLDirectiveConfig,
|
||||||
|
} from "./directives";
|
||||||
|
|
||||||
|
// Common built-in scalar instances.
|
||||||
|
export {
|
||||||
|
isSpecifiedScalarType,
|
||||||
|
specifiedScalarTypes,
|
||||||
|
GraphQLInt,
|
||||||
|
GraphQLFloat,
|
||||||
|
GraphQLString,
|
||||||
|
GraphQLBoolean,
|
||||||
|
GraphQLID,
|
||||||
|
} from "./scalars";
|
||||||
|
|
||||||
|
export {
|
||||||
|
// "Enum" of Type Kinds
|
||||||
|
TypeKind,
|
||||||
|
// GraphQL Types for introspection.
|
||||||
|
isIntrospectionType,
|
||||||
|
introspectionTypes,
|
||||||
|
__Schema,
|
||||||
|
__Directive,
|
||||||
|
__DirectiveLocation,
|
||||||
|
__Type,
|
||||||
|
__Field,
|
||||||
|
__InputValue,
|
||||||
|
__EnumValue,
|
||||||
|
__TypeKind,
|
||||||
|
// Meta-field definitions.
|
||||||
|
SchemaMetaFieldDef,
|
||||||
|
TypeMetaFieldDef,
|
||||||
|
TypeNameMetaFieldDef,
|
||||||
|
} from "./introspection";
|
||||||
|
|
||||||
|
export { validateSchema, assertValidSchema } from "./validate";
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
import {
|
||||||
|
GraphQLScalarType,
|
||||||
|
GraphQLObjectType,
|
||||||
|
GraphQLInterfaceType,
|
||||||
|
GraphQLUnionType,
|
||||||
|
GraphQLEnumType,
|
||||||
|
GraphQLInputObjectType,
|
||||||
|
GraphQLList,
|
||||||
|
GraphQLNonNull,
|
||||||
|
} from "./definition";
|
||||||
|
import { GraphQLField } from "./definition";
|
||||||
|
|
||||||
|
export const __Schema: GraphQLObjectType;
|
||||||
|
export const __Directive: GraphQLObjectType;
|
||||||
|
export const __DirectiveLocation: GraphQLEnumType;
|
||||||
|
export const __Type: GraphQLObjectType;
|
||||||
|
export const __Field: GraphQLObjectType;
|
||||||
|
export const __InputValue: GraphQLObjectType;
|
||||||
|
export const __EnumValue: GraphQLObjectType;
|
||||||
|
|
||||||
|
export const TypeKind: {
|
||||||
|
SCALAR: "SCALAR";
|
||||||
|
OBJECT: "OBJECT";
|
||||||
|
INTERFACE: "INTERFACE";
|
||||||
|
UNION: "UNION";
|
||||||
|
ENUM: "ENUM";
|
||||||
|
INPUT_OBJECT: "INPUT_OBJECT";
|
||||||
|
LIST: "LIST";
|
||||||
|
NON_NULL: "NON_NULL";
|
||||||
|
};
|
||||||
|
|
||||||
|
export const __TypeKind: GraphQLEnumType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note that these are GraphQLField and not GraphQLFieldConfig,
|
||||||
|
* so the format for args is different.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const SchemaMetaFieldDef: GraphQLField<any, any>;
|
||||||
|
export const TypeMetaFieldDef: GraphQLField<any, any>;
|
||||||
|
export const TypeNameMetaFieldDef: GraphQLField<any, any>;
|
||||||
|
|
||||||
|
export const introspectionTypes: ReadonlyArray<any>;
|
||||||
|
|
||||||
|
export function isIntrospectionType(type: any): boolean;
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { GraphQLScalarType } from "./definition";
|
||||||
|
|
||||||
|
export const GraphQLInt: GraphQLScalarType;
|
||||||
|
export const GraphQLFloat: GraphQLScalarType;
|
||||||
|
export const GraphQLString: GraphQLScalarType;
|
||||||
|
export const GraphQLBoolean: GraphQLScalarType;
|
||||||
|
export const GraphQLID: GraphQLScalarType;
|
||||||
|
|
||||||
|
export const specifiedScalarTypes: ReadonlyArray<GraphQLScalarType>;
|
||||||
|
|
||||||
|
export function isSpecifiedScalarType(type: GraphQLScalarType): boolean;
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import { GraphQLObjectType } from "./definition";
|
||||||
|
import { GraphQLType, GraphQLNamedType, GraphQLAbstractType } from "./definition";
|
||||||
|
import { SchemaDefinitionNode, SchemaExtensionNode } from "../language/ast";
|
||||||
|
import { GraphQLDirective } from "./directives";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if the given value is a GraphQL schema.
|
||||||
|
*/
|
||||||
|
export function isSchema(schema: any): schema is GraphQLSchema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schema Definition
|
||||||
|
*
|
||||||
|
* A Schema is created by supplying the root types of each type of operation,
|
||||||
|
* query and mutation (optional). A schema definition is then supplied to the
|
||||||
|
* validator and executor.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* const MyAppSchema = new GraphQLSchema({
|
||||||
|
* query: MyAppQueryRootType,
|
||||||
|
* mutation: MyAppMutationRootType,
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* Note: If an array of `directives` are provided to GraphQLSchema, that will be
|
||||||
|
* the exact list of directives represented and allowed. If `directives` is not
|
||||||
|
* provided then a default set of the specified directives (e.g. @include and
|
||||||
|
* @skip) will be used. If you wish to provide *additional* directives to these
|
||||||
|
* specified directives, you must explicitly declare them. Example:
|
||||||
|
*
|
||||||
|
* const MyAppSchema = new GraphQLSchema({
|
||||||
|
* ...
|
||||||
|
* directives: specifiedDirectives.concat([ myCustomDirective ]),
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export class GraphQLSchema {
|
||||||
|
astNode: Maybe<SchemaDefinitionNode>;
|
||||||
|
extensionASTNodes: Maybe<ReadonlyArray<SchemaExtensionNode>>;
|
||||||
|
|
||||||
|
constructor(config: GraphQLSchemaConfig);
|
||||||
|
|
||||||
|
getQueryType(): Maybe<GraphQLObjectType>;
|
||||||
|
getMutationType(): Maybe<GraphQLObjectType>;
|
||||||
|
getSubscriptionType(): Maybe<GraphQLObjectType>;
|
||||||
|
getTypeMap(): TypeMap;
|
||||||
|
getType(name: string): Maybe<GraphQLNamedType>;
|
||||||
|
getPossibleTypes(abstractType: GraphQLAbstractType): ReadonlyArray<GraphQLObjectType>;
|
||||||
|
|
||||||
|
isPossibleType(abstractType: GraphQLAbstractType, possibleType: GraphQLObjectType): boolean;
|
||||||
|
|
||||||
|
getDirectives(): ReadonlyArray<GraphQLDirective>;
|
||||||
|
getDirective(name: string): Maybe<GraphQLDirective>;
|
||||||
|
|
||||||
|
toConfig(): GraphQLSchemaConfig & {
|
||||||
|
types: GraphQLNamedType[];
|
||||||
|
directives: GraphQLDirective[];
|
||||||
|
extensionASTNodes: ReadonlyArray<SchemaExtensionNode>;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
type TypeMap = { [key: string]: GraphQLNamedType };
|
||||||
|
|
||||||
|
export interface GraphQLSchemaValidationOptions {
|
||||||
|
/**
|
||||||
|
* When building a schema from a GraphQL service's introspection result, it
|
||||||
|
* might be safe to assume the schema is valid. Set to true to assume the
|
||||||
|
* produced schema is valid.
|
||||||
|
*
|
||||||
|
* Default: false
|
||||||
|
*/
|
||||||
|
assumeValid?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If provided, the schema will consider fields or types with names included
|
||||||
|
* in this list valid, even if they do not adhere to the specification's
|
||||||
|
* schema validation rules.
|
||||||
|
*
|
||||||
|
* This option is provided to ease adoption and will be removed in v15.
|
||||||
|
*/
|
||||||
|
allowedLegacyNames?: Maybe<ReadonlyArray<string>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {
|
||||||
|
query: Maybe<GraphQLObjectType>;
|
||||||
|
mutation?: Maybe<GraphQLObjectType>;
|
||||||
|
subscription?: Maybe<GraphQLObjectType>;
|
||||||
|
types?: Maybe<GraphQLNamedType[]>;
|
||||||
|
directives?: Maybe<GraphQLDirective[]>;
|
||||||
|
astNode?: Maybe<SchemaDefinitionNode>;
|
||||||
|
extensionASTNodes?: Maybe<ReadonlyArray<SchemaExtensionNode>>;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { GraphQLSchema } from "./schema";
|
||||||
|
import { GraphQLError } from "../error/GraphQLError";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements the "Type Validation" sub-sections of the specification's
|
||||||
|
* "Type System" section.
|
||||||
|
*
|
||||||
|
* Validation runs synchronously, returning an array of encountered errors, or
|
||||||
|
* an empty array if no errors were encountered and the Schema is valid.
|
||||||
|
*/
|
||||||
|
export function validateSchema(schema: GraphQLSchema): ReadonlyArray<GraphQLError>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility function which asserts a schema is valid by throwing an error if
|
||||||
|
* it is invalid.
|
||||||
|
*/
|
||||||
|
export function assertValidSchema(schema: GraphQLSchema): void;
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import { GraphQLSchema } from "../type/schema";
|
||||||
|
import {
|
||||||
|
GraphQLOutputType,
|
||||||
|
GraphQLCompositeType,
|
||||||
|
GraphQLInputType,
|
||||||
|
GraphQLField,
|
||||||
|
GraphQLArgument,
|
||||||
|
GraphQLEnumValue,
|
||||||
|
GraphQLType,
|
||||||
|
} from "../type/definition";
|
||||||
|
import { GraphQLDirective } from "../type/directives";
|
||||||
|
import { ASTNode, FieldNode } from "../language/ast";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TypeInfo is a utility class which, given a GraphQL schema, can keep track
|
||||||
|
* of the current field and type definitions at any point in a GraphQL document
|
||||||
|
* AST during a recursive descent by calling `enter(node)` and `leave(node)`.
|
||||||
|
*/
|
||||||
|
export class TypeInfo {
|
||||||
|
constructor(
|
||||||
|
schema: GraphQLSchema,
|
||||||
|
// NOTE: this experimental optional second parameter is only needed in order
|
||||||
|
// to support non-spec-compliant codebases. You should never need to use it.
|
||||||
|
// It may disappear in the future.
|
||||||
|
getFieldDefFn?: getFieldDef,
|
||||||
|
// Initial type may be provided in rare cases to facilitate traversals
|
||||||
|
// beginning somewhere other than documents.
|
||||||
|
initialType?: GraphQLType
|
||||||
|
);
|
||||||
|
|
||||||
|
getType(): Maybe<GraphQLOutputType>;
|
||||||
|
getParentType(): Maybe<GraphQLCompositeType>;
|
||||||
|
getInputType(): Maybe<GraphQLInputType>;
|
||||||
|
getParentInputType(): Maybe<GraphQLInputType>;
|
||||||
|
getFieldDef(): GraphQLField<any, Maybe<any>>;
|
||||||
|
getDefaultValue(): Maybe<any>;
|
||||||
|
getDirective(): Maybe<GraphQLDirective>;
|
||||||
|
getArgument(): Maybe<GraphQLArgument>;
|
||||||
|
getEnumValue(): Maybe<GraphQLEnumValue>;
|
||||||
|
enter(node: ASTNode): any;
|
||||||
|
leave(node: ASTNode): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
type getFieldDef = (
|
||||||
|
schema: GraphQLSchema,
|
||||||
|
parentType: GraphQLType,
|
||||||
|
fieldNode: FieldNode
|
||||||
|
) => Maybe<GraphQLField<any, any>>;
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { GraphQLError } from "../error/GraphQLError";
|
||||||
|
import { ASTNode } from "../language/ast";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upholds the spec rules about naming.
|
||||||
|
*/
|
||||||
|
export function assertValidName(name: string): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an Error if a name is invalid.
|
||||||
|
*/
|
||||||
|
export function isValidNameError(name: string, node?: ASTNode | undefined): GraphQLError | undefined;
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import { ValueNode } from "../language/ast";
|
||||||
|
import { GraphQLInputType } from "../type/definition";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Produces a GraphQL Value AST given a JavaScript value.
|
||||||
|
*
|
||||||
|
* A GraphQL type must be provided, which will be used to interpret different
|
||||||
|
* JavaScript values.
|
||||||
|
*
|
||||||
|
* | JSON Value | GraphQL Value |
|
||||||
|
* | ------------- | -------------------- |
|
||||||
|
* | Object | Input Object |
|
||||||
|
* | Array | List |
|
||||||
|
* | Boolean | Boolean |
|
||||||
|
* | String | String / Enum Value |
|
||||||
|
* | Number | Int / Float |
|
||||||
|
* | Mixed | Enum Value |
|
||||||
|
* | null | NullValue |
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export function astFromValue(value: any, type: GraphQLInputType): Maybe<ValueNode>;
|
||||||
|
|
@ -0,0 +1,95 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import {
|
||||||
|
DocumentNode,
|
||||||
|
Location,
|
||||||
|
StringValueNode,
|
||||||
|
TypeDefinitionNode,
|
||||||
|
NamedTypeNode,
|
||||||
|
DirectiveDefinitionNode,
|
||||||
|
FieldDefinitionNode,
|
||||||
|
InputValueDefinitionNode,
|
||||||
|
EnumValueDefinitionNode,
|
||||||
|
} from "../language/ast";
|
||||||
|
import { GraphQLNamedType, GraphQLFieldConfig, GraphQLInputField, GraphQLEnumValueConfig } from "../type/definition";
|
||||||
|
import { GraphQLDirective } from "../type/directives";
|
||||||
|
import { Source } from "../language/source";
|
||||||
|
import { GraphQLSchema, GraphQLSchemaValidationOptions } from "../type/schema";
|
||||||
|
import { ParseOptions } from "../language/parser";
|
||||||
|
import { dedentBlockStringValue } from "../language/blockString";
|
||||||
|
|
||||||
|
interface BuildSchemaOptions extends GraphQLSchemaValidationOptions {
|
||||||
|
/**
|
||||||
|
* Descriptions are defined as preceding string literals, however an older
|
||||||
|
* experimental version of the SDL supported preceding comments as
|
||||||
|
* descriptions. Set to true to enable this deprecated behavior.
|
||||||
|
* This option is provided to ease adoption and will be removed in v16.
|
||||||
|
*
|
||||||
|
* Default: false
|
||||||
|
*/
|
||||||
|
commentDescriptions?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to true to assume the SDL is valid.
|
||||||
|
*
|
||||||
|
* Default: false
|
||||||
|
*/
|
||||||
|
assumeValidSDL?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This takes the ast of a schema document produced by the parse function in
|
||||||
|
* src/language/parser.js.
|
||||||
|
*
|
||||||
|
* If no schema definition is provided, then it will look for types named Query
|
||||||
|
* and Mutation.
|
||||||
|
*
|
||||||
|
* Given that AST it constructs a GraphQLSchema. The resulting schema
|
||||||
|
* has no resolve methods, so execution will use default resolvers.
|
||||||
|
*
|
||||||
|
* Accepts options as a second argument:
|
||||||
|
*
|
||||||
|
* - commentDescriptions:
|
||||||
|
* Provide true to use preceding comments as the description.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export function buildASTSchema(documentAST: DocumentNode, options?: BuildSchemaOptions): GraphQLSchema;
|
||||||
|
|
||||||
|
type TypeDefinitionsMap = { [key: string]: TypeDefinitionNode };
|
||||||
|
type TypeResolver = (typeRef: NamedTypeNode) => GraphQLNamedType;
|
||||||
|
|
||||||
|
export class ASTDefinitionBuilder {
|
||||||
|
constructor(typeDefinitionsMap: TypeDefinitionsMap, options: Maybe<BuildSchemaOptions>, resolveType: TypeResolver);
|
||||||
|
|
||||||
|
buildTypes(nodes: ReadonlyArray<NamedTypeNode | TypeDefinitionNode>): Array<GraphQLNamedType>;
|
||||||
|
|
||||||
|
buildType(node: NamedTypeNode | TypeDefinitionNode): GraphQLNamedType;
|
||||||
|
|
||||||
|
buildDirective(directiveNode: DirectiveDefinitionNode): GraphQLDirective;
|
||||||
|
|
||||||
|
buildField(field: FieldDefinitionNode): GraphQLFieldConfig<any, any>;
|
||||||
|
|
||||||
|
buildInputField(value: InputValueDefinitionNode): GraphQLInputField;
|
||||||
|
|
||||||
|
buildEnumValue(value: EnumValueDefinitionNode): GraphQLEnumValueConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given an ast node, returns its string description.
|
||||||
|
* @deprecated: provided to ease adoption and will be removed in v16.
|
||||||
|
*
|
||||||
|
* Accepts options as a second argument:
|
||||||
|
*
|
||||||
|
* - commentDescriptions:
|
||||||
|
* Provide true to use preceding comments as the description.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export function getDescription(
|
||||||
|
node: { readonly description?: StringValueNode; readonly loc?: Location },
|
||||||
|
options: Maybe<BuildSchemaOptions>
|
||||||
|
): string | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A helper function to build a GraphQLSchema directly from a source
|
||||||
|
* document.
|
||||||
|
*/
|
||||||
|
export function buildSchema(source: string | Source, options?: BuildSchemaOptions & ParseOptions): GraphQLSchema;
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { IntrospectionQuery } from "./introspectionQuery";
|
||||||
|
import { GraphQLSchema, GraphQLSchemaValidationOptions } from "../type/schema";
|
||||||
|
|
||||||
|
interface Options extends GraphQLSchemaValidationOptions {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a GraphQLSchema for use by client tools.
|
||||||
|
*
|
||||||
|
* Given the result of a client running the introspection query, creates and
|
||||||
|
* returns a GraphQLSchema instance which can be then used with all graphql-js
|
||||||
|
* tools, but cannot be used to execute a query, as introspection does not
|
||||||
|
* represent the "resolver", "parse" or "serialize" functions or any other
|
||||||
|
* server-internal mechanisms.
|
||||||
|
*
|
||||||
|
* This function expects a complete introspection result. Don't forget to check
|
||||||
|
* the "errors" field of a server response before calling this function.
|
||||||
|
*/
|
||||||
|
export function buildClientSchema(introspection: IntrospectionQuery, options?: Options): GraphQLSchema;
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { GraphQLError } from "../error/GraphQLError";
|
||||||
|
import { ASTNode } from "../language/ast";
|
||||||
|
import { GraphQLInputType } from "../type/definition";
|
||||||
|
|
||||||
|
interface CoercedValue {
|
||||||
|
readonly errors: ReadonlyArray<GraphQLError> | undefined;
|
||||||
|
readonly value: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Path {
|
||||||
|
readonly prev: Path | undefined;
|
||||||
|
readonly key: string | number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Coerces a JavaScript value given a GraphQL Type.
|
||||||
|
*
|
||||||
|
* Returns either a value which is valid for the provided type or a list of
|
||||||
|
* encountered coercion errors.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export function coerceValue(value: any, type: GraphQLInputType, blameNode?: ASTNode, path?: Path): CoercedValue;
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { DocumentNode } from "../language/ast";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provided a collection of ASTs, presumably each from different files,
|
||||||
|
* concatenate the ASTs together into batched AST, useful for validating many
|
||||||
|
* GraphQL source files which together represent one conceptual application.
|
||||||
|
*/
|
||||||
|
export function concatAST(asts: ReadonlyArray<DocumentNode>): DocumentNode;
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
import { DocumentNode } from "../language/ast";
|
||||||
|
import { GraphQLSchema } from "../type/schema";
|
||||||
|
import { GraphQLSchemaValidationOptions } from "../type/schema";
|
||||||
|
|
||||||
|
interface Options extends GraphQLSchemaValidationOptions {
|
||||||
|
/**
|
||||||
|
* Descriptions are defined as preceding string literals, however an older
|
||||||
|
* experimental version of the SDL supported preceding comments as
|
||||||
|
* descriptions. Set to true to enable this deprecated behavior.
|
||||||
|
* This option is provided to ease adoption and will be removed in v16.
|
||||||
|
*
|
||||||
|
* Default: false
|
||||||
|
*/
|
||||||
|
commentDescriptions?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to true to assume the SDL is valid.
|
||||||
|
*
|
||||||
|
* Default: false
|
||||||
|
*/
|
||||||
|
assumeValidSDL?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Produces a new schema given an existing schema and a document which may
|
||||||
|
* contain GraphQL type extensions and definitions. The original schema will
|
||||||
|
* remain unaltered.
|
||||||
|
*
|
||||||
|
* Because a schema represents a graph of references, a schema cannot be
|
||||||
|
* extended without effectively making an entire copy. We do not know until it's
|
||||||
|
* too late if subgraphs remain unchanged.
|
||||||
|
*
|
||||||
|
* This algorithm copies the provided schema, applying extensions while
|
||||||
|
* producing the copy. The original schema remains unaltered.
|
||||||
|
*
|
||||||
|
* Accepts options as a third argument:
|
||||||
|
*
|
||||||
|
* - commentDescriptions:
|
||||||
|
* Provide true to use preceding comments as the description.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export function extendSchema(schema: GraphQLSchema, documentAST: DocumentNode, options?: Options): GraphQLSchema;
|
||||||
|
|
@ -0,0 +1,160 @@
|
||||||
|
import {
|
||||||
|
getNamedType,
|
||||||
|
GraphQLScalarType,
|
||||||
|
GraphQLEnumType,
|
||||||
|
GraphQLInputObjectType,
|
||||||
|
GraphQLInterfaceType,
|
||||||
|
GraphQLObjectType,
|
||||||
|
GraphQLUnionType,
|
||||||
|
GraphQLNamedType,
|
||||||
|
} from "../type/definition";
|
||||||
|
import { GraphQLDirective } from "../type/directives";
|
||||||
|
import { GraphQLSchema } from "../type/schema";
|
||||||
|
import { DirectiveLocationEnum } from "../language/directiveLocation";
|
||||||
|
|
||||||
|
export const BreakingChangeType: _BreakingChangeType;
|
||||||
|
|
||||||
|
// @internal
|
||||||
|
type _BreakingChangeType = {
|
||||||
|
FIELD_CHANGED_KIND: "FIELD_CHANGED_KIND";
|
||||||
|
FIELD_REMOVED: "FIELD_REMOVED";
|
||||||
|
TYPE_CHANGED_KIND: "TYPE_CHANGED_KIND";
|
||||||
|
TYPE_REMOVED: "TYPE_REMOVED";
|
||||||
|
TYPE_REMOVED_FROM_UNION: "TYPE_REMOVED_FROM_UNION";
|
||||||
|
VALUE_REMOVED_FROM_ENUM: "VALUE_REMOVED_FROM_ENUM";
|
||||||
|
ARG_REMOVED: "ARG_REMOVED";
|
||||||
|
ARG_CHANGED_KIND: "ARG_CHANGED_KIND";
|
||||||
|
REQUIRED_ARG_ADDED: "REQUIRED_ARG_ADDED";
|
||||||
|
REQUIRED_INPUT_FIELD_ADDED: "REQUIRED_INPUT_FIELD_ADDED";
|
||||||
|
INTERFACE_REMOVED_FROM_OBJECT: "INTERFACE_REMOVED_FROM_OBJECT";
|
||||||
|
DIRECTIVE_REMOVED: "DIRECTIVE_REMOVED";
|
||||||
|
DIRECTIVE_ARG_REMOVED: "DIRECTIVE_ARG_REMOVED";
|
||||||
|
DIRECTIVE_LOCATION_REMOVED: "DIRECTIVE_LOCATION_REMOVED";
|
||||||
|
REQUIRED_DIRECTIVE_ARG_ADDED: "REQUIRED_DIRECTIVE_ARG_ADDED";
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DangerousChangeType: _DangerousChangeType;
|
||||||
|
|
||||||
|
// @internal
|
||||||
|
type _DangerousChangeType = {
|
||||||
|
ARG_DEFAULT_VALUE_CHANGE: "ARG_DEFAULT_VALUE_CHANGE";
|
||||||
|
VALUE_ADDED_TO_ENUM: "VALUE_ADDED_TO_ENUM";
|
||||||
|
INTERFACE_ADDED_TO_OBJECT: "INTERFACE_ADDED_TO_OBJECT";
|
||||||
|
TYPE_ADDED_TO_UNION: "TYPE_ADDED_TO_UNION";
|
||||||
|
OPTIONAL_INPUT_FIELD_ADDED: "OPTIONAL_INPUT_FIELD_ADDED";
|
||||||
|
OPTIONAL_ARG_ADDED: "OPTIONAL_ARG_ADDED";
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface BreakingChange {
|
||||||
|
type: keyof _BreakingChangeType;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DangerousChange {
|
||||||
|
type: keyof _DangerousChangeType;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given two schemas, returns an Array containing descriptions of all the types
|
||||||
|
* of breaking changes covered by the other functions down below.
|
||||||
|
*/
|
||||||
|
export function findBreakingChanges(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Array<BreakingChange>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given two schemas, returns an Array containing descriptions of all the types
|
||||||
|
* of potentially dangerous changes covered by the other functions down below.
|
||||||
|
*/
|
||||||
|
export function findDangerousChanges(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Array<DangerousChange>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given two schemas, returns an Array containing descriptions of any breaking
|
||||||
|
* changes in the newSchema related to removing an entire type.
|
||||||
|
*/
|
||||||
|
export function findRemovedTypes(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Array<BreakingChange>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given two schemas, returns an Array containing descriptions of any breaking
|
||||||
|
* changes in the newSchema related to changing the type of a type.
|
||||||
|
*/
|
||||||
|
export function findTypesThatChangedKind(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Array<BreakingChange>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given two schemas, returns an Array containing descriptions of any
|
||||||
|
* breaking or dangerous changes in the newSchema related to arguments
|
||||||
|
* (such as removal or change of type of an argument, or a change in an
|
||||||
|
* argument's default value).
|
||||||
|
*/
|
||||||
|
export function findArgChanges(
|
||||||
|
oldSchema: GraphQLSchema,
|
||||||
|
newSchema: GraphQLSchema
|
||||||
|
): {
|
||||||
|
breakingChanges: Array<BreakingChange>;
|
||||||
|
dangerousChanges: Array<DangerousChange>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function findFieldsThatChangedTypeOnObjectOrInterfaceTypes(
|
||||||
|
oldSchema: GraphQLSchema,
|
||||||
|
newSchema: GraphQLSchema
|
||||||
|
): Array<BreakingChange>;
|
||||||
|
|
||||||
|
export function findFieldsThatChangedTypeOnInputObjectTypes(
|
||||||
|
oldSchema: GraphQLSchema,
|
||||||
|
newSchema: GraphQLSchema
|
||||||
|
): {
|
||||||
|
breakingChanges: Array<BreakingChange>;
|
||||||
|
dangerousChanges: Array<DangerousChange>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given two schemas, returns an Array containing descriptions of any breaking
|
||||||
|
* changes in the newSchema related to removing types from a union type.
|
||||||
|
*/
|
||||||
|
export function findTypesRemovedFromUnions(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Array<BreakingChange>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given two schemas, returns an Array containing descriptions of any dangerous
|
||||||
|
* changes in the newSchema related to adding types to a union type.
|
||||||
|
*/
|
||||||
|
export function findTypesAddedToUnions(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Array<DangerousChange>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given two schemas, returns an Array containing descriptions of any breaking
|
||||||
|
* changes in the newSchema related to removing values from an enum type.
|
||||||
|
*/
|
||||||
|
export function findValuesRemovedFromEnums(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Array<BreakingChange>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given two schemas, returns an Array containing descriptions of any dangerous
|
||||||
|
* changes in the newSchema related to adding values to an enum type.
|
||||||
|
*/
|
||||||
|
export function findValuesAddedToEnums(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Array<DangerousChange>;
|
||||||
|
|
||||||
|
export function findInterfacesRemovedFromObjectTypes(
|
||||||
|
oldSchema: GraphQLSchema,
|
||||||
|
newSchema: GraphQLSchema
|
||||||
|
): Array<BreakingChange>;
|
||||||
|
|
||||||
|
export function findInterfacesAddedToObjectTypes(
|
||||||
|
oldSchema: GraphQLSchema,
|
||||||
|
newSchema: GraphQLSchema
|
||||||
|
): Array<DangerousChange>;
|
||||||
|
|
||||||
|
export function findRemovedDirectives(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Array<BreakingChange>;
|
||||||
|
|
||||||
|
export function findRemovedDirectiveArgs(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Array<BreakingChange>;
|
||||||
|
|
||||||
|
export function findAddedNonNullDirectiveArgs(
|
||||||
|
oldSchema: GraphQLSchema,
|
||||||
|
newSchema: GraphQLSchema
|
||||||
|
): Array<BreakingChange>;
|
||||||
|
|
||||||
|
export function findRemovedLocationsForDirective(
|
||||||
|
oldDirective: GraphQLDirective,
|
||||||
|
newDirective: GraphQLDirective
|
||||||
|
): Array<DirectiveLocationEnum>;
|
||||||
|
|
||||||
|
export function findRemovedDirectiveLocations(
|
||||||
|
oldSchema: GraphQLSchema,
|
||||||
|
newSchema: GraphQLSchema
|
||||||
|
): Array<BreakingChange>;
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
import { GraphQLSchema } from "../type/schema";
|
||||||
|
import { DocumentNode } from "../language/ast";
|
||||||
|
import { GraphQLError } from "../error/GraphQLError";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A validation rule which reports deprecated usages.
|
||||||
|
*
|
||||||
|
* Returns a list of GraphQLError instances describing each deprecated use.
|
||||||
|
*/
|
||||||
|
export function findDeprecatedUsages(schema: GraphQLSchema, ast: DocumentNode): GraphQLError[];
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import { DocumentNode, OperationDefinitionNode } from "../language/ast";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an operation AST given a document AST and optionally an operation
|
||||||
|
* name. If a name is not provided, an operation is only returned if only one is
|
||||||
|
* provided in the document.
|
||||||
|
*/
|
||||||
|
export function getOperationAST(
|
||||||
|
documentAST: DocumentNode,
|
||||||
|
operationName: Maybe<string>
|
||||||
|
): Maybe<OperationDefinitionNode>;
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { GraphQLSchema } from "../type/schema";
|
||||||
|
import { OperationDefinitionNode, OperationTypeDefinitionNode } from "../language/ast";
|
||||||
|
import { GraphQLObjectType } from "../type/definition";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the root type of the operation from the schema.
|
||||||
|
*/
|
||||||
|
export function getOperationRootType(
|
||||||
|
schema: GraphQLSchema,
|
||||||
|
operation: OperationDefinitionNode | OperationTypeDefinitionNode
|
||||||
|
): GraphQLObjectType;
|
||||||
|
|
@ -0,0 +1,112 @@
|
||||||
|
// The GraphQL query recommended for a full schema introspection.
|
||||||
|
export {
|
||||||
|
getIntrospectionQuery,
|
||||||
|
// @deprecated, use getIntrospectionQuery() - will be removed in v15
|
||||||
|
introspectionQuery,
|
||||||
|
} from "./introspectionQuery";
|
||||||
|
|
||||||
|
export {
|
||||||
|
IntrospectionOptions,
|
||||||
|
IntrospectionQuery,
|
||||||
|
IntrospectionSchema,
|
||||||
|
IntrospectionType,
|
||||||
|
IntrospectionInputType,
|
||||||
|
IntrospectionOutputType,
|
||||||
|
IntrospectionScalarType,
|
||||||
|
IntrospectionObjectType,
|
||||||
|
IntrospectionInterfaceType,
|
||||||
|
IntrospectionUnionType,
|
||||||
|
IntrospectionEnumType,
|
||||||
|
IntrospectionInputObjectType,
|
||||||
|
IntrospectionTypeRef,
|
||||||
|
IntrospectionInputTypeRef,
|
||||||
|
IntrospectionOutputTypeRef,
|
||||||
|
IntrospectionNamedTypeRef,
|
||||||
|
IntrospectionListTypeRef,
|
||||||
|
IntrospectionNonNullTypeRef,
|
||||||
|
IntrospectionField,
|
||||||
|
IntrospectionInputValue,
|
||||||
|
IntrospectionEnumValue,
|
||||||
|
IntrospectionDirective,
|
||||||
|
} from "./introspectionQuery";
|
||||||
|
|
||||||
|
// Gets the target Operation from a Document
|
||||||
|
export { getOperationAST } from "./getOperationAST";
|
||||||
|
|
||||||
|
// Gets the Type for the target Operation AST.
|
||||||
|
export { getOperationRootType } from "./getOperationRootType";
|
||||||
|
|
||||||
|
// Convert a GraphQLSchema to an IntrospectionQuery
|
||||||
|
export { introspectionFromSchema } from "./introspectionFromSchema";
|
||||||
|
|
||||||
|
// Build a GraphQLSchema from an introspection result.
|
||||||
|
export { buildClientSchema } from "./buildClientSchema";
|
||||||
|
|
||||||
|
// Build a GraphQLSchema from GraphQL Schema language.
|
||||||
|
export {
|
||||||
|
buildASTSchema,
|
||||||
|
buildSchema,
|
||||||
|
// @deprecated: Get the description from a schema AST node and supports legacy
|
||||||
|
// syntax for specifying descriptions - will be removed in v16
|
||||||
|
getDescription,
|
||||||
|
BuildSchemaOptions,
|
||||||
|
} from "./buildASTSchema";
|
||||||
|
|
||||||
|
// Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST.
|
||||||
|
export { extendSchema } from "./extendSchema";
|
||||||
|
|
||||||
|
// Sort a GraphQLSchema.
|
||||||
|
export { lexicographicSortSchema } from "./lexicographicSortSchema";
|
||||||
|
|
||||||
|
// Print a GraphQLSchema to GraphQL Schema language.
|
||||||
|
export { printSchema, printType, printIntrospectionSchema } from "./schemaPrinter";
|
||||||
|
|
||||||
|
// Create a GraphQLType from a GraphQL language AST.
|
||||||
|
export { typeFromAST } from "./typeFromAST";
|
||||||
|
|
||||||
|
// Create a JavaScript value from a GraphQL language AST with a type.
|
||||||
|
export { valueFromAST } from "./valueFromAST";
|
||||||
|
|
||||||
|
// Create a JavaScript value from a GraphQL language AST without a type.
|
||||||
|
export { valueFromASTUntyped } from "./valueFromASTUntyped";
|
||||||
|
|
||||||
|
// Create a GraphQL language AST from a JavaScript value.
|
||||||
|
export { astFromValue } from "./astFromValue";
|
||||||
|
|
||||||
|
// A helper to use within recursive-descent visitors which need to be aware of
|
||||||
|
// the GraphQL type system.
|
||||||
|
export { TypeInfo } from "./TypeInfo";
|
||||||
|
|
||||||
|
// Coerces a JavaScript value to a GraphQL type, or produces errors.
|
||||||
|
export { coerceValue } from "./coerceValue";
|
||||||
|
|
||||||
|
// @deprecated use coerceValue - will be removed in v15
|
||||||
|
export { isValidJSValue } from "./isValidJSValue";
|
||||||
|
|
||||||
|
// @deprecated use validation - will be removed in v15
|
||||||
|
export { isValidLiteralValue } from "./isValidLiteralValue";
|
||||||
|
|
||||||
|
// Concatenates multiple AST together.
|
||||||
|
export { concatAST } from "./concatAST";
|
||||||
|
|
||||||
|
// Separates an AST into an AST per Operation.
|
||||||
|
export { separateOperations } from "./separateOperations";
|
||||||
|
|
||||||
|
// Comparators for types
|
||||||
|
export { isEqualType, isTypeSubTypeOf, doTypesOverlap } from "./typeComparators";
|
||||||
|
|
||||||
|
// Asserts that a string is a valid GraphQL name
|
||||||
|
export { assertValidName, isValidNameError } from "./assertValidName";
|
||||||
|
|
||||||
|
// Compares two GraphQLSchemas and detects breaking changes.
|
||||||
|
export {
|
||||||
|
BreakingChangeType,
|
||||||
|
DangerousChangeType,
|
||||||
|
findBreakingChanges,
|
||||||
|
findDangerousChanges,
|
||||||
|
BreakingChange,
|
||||||
|
DangerousChange,
|
||||||
|
} from "./findBreakingChanges";
|
||||||
|
|
||||||
|
// Report all deprecated usage within a GraphQL document.
|
||||||
|
export { findDeprecatedUsages } from "./findDeprecatedUsages";
|
||||||
13
node_modules/@types/graphql/utilities/introspectionFromSchema.d.ts
generated
vendored
Normal file
13
node_modules/@types/graphql/utilities/introspectionFromSchema.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { GraphQLSchema } from "../type/schema";
|
||||||
|
import { IntrospectionQuery, IntrospectionOptions } from "./introspectionQuery";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build an IntrospectionQuery from a GraphQLSchema
|
||||||
|
*
|
||||||
|
* IntrospectionQuery is useful for utilities that care about type and field
|
||||||
|
* relationships, but do not need to traverse through those relationships.
|
||||||
|
*
|
||||||
|
* This is the inverse of buildClientSchema. The primary use case is outside
|
||||||
|
* of the server context, for instance when doing schema comparisons.
|
||||||
|
*/
|
||||||
|
export function introspectionFromSchema(schema: GraphQLSchema, options?: IntrospectionOptions): IntrospectionQuery;
|
||||||
|
|
@ -0,0 +1,149 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import { DirectiveLocationEnum } from "../language/directiveLocation";
|
||||||
|
|
||||||
|
export interface IntrospectionOptions {
|
||||||
|
// Whether to include descriptions in the introspection result.
|
||||||
|
// Default: true
|
||||||
|
descriptions: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getIntrospectionQuery(options?: IntrospectionOptions): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated, call getIntrospectionQuery directly.
|
||||||
|
*
|
||||||
|
* This function will be removed in v15
|
||||||
|
*/
|
||||||
|
export const introspectionQuery: string;
|
||||||
|
|
||||||
|
export interface IntrospectionQuery {
|
||||||
|
readonly __schema: IntrospectionSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IntrospectionSchema {
|
||||||
|
readonly queryType: IntrospectionNamedTypeRef<IntrospectionObjectType>;
|
||||||
|
readonly mutationType: Maybe<IntrospectionNamedTypeRef<IntrospectionObjectType>>;
|
||||||
|
readonly subscriptionType: Maybe<IntrospectionNamedTypeRef<IntrospectionObjectType>>;
|
||||||
|
readonly types: ReadonlyArray<IntrospectionType>;
|
||||||
|
readonly directives: ReadonlyArray<IntrospectionDirective>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type IntrospectionType =
|
||||||
|
| IntrospectionScalarType
|
||||||
|
| IntrospectionObjectType
|
||||||
|
| IntrospectionInterfaceType
|
||||||
|
| IntrospectionUnionType
|
||||||
|
| IntrospectionEnumType
|
||||||
|
| IntrospectionInputObjectType;
|
||||||
|
|
||||||
|
export type IntrospectionOutputType =
|
||||||
|
| IntrospectionScalarType
|
||||||
|
| IntrospectionObjectType
|
||||||
|
| IntrospectionInterfaceType
|
||||||
|
| IntrospectionUnionType
|
||||||
|
| IntrospectionEnumType;
|
||||||
|
|
||||||
|
export type IntrospectionInputType = IntrospectionScalarType | IntrospectionEnumType | IntrospectionInputObjectType;
|
||||||
|
|
||||||
|
export interface IntrospectionScalarType {
|
||||||
|
readonly kind: "SCALAR";
|
||||||
|
readonly name: string;
|
||||||
|
readonly description?: Maybe<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IntrospectionObjectType {
|
||||||
|
readonly kind: "OBJECT";
|
||||||
|
readonly name: string;
|
||||||
|
readonly description?: Maybe<string>;
|
||||||
|
readonly fields: ReadonlyArray<IntrospectionField>;
|
||||||
|
readonly interfaces: ReadonlyArray<IntrospectionNamedTypeRef<IntrospectionInterfaceType>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IntrospectionInterfaceType {
|
||||||
|
readonly kind: "INTERFACE";
|
||||||
|
readonly name: string;
|
||||||
|
readonly description?: Maybe<string>;
|
||||||
|
readonly fields: ReadonlyArray<IntrospectionField>;
|
||||||
|
readonly possibleTypes: ReadonlyArray<IntrospectionNamedTypeRef<IntrospectionObjectType>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IntrospectionUnionType {
|
||||||
|
readonly kind: "UNION";
|
||||||
|
readonly name: string;
|
||||||
|
readonly description?: Maybe<string>;
|
||||||
|
readonly possibleTypes: ReadonlyArray<IntrospectionNamedTypeRef<IntrospectionObjectType>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IntrospectionEnumType {
|
||||||
|
readonly kind: "ENUM";
|
||||||
|
readonly name: string;
|
||||||
|
readonly description?: Maybe<string>;
|
||||||
|
readonly enumValues: ReadonlyArray<IntrospectionEnumValue>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IntrospectionInputObjectType {
|
||||||
|
readonly kind: "INPUT_OBJECT";
|
||||||
|
readonly name: string;
|
||||||
|
readonly description?: Maybe<string>;
|
||||||
|
readonly inputFields: ReadonlyArray<IntrospectionInputValue>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IntrospectionListTypeRef<T extends IntrospectionTypeRef = IntrospectionTypeRef> {
|
||||||
|
readonly kind: "LIST";
|
||||||
|
readonly ofType: T;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IntrospectionNonNullTypeRef<T extends IntrospectionTypeRef = IntrospectionTypeRef> {
|
||||||
|
readonly kind: "NON_NULL";
|
||||||
|
readonly ofType: T;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type IntrospectionTypeRef =
|
||||||
|
| IntrospectionNamedTypeRef<IntrospectionType>
|
||||||
|
| IntrospectionListTypeRef<any>
|
||||||
|
| IntrospectionNonNullTypeRef<IntrospectionNamedTypeRef<IntrospectionType> | IntrospectionListTypeRef<any>>;
|
||||||
|
|
||||||
|
export type IntrospectionOutputTypeRef =
|
||||||
|
| IntrospectionNamedTypeRef<IntrospectionOutputType>
|
||||||
|
| IntrospectionListTypeRef<any>
|
||||||
|
| IntrospectionNonNullTypeRef<IntrospectionNamedTypeRef<IntrospectionOutputType> | IntrospectionListTypeRef<any>>;
|
||||||
|
|
||||||
|
export type IntrospectionInputTypeRef =
|
||||||
|
| IntrospectionNamedTypeRef<IntrospectionInputType>
|
||||||
|
| IntrospectionListTypeRef<any>
|
||||||
|
| IntrospectionNonNullTypeRef<IntrospectionNamedTypeRef<IntrospectionInputType> | IntrospectionListTypeRef<any>>;
|
||||||
|
|
||||||
|
export interface IntrospectionNamedTypeRef<T extends IntrospectionType = IntrospectionType> {
|
||||||
|
readonly kind: T["kind"];
|
||||||
|
readonly name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IntrospectionField {
|
||||||
|
readonly name: string;
|
||||||
|
readonly description?: Maybe<string>;
|
||||||
|
readonly args: ReadonlyArray<IntrospectionInputValue>;
|
||||||
|
readonly type: IntrospectionOutputTypeRef;
|
||||||
|
readonly isDeprecated: boolean;
|
||||||
|
readonly deprecationReason?: Maybe<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IntrospectionInputValue {
|
||||||
|
readonly name: string;
|
||||||
|
readonly description?: Maybe<string>;
|
||||||
|
readonly type: IntrospectionInputTypeRef;
|
||||||
|
readonly defaultValue?: Maybe<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IntrospectionEnumValue {
|
||||||
|
readonly name: string;
|
||||||
|
readonly description?: Maybe<string>;
|
||||||
|
readonly isDeprecated: boolean;
|
||||||
|
readonly deprecationReason?: Maybe<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IntrospectionDirective {
|
||||||
|
readonly name: string;
|
||||||
|
readonly description?: Maybe<string>;
|
||||||
|
readonly locations: ReadonlyArray<DirectiveLocationEnum>;
|
||||||
|
readonly args: ReadonlyArray<IntrospectionInputValue>;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { GraphQLInputType } from "../type/definition";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated. Use coerceValue() directly for richer information.
|
||||||
|
*
|
||||||
|
* This function will be removed in v15
|
||||||
|
*/
|
||||||
|
export function isValidJSValue(value: any, type: GraphQLInputType): string[];
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { GraphQLError } from "../error/GraphQLError";
|
||||||
|
import { ValueNode } from "../language/ast";
|
||||||
|
import { GraphQLInputType } from "../type/definition";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility which determines if a value literal node is valid for an input type.
|
||||||
|
*
|
||||||
|
* Deprecated. Rely on validation for documents containing literal values.
|
||||||
|
*
|
||||||
|
* This function will be removed in v15
|
||||||
|
*/
|
||||||
|
export function isValidLiteralValue(type: GraphQLInputType, valueNode: ValueNode): ReadonlyArray<GraphQLError>;
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
import { GraphQLSchema } from "../type/schema";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort GraphQLSchema.
|
||||||
|
*/
|
||||||
|
export function lexicographicSortSchema(schema: GraphQLSchema): GraphQLSchema;
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { GraphQLSchema } from "../type/schema";
|
||||||
|
import { GraphQLType, GraphQLNamedType } from "../type/definition";
|
||||||
|
|
||||||
|
export interface Options {
|
||||||
|
/**
|
||||||
|
* Descriptions are defined as preceding string literals, however an older
|
||||||
|
* experimental version of the SDL supported preceding comments as
|
||||||
|
* descriptions. Set to true to enable this deprecated behavior.
|
||||||
|
* This option is provided to ease adoption and will be removed in v16.
|
||||||
|
*
|
||||||
|
* Default: false
|
||||||
|
*/
|
||||||
|
commentDescriptions?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accepts options as a second argument:
|
||||||
|
*
|
||||||
|
* - commentDescriptions:
|
||||||
|
* Provide true to use preceding comments as the description.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export function printSchema(schema: GraphQLSchema, options?: Options): string;
|
||||||
|
|
||||||
|
export function printIntrospectionSchema(schema: GraphQLSchema, options?: Options): string;
|
||||||
|
|
||||||
|
export function printType(type: GraphQLNamedType, options?: Options): string;
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { DocumentNode, OperationDefinitionNode } from "../language/ast";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* separateOperations accepts a single AST document which may contain many
|
||||||
|
* operations and fragments and returns a collection of AST documents each of
|
||||||
|
* which contains a single operation as well the fragment definitions it
|
||||||
|
* refers to.
|
||||||
|
*/
|
||||||
|
export function separateOperations(documentAST: DocumentNode): { [key: string]: DocumentNode };
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
import { GraphQLType, GraphQLCompositeType, GraphQLAbstractType } from "../type/definition";
|
||||||
|
import { GraphQLSchema } from "../type/schema";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provided two types, return true if the types are equal (invariant).
|
||||||
|
*/
|
||||||
|
export function isEqualType(typeA: GraphQLType, typeB: GraphQLType): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provided a type and a super type, return true if the first type is either
|
||||||
|
* equal or a subset of the second super type (covariant).
|
||||||
|
*/
|
||||||
|
export function isTypeSubTypeOf(schema: GraphQLSchema, maybeSubType: GraphQLType, superType: GraphQLType): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provided two composite types, determine if they "overlap". Two composite
|
||||||
|
* types overlap when the Sets of possible concrete types for each intersect.
|
||||||
|
*
|
||||||
|
* This is often used to determine if a fragment of a given type could possibly
|
||||||
|
* be visited in a context of another type.
|
||||||
|
*
|
||||||
|
* This function is commutative.
|
||||||
|
*/
|
||||||
|
export function doTypesOverlap(
|
||||||
|
schema: GraphQLSchema,
|
||||||
|
typeA: GraphQLCompositeType,
|
||||||
|
typeB: GraphQLCompositeType
|
||||||
|
): boolean;
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { TypeNode, NamedTypeNode, ListTypeNode, NonNullTypeNode } from "../language/ast";
|
||||||
|
import { GraphQLType, GraphQLNullableType, GraphQLNamedType, GraphQLList, GraphQLNonNull } from "../type/definition";
|
||||||
|
import { GraphQLSchema } from "../type/schema";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a Schema and an AST node describing a type, return a GraphQLType
|
||||||
|
* definition which applies to that type. For example, if provided the parsed
|
||||||
|
* AST node for `[User]`, a GraphQLList instance will be returned, containing
|
||||||
|
* the type called "User" found in the schema. If a type called "User" is not
|
||||||
|
* found in the schema, then undefined will be returned.
|
||||||
|
*/
|
||||||
|
export function typeFromAST(schema: GraphQLSchema, typeNode: NamedTypeNode): GraphQLNamedType | undefined;
|
||||||
|
|
||||||
|
export function typeFromAST(schema: GraphQLSchema, typeNode: ListTypeNode): GraphQLList<any> | undefined;
|
||||||
|
|
||||||
|
export function typeFromAST(schema: GraphQLSchema, typeNode: NonNullTypeNode): GraphQLNonNull<any> | undefined;
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import { GraphQLInputType } from "../type/definition";
|
||||||
|
import { ValueNode, VariableNode, ListValueNode, ObjectValueNode } from "../language/ast";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Produces a JavaScript value given a GraphQL Value AST.
|
||||||
|
*
|
||||||
|
* A GraphQL type must be provided, which will be used to interpret different
|
||||||
|
* GraphQL Value literals.
|
||||||
|
*
|
||||||
|
* Returns `undefined` when the value could not be validly coerced according to
|
||||||
|
* the provided type.
|
||||||
|
*
|
||||||
|
* | GraphQL Value | JSON Value |
|
||||||
|
* | -------------------- | ------------- |
|
||||||
|
* | Input Object | Object |
|
||||||
|
* | List | Array |
|
||||||
|
* | Boolean | Boolean |
|
||||||
|
* | String | String |
|
||||||
|
* | Int / Float | Number |
|
||||||
|
* | Enum Value | Mixed |
|
||||||
|
* | NullValue | null |
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export function valueFromAST(
|
||||||
|
valueNode: Maybe<ValueNode>,
|
||||||
|
type: GraphQLInputType,
|
||||||
|
variables?: Maybe<{ [key: string]: any }>
|
||||||
|
): any;
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import { ValueNode } from "../language/ast";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Produces a JavaScript value given a GraphQL Value AST.
|
||||||
|
*
|
||||||
|
* Unlike `valueFromAST()`, no type is provided. The resulting JavaScript value
|
||||||
|
* will reflect the provided GraphQL value AST.
|
||||||
|
*
|
||||||
|
* | GraphQL Value | JavaScript Value |
|
||||||
|
* | -------------------- | ---------------- |
|
||||||
|
* | Input Object | Object |
|
||||||
|
* | List | Array |
|
||||||
|
* | Boolean | Boolean |
|
||||||
|
* | String / Enum | String |
|
||||||
|
* | Int / Float | Number |
|
||||||
|
* | Null | null |
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export function valueFromASTUntyped(valueNode: ValueNode, variables?: Maybe<{ [key: string]: any }>): any;
|
||||||
|
|
@ -0,0 +1,83 @@
|
||||||
|
import Maybe from "../tsutils/Maybe";
|
||||||
|
import { GraphQLError } from "../error";
|
||||||
|
import {
|
||||||
|
DocumentNode,
|
||||||
|
OperationDefinitionNode,
|
||||||
|
VariableNode,
|
||||||
|
SelectionSetNode,
|
||||||
|
FragmentSpreadNode,
|
||||||
|
FragmentDefinitionNode,
|
||||||
|
} from "../language/ast";
|
||||||
|
import { GraphQLSchema } from "../type/schema";
|
||||||
|
import {
|
||||||
|
GraphQLInputType,
|
||||||
|
GraphQLOutputType,
|
||||||
|
GraphQLCompositeType,
|
||||||
|
GraphQLField,
|
||||||
|
GraphQLArgument,
|
||||||
|
} from "../type/definition";
|
||||||
|
import { GraphQLDirective } from "../type/directives";
|
||||||
|
import { TypeInfo } from "../utilities/TypeInfo";
|
||||||
|
import { ASTVisitor } from "../language/visitor";
|
||||||
|
|
||||||
|
type NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode;
|
||||||
|
type VariableUsage = {
|
||||||
|
readonly node: VariableNode;
|
||||||
|
readonly type: Maybe<GraphQLInputType>;
|
||||||
|
readonly defaultValue: Maybe<any>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An instance of this class is passed as the "this" context to all validators,
|
||||||
|
* allowing access to commonly useful contextual information from within a
|
||||||
|
* validation rule.
|
||||||
|
*/
|
||||||
|
export class ASTValidationContext {
|
||||||
|
constructor(ast: DocumentNode);
|
||||||
|
|
||||||
|
reportError(error: GraphQLError): undefined;
|
||||||
|
|
||||||
|
getErrors(): ReadonlyArray<GraphQLError>;
|
||||||
|
|
||||||
|
getDocument(): DocumentNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SDLValidationContext extends ASTValidationContext {
|
||||||
|
constructor(ast: DocumentNode, schema?: Maybe<GraphQLSchema>);
|
||||||
|
|
||||||
|
getSchema(): Maybe<GraphQLSchema>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SDLValidationRule = (context: SDLValidationContext) => ASTVisitor;
|
||||||
|
|
||||||
|
export class ValidationContext extends ASTValidationContext {
|
||||||
|
constructor(schema: GraphQLSchema, ast: DocumentNode, typeInfo: TypeInfo);
|
||||||
|
|
||||||
|
getSchema(): GraphQLSchema;
|
||||||
|
|
||||||
|
getFragment(name: string): Maybe<FragmentDefinitionNode>;
|
||||||
|
|
||||||
|
getFragmentSpreads(node: SelectionSetNode): ReadonlyArray<FragmentSpreadNode>;
|
||||||
|
|
||||||
|
getRecursivelyReferencedFragments(operation: OperationDefinitionNode): ReadonlyArray<FragmentDefinitionNode>;
|
||||||
|
|
||||||
|
getVariableUsages(node: NodeWithSelectionSet): ReadonlyArray<VariableUsage>;
|
||||||
|
|
||||||
|
getRecursiveVariableUsages(operation: OperationDefinitionNode): ReadonlyArray<VariableUsage>;
|
||||||
|
|
||||||
|
getType(): Maybe<GraphQLOutputType>;
|
||||||
|
|
||||||
|
getParentType(): Maybe<GraphQLCompositeType>;
|
||||||
|
|
||||||
|
getInputType(): Maybe<GraphQLInputType>;
|
||||||
|
|
||||||
|
getParentInputType(): Maybe<GraphQLInputType>;
|
||||||
|
|
||||||
|
getFieldDef(): Maybe<GraphQLField<any, any>>;
|
||||||
|
|
||||||
|
getDirective(): Maybe<GraphQLDirective>;
|
||||||
|
|
||||||
|
getArgument(): Maybe<GraphQLArgument>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ValidationRule = (context: ValidationContext) => ASTVisitor;
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
export { validate } from "./validate";
|
||||||
|
|
||||||
|
export { ValidationContext } from "./ValidationContext";
|
||||||
|
|
||||||
|
export { specifiedRules } from "./specifiedRules";
|
||||||
|
|
||||||
|
// Spec Section: "Field Selections on Objects, Interfaces, and Unions Types"
|
||||||
|
export { FieldsOnCorrectType as FieldsOnCorrectTypeRule } from "./rules/FieldsOnCorrectType";
|
||||||
|
|
||||||
|
// Spec Section: "Fragments on Composite Types"
|
||||||
|
export { FragmentsOnCompositeTypes as FragmentsOnCompositeTypesRule } from "./rules/FragmentsOnCompositeTypes";
|
||||||
|
|
||||||
|
// Spec Section: "Argument Names"
|
||||||
|
export { KnownArgumentNames as KnownArgumentNamesRule } from "./rules/KnownArgumentNames";
|
||||||
|
|
||||||
|
// Spec Section: "Directives Are Defined"
|
||||||
|
export { KnownDirectives as KnownDirectivesRule } from "./rules/KnownDirectives";
|
||||||
|
|
||||||
|
// Spec Section: "Fragment spread target defined"
|
||||||
|
export { KnownFragmentNames as KnownFragmentNamesRule } from "./rules/KnownFragmentNames";
|
||||||
|
|
||||||
|
// Spec Section: "Fragment Spread Type Existence"
|
||||||
|
export { KnownTypeNames as KnownTypeNamesRule } from "./rules/KnownTypeNames";
|
||||||
|
|
||||||
|
// Spec Section: "Lone Anonymous Operation"
|
||||||
|
export { LoneAnonymousOperation as LoneAnonymousOperationRule } from "./rules/LoneAnonymousOperation";
|
||||||
|
|
||||||
|
// Spec Section: "Fragments must not form cycles"
|
||||||
|
export { NoFragmentCycles as NoFragmentCyclesRule } from "./rules/NoFragmentCycles";
|
||||||
|
|
||||||
|
// Spec Section: "All Variable Used Defined"
|
||||||
|
export { NoUndefinedVariables as NoUndefinedVariablesRule } from "./rules/NoUndefinedVariables";
|
||||||
|
|
||||||
|
// Spec Section: "Fragments must be used"
|
||||||
|
export { NoUnusedFragments as NoUnusedFragmentsRule } from "./rules/NoUnusedFragments";
|
||||||
|
|
||||||
|
// Spec Section: "All Variables Used"
|
||||||
|
export { NoUnusedVariables as NoUnusedVariablesRule } from "./rules/NoUnusedVariables";
|
||||||
|
|
||||||
|
// Spec Section: "Field Selection Merging"
|
||||||
|
export { OverlappingFieldsCanBeMerged as OverlappingFieldsCanBeMergedRule } from "./rules/OverlappingFieldsCanBeMerged";
|
||||||
|
|
||||||
|
// Spec Section: "Fragment spread is possible"
|
||||||
|
export { PossibleFragmentSpreads as PossibleFragmentSpreadsRule } from "./rules/PossibleFragmentSpreads";
|
||||||
|
|
||||||
|
// Spec Section: "Argument Optionality"
|
||||||
|
export { ProvidedRequiredArguments as ProvidedRequiredArgumentsRule } from "./rules/ProvidedRequiredArguments";
|
||||||
|
|
||||||
|
// Spec Section: "Leaf Field Selections"
|
||||||
|
export { ScalarLeafs as ScalarLeafsRule } from "./rules/ScalarLeafs";
|
||||||
|
|
||||||
|
// Spec Section: "Subscriptions with Single Root Field"
|
||||||
|
export { SingleFieldSubscriptions as SingleFieldSubscriptionsRule } from "./rules/SingleFieldSubscriptions";
|
||||||
|
|
||||||
|
// Spec Section: "Argument Uniqueness"
|
||||||
|
export { UniqueArgumentNames as UniqueArgumentNamesRule } from "./rules/UniqueArgumentNames";
|
||||||
|
|
||||||
|
// Spec Section: "Directives Are Unique Per Location"
|
||||||
|
export { UniqueDirectivesPerLocation as UniqueDirectivesPerLocationRule } from "./rules/UniqueDirectivesPerLocation";
|
||||||
|
|
||||||
|
// Spec Section: "Fragment Name Uniqueness"
|
||||||
|
export { UniqueFragmentNames as UniqueFragmentNamesRule } from "./rules/UniqueFragmentNames";
|
||||||
|
|
||||||
|
// Spec Section: "Input Object Field Uniqueness"
|
||||||
|
export { UniqueInputFieldNames as UniqueInputFieldNamesRule } from "./rules/UniqueInputFieldNames";
|
||||||
|
|
||||||
|
// Spec Section: "Operation Name Uniqueness"
|
||||||
|
export { UniqueOperationNames as UniqueOperationNamesRule } from "./rules/UniqueOperationNames";
|
||||||
|
|
||||||
|
// Spec Section: "Variable Uniqueness"
|
||||||
|
export { UniqueVariableNames as UniqueVariableNamesRule } from "./rules/UniqueVariableNames";
|
||||||
|
|
||||||
|
// Spec Section: "Values Type Correctness"
|
||||||
|
export { ValuesOfCorrectType as ValuesOfCorrectTypeRule } from "./rules/ValuesOfCorrectType";
|
||||||
|
|
||||||
|
// Spec Section: "Variables are Input Types"
|
||||||
|
export { VariablesAreInputTypes as VariablesAreInputTypesRule } from "./rules/VariablesAreInputTypes";
|
||||||
|
|
||||||
|
// Spec Section: "All Variable Usages Are Allowed"
|
||||||
|
export { VariablesInAllowedPosition as VariablesInAllowedPositionRule } from "./rules/VariablesInAllowedPosition";
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue