上一篇文章介绍了使用 Strapi 创建 Content Api 的过程,这里简要写一下生成一个自定义的 GraphQL Content Api。1.创建 GraphQL SchemaSchema 文件路径/api/movie/config/schema.graphql.jsSchema example1234567891011121314151617module.exports = {query: `moviesCount(where: JSON): Int!`,resolver: {Query: {moviesCount: {description: "Return the count of movies",resolverOf: "application::movie.movie.count",resolver: async (obj, options, ctx) => {return await strapi.query("movie").count(options.where || {});},},},},};2.查询Query moviesCount123{moviesCount}注意:如果返回 403Forbidden,需要在设置
...
继续阅读
(60)