graphql

GraphQL:Descriptor Attributes

倾然丶 夕夏残阳落幕 提交于 2020-12-20 16:51:06
GraphQL 既是一种用于 API 的查询语言也是一个满足你数据查询的运行时。GraphQL 对你的 API 中的数据提供了一套易于理解的完整描述,使得客户端能够准确地获得它需要的数据,而且没有任何冗余,也让 API 更容易地随着时间推移而演进,还能用于构建强大的开发者工具。 ——出自 https://graphql.cn HotChocolate中可以通过定义Attribute来增加通用性处理功能,之前博文中用过UsePaging分页,UseFiltering过滤,UseSorting排序,我们也可以自定义特性类来达到处理统一数据的作用,下面的例子就是一个 脱敏 的特性类,可以在使用特性类时告诉系统那些数据是不显示出来的,此类就会把数据变成等长的*号字符串来替换。 using HotChocolate; using HotChocolate.Data; using HotChocolate.Execution; using HotChocolate.Types; using HotChocolate.Types.Descriptors; using System; using System.Collections; using System.Collections.Generic; using System.Reflection; namespace

GraphQL:打造自己的Directive库

送分小仙女□ 提交于 2020-12-17 14:27:27
GraphQL 既是一种用于 API 的查询语言也是一个满足你数据查询的运行时。GraphQL 对你的 API 中的数据提供了一套易于理解的完整描述,使得客户端能够准确地获得它需要的数据,而且没有任何冗余,也让 API 更容易地随着时间推移而演进,还能用于构建强大的开发者工具。 ——出自 https://graphql.cn HotChocolate可以通过自定义Directive来对字段的值进行转换和处理,下在的例子就是给字符串给字符串类型的值转大写和替换。 using HotChocolate; using HotChocolate.Data; using HotChocolate.Execution; using HotChocolate.Types; using System; using System.Collections.Generic; using System.Reflection; namespace GraphQLBase003 { class Program { static void Main(string[] args) { DirectiveDemo.Run(); } } public class DirectiveDemo { public static void Run() { var schema = SchemaBuilder.New()

Gatsby MDX showing title and slug but doesn't find page

早过忘川 提交于 2020-12-15 06:39:47
问题 I'm learning Gatsby and I wanted to use MDX for blog pages. I followed the tutorial here to programmatically create pages. I can see them in my GraphQL, and displaying the list of all the articles is working with their title and slug, but when I click on the link to open them or type their address I have a 404 page. Do you have an idea from where it can come from? This is my code: gatsby-node.js: exports.onCreateNode = ({ node, actions, getNode }) => { const { createNodeField } = actions if

When to use enter/leave with `visit` function of `graphql`

回眸只為那壹抹淺笑 提交于 2020-12-15 05:25:26
问题 I'm trying to remove some nodes from a ast of graphql using the visit function. Just as the doc says, there are two event I can hook into enter leave I don't know when to use enter and when to use leave, what's the deference between them? How can I tell which one to use? 回答1: The main difference is that enter() allows you to skip the subtree if you don't care about it. There is a section on this page https://graphql.org/graphql-js/language/#visitor that describes the return values permitted

How to map serial and timestamptz of graphlql

笑着哭i 提交于 2020-12-15 04:04:12
问题 I have the following data base which i am trying to make a mapping for it while the data base looks like the following id ----> serial (nextval('id_seq'::regclass)) fromDate_ts ---> timestamptz toDate_ts --> timestamptz creating_ts--> timestamptz so --> varchar re--> int4 while writing mapping like this: @Id @Column(name = "id", nullable = false, insertable = false) private Integer id; @Column(name = "fromDate_ts ") @Temporal(TemporalType.TIMESTAMP) private Date fromDate; @Column(name =

How to map serial and timestamptz of graphlql

那年仲夏 提交于 2020-12-15 04:03:12
问题 I have the following data base which i am trying to make a mapping for it while the data base looks like the following id ----> serial (nextval('id_seq'::regclass)) fromDate_ts ---> timestamptz toDate_ts --> timestamptz creating_ts--> timestamptz so --> varchar re--> int4 while writing mapping like this: @Id @Column(name = "id", nullable = false, insertable = false) private Integer id; @Column(name = "fromDate_ts ") @Temporal(TemporalType.TIMESTAMP) private Date fromDate; @Column(name =

Authorisation in Laravel Lighthouse

筅森魡賤 提交于 2020-12-13 06:19:40
问题 In my graphql API I have to authorize requests to fields by two different factors. Whether the user is authorized to access the data or whether the data belongs to the user. For example, the user should be able to see its own user data and all users with admin rights should be able to see this data too. I want to protect the fields, so users with different permisions can access some fields of a type, but don't have access all fields. I tried to do this with @can , but I didn't find any way to

strapi graphql limit only return 100 items even if I set limit to -1

让人想犯罪 __ 提交于 2020-12-13 04:55:08
问题 currently I have some problem with strapi graphql query. I can only query about 100 items max. here is my query: query StudioList { studios(limit: -1) { id slug name } } with or without limit always return 100 items. how do i query for more than 100? thanks.. 回答1: I found the solution: if you have plugins.js file in your strapi ./config folder, then add the following code: module.exports = { // graphql: { endpoint: '/graphql', shadowCRUD: true, playgroundAlways: false, depthLimit: 7,

Graphql query to check passport/google authentication

孤人 提交于 2020-12-13 04:48:16
问题 I want to implement graphql query to check if I'm logged in or not. First part is similar for what we all can see on passport docs and youtube/github tutorials: I: Introduction(if anybody know what is all about you can skip to problem part): modules/auth.js const GoogleStrategy = require('passport-google-oauth20').Strategy const passport = require('passport'); const User = require('../models/user'); passport.serializeUser((user, done) => { done(null, user.id) }) passport.deserializeUser((id,

Dynamic GraphQL schema?

此生再无相见时 提交于 2020-12-13 04:28:11
问题 I have a mutation that is going to submit a form data, this data can vary depending by the form you are filling out. The forms are going to be a lot, and they will share the same "steps" (each form is composed by 1 or more pages/steps). So, we may have these reusable steps: Fav fruit Date of birth Name and surname And these two forms: Generic info ( genericInfo ): Name and surname + Date of birth What do you eat? ( whatYouEat ): Name and surname + Fav fruit I'd need a way to have a single