Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Latest commit

 

History

History
executable file
·
71 lines (51 loc) · 2.11 KB

graphql.md

File metadata and controls

executable file
·
71 lines (51 loc) · 2.11 KB

This document assumes that you already know the basics of GraphQL. If you don't know much about it, please refer to https://www.howtographql.com/

Overview

All interfaces of CPS are provided and only the GraphQL interface is available. All GraphQL requests can only be initiated in two places:

  1. In the pages directory, prepare the data for the server's server rendering.
  2. In the logic.js file of each container component (the corresponding schema file is located in the same directory)

how to use

Take containers/PostsThread/schema.js as an example:

import gql from 'graphql-tag'
import { P, F } from '@/schemas'

const pagedPosts = gql`
  ${P.pagedPosts}
`
const pagedArticleTags = gql`
  ${P.pagedArticleTags}
`

const pagedCommunities = gql`
  Query($filter: CommunitiesFilter!) {
    pagedCommunities(filter: $filter) {
      Entries {
        ${F.community}
        contributesDigest
        subscribersCount
      }
      ${F.pagi}
    }
  }
`

const schema = {
  pagedPosts,
  partialTags,
  pagedCommunities,
}

export default schema

P, F are common schema fragments (note that not strictly Fragment, but very similar). After exporting the Schema, you can use it in the same directory's logic.js:

Const loadCityCommunities = () => {
  ....
  Sr71$.query(S.pagedCommunities, args)
  ....
}

API Documentation

You can open the https://coderplanets.com/graphiql using the online interactive tool to query and use the API.

image

For detailed usage, please refer to the Reference Document

Note: If you want to develop a third-party client, please do not use the main station for debugging. Please use https://dev.coderplanets.com for development.

Model Visualization

You can visually view the relationship between models by opening https://coderplanets.com/model-graphs:

image