Skip to content

quick scripts for GRAPHQL mutations and quries

biyingshuai edited this page Jul 5, 2020 · 1 revision

User

Mutation

addUser

mutation addUser($input: CreateUserInput!) {
    addUser(user: $input) {
        email
        name
        password
    }
}

variable:

{
    "input": {
        "email": "[email protected]",
        "name": "bys",
        "username": "zifeiyu",
        "password": "123",
        "intro": "this is my intro"
    }
}

modifyUser

mutation updateUser($user: UpdateUserInput!) {
    update(user: $user) {
        name
    }
}

variable:

{
    "user": {
        "id": "5eee0cafb559546b1ad66810",
        "name": "bys22222",
        "intro": "this is my intro"
    }
}

Query

findOne

query getUser($id: String!) {
    user(id: $id) {
        name
        email
    }
}

variable

{
    "id": "5eee22845f58b61575c5c054"
}

Team

Mutation

addTeam

mutation addTeam($input: CreateTeamDTO!) {
    addTeam(team: $input) {
        name,
    }
}

variable

{
    "input": {
        "owner": "5efca6401f1d3a716c7d9533",
        "name": "team1"
    }
}

addMember

mutation addMember($teamId: String!, $member: CreateTeamMemberInput!) {
    addMember(teamId: $teamId, member: $member) {
        permission,
        user
    }
}

variable

{
    "teamId": "5eef0345c5763dc8a3bc018d",
    "member": {
        "user": "5eee22845f58b61575c5c054",
        "permission": "normal"
    }
}

Query

team

query team($input: String!) {
    team(id: $input) {
        name
    }
}

variable

{
    "input": "5eef0345c5763dc8a3bc018d"
}

specification

Mutation

createSpecification

mutation createSpecification($input: CreateSpecificationDTO!) {
    createSpecification(specification: $input) {
        id,
        name
    }
}

variable

{
    "input": {
        "name": "spec one",
        "team": "5efe08c021ae4749a8a14057"
    }
}

createCategory

mutation category($input: CreateCategoryDTO!) {
    createCategory(category: $input)
}

variable

{
    "input": {
        pecificationId": "5f006ce444cbd3120fddf57d",
        "name": "颜色"
    }
}

updateSpecification

mutation updateSpecification($input: UpdateSpecificationDTO!, $fields: [String!]) {
    updateSpecification(fields: $fields, specification: $input) {
        id,
        name
    }
}

variable

{
    "input": {
        "id": "5f006ce444cbd3120fddf57d",
        "name": "规范1"
    },
    "fields": ["id", "name"]
}

updateCategory

mutation updateCategory($input: UpdateCategoryDTO!) {
    updateCategory(category: $input)
}

variable

{
    "input": {
        "id": "5f0143580853d04b011661af",
        "name": "字体",
        "specificationId": "5f006ce444cbd3120fddf57d"
    }
}

deleteCategory

mutation deleteCategory($categoryId: String!, $specificationId:  String!) {
    deleteCategory(categoryId: $categoryId, specificationId: $specificationId)
}

variable

{
    "categoryId": "5f0142fa0853d04b011661ae",
    "specificationId": "5f006ce444cbd3120fddf57d"
}

Query

specification

query specification($input: String!) {
    specification(id: $input) {
        id,
        name,
        team
    }
}

variable

{
    "input": "5f006ce444cbd3120fddf57d"
}

category

query category($fields: [String!], $categoryId: String!, $specificationId: String!) {
    category(fields: $fields, categoryId: $categoryId, specificationId: $specificationId) {
        name
    }
}

spicificationItem

query specificationItem($names: [String!], $categoryId: String!, $specificationId: String!) {
    specificationItem(names: $names, categoryId: $categoryId, specificationId: $specificationId) {
        name
    }
}

variable

{
    "categoryId": "5eef73d17ac1bf330bc74dea",
    "specificationId": "5eef37061a98aafcabeef0a3"
}

Level

query

level

query level($input: String!) {
    level(id: $input) {
        id,
        name
    }
}

variable

{
    "input": "5f019229b2ac158fa1c991b5"
}

mutation

creeateLevel

mutation createLevel($input: CreateLevelDTO!) {
    createLevel(level: $input) {
        id
    }
}

variable

{
    "input": {
        "specification": "5f006ce444cbd3120fddf57d",
        "category": "5f0143580853d04b011661af",
        "name": "标题字体"
    }
}

createItem

mutation createItem($item: CreateItemDTO!, $levelId: String!) {
    createItem(item: $item, levelId:  $levelId)
}

variable

{
    "item": {
        "name": "一级标题",
        "text": "一级标题title",
        "info": "一级标题info",
        "meta": "{}"
    },
    "levelId": "5f019229b2ac158fa1c991b5"
}

Project

query

project

query project($input: String!) {
    project(id: $input) {
        id,
        name,
        type
    }
}

variable

{
    "input": "5f01a9f36b333aa78ff86634"
}

mutation

createProject

mutation createProject($input: CreateProjectDTO!) {
    createProject(project: $input) {
        id,
        name
    }
}

variable

{
    "input": {
        "name": "项目1",
        "team": "5efe08c021ae4749a8a14057",
        "type": "pc"
    }
}

updateProject

mutation updateProject($input: UpdateProjectDTO!) {
    updateProject(project: $input)
}

variable

{
    "input": {
        "id": "5f01a9f36b333aa78ff86634",
        "type": "mobile",
        "name": "更新的项目1"
    }
}