转自:https://blog.grandstack.io/whats-new-in-grandstack-310c067fea4a

There’s been a lot of activity in the GRANDstack world recently so in this post we review some of the new features and take a look at what community members have been working on.

GRANDstack is a fullstack framework for building applications using GraphQL, React, Apollo, and Neo4j Database.

Implementing authorization in GraphQL has long been an area of interest for developers working with GraphQL. Beginning in version 2.4.0 of neo4j-graphql.js we’ve introduced features to make implementing authorization easier. Specifically, we’ve added authorization specific schema directives that work with JSON Web Tokens (JWTs) out of the box, and the ability to access context values in Cypher queries.

Schema Directives

Based on the prototype described in this post, “Authorization In GraphQL Using Custom Schema Directives”, you can now make use of the following authorization schema directives in your GraphQL type definitions with neo4j-graphql.js:

  • isAuthenticated
  • hasRole
  • hasScope

You can read more about using schema directives for securing your GraphQL API in the docs here, or see the example project and post here.

Context Values Into Cypher Query

Another authorization feature in neo4j-graphql.js is the ability to access values from the context object in a Cypher query specified in a@cypherdirective. This is useful when using authorization middleware (such as Passport) that adds user information to the request object, or to access a JWT token that contains user information to be matched against the database.

Here’s how it works: First, add a cypherParams object to the context. Here’s how that looks when using Apollo Server:

const server = new ApolloServer({   
context: ({req}) => ({
driver,
cypherParams: {
currentUserId: req.user.id
}
})
})

Any values within cypherParamin the context object will then be available in Cypher queries making use of the@cypherschema directive as Cypher parameters. Here we look up the currently authenticated user by using the currentUserId value that we added to the context object above:

type Query {
currentUser: User @cypher(statement: """
MATCH (u:User {id: $cypherParams.currentUserId})
RETURN u
""")
}

You can read more about these authorization features in the neo4j-graphql.js documentation.

GraphQL Foundation

In March, the Linux Foundation announced the formation of the GraphQL Foundation, a neutral group set up to provide governance and vendor-neutral stewardship for GraphQL. This includes oversight of funding, operations and marketing resources for the GraphQL community. Neo4j is happy to be included in this group as a founding member.

Neo4j joined the newly formed GraphQL Foundation as a founding member in March.

As Emil says, GraphQL and GRANDstack have been a huge boost for developers using Neo4j and we want to make sure this continues:

“Neo4j is pleased to support GraphQL, due to its unique ability to enable front-end developers, API developers and data architects to all work with the same graph-based data model. Our GraphQL integration and GRANDstack have already helped thousands of developers build graph applications with Neo4j, thanks to the huge developer productivity gain of GraphQL and the graph thinking mindset it brings for both developers and API consumers. The GraphQL Foundation is an important step to cement today’s most relevant standard for building APIs and we’re honored to join as founding members to help steward GraphQL as the ecosystem continues to evolve.”

— Emil Eifrem, CEO and Co-Founder, Neo4j

Neo4j GraphQL Java

The neo4j-graphql.js library has been an important component of GRANDstack for those building node.js APIs, but what if you want to use languages other than node.js? To support Java / JVM based APIs we’ve been working on neo4j-graphql-java, a JVM library to translate GraphQL queries and mutations to Cypher for use with Neo4j.

neo4j-graphql-java milestone release 2 is now available!

neo4j-graphql-java has had a second milestone release earlier this week with loads of new features such as

Please give it a try, check out the project’s documentation, and open issues for any feedback.

A slide from Rhys Evans’s talk “A Field Guide To The Financial Times”

From The Community

The GRANDstack community has been working on some great projects, here’s just a few that we’d like to share with you.

  • Gavin Williams from Quandercame on the Neo4j Online Meetup and shared how to build a GraphQL API with Neo4j. You can find the video here.
  • Rhys Evans from The Financial Times presented “A Field Guide To The Financial Times” where he shared how the FT is using GRANDstack. You can find the slides here.
  • Matt Ross from Comcast created a video course on Egghead “Build a Neo4j & GraphQL API” where he shows how to use neo4j-graphql.js to generate a GraphQL API backed by Neo4j using only GraphQL type definitions.
  • Erik Rahm, Senior Software Engineer at CyberGRX, released grand-stack-seed, a GRANDstack seed project with built in local auth, Facebook OAuth, and sample GraphQL types, queries, and mutations.

Share Your GRANDstack story

Do you have a neat GRANDstack project you’ve been working on? Please consider sharing your story by submitting a talk to GraphQL Summit in San Francisco or ping me to be an author on theGRANDstack blog.

 
 
 
 

What’s New In GRANDstack?的更多相关文章

  1. grandstack graphql 开发模型

    当前grandstack 支持两类开发方式 js (使用Neo4j-graphql-js) 插件模型 js 模型 参考https://github.com/rongfengliang/grand-st ...

  2. grandstack graphql 工具基本试用

      grandstack 是一个方便graphql 应用开发的工具 使用docker-compose 运行 环境准备 官方的starter 比较好,已经是使用docker-compose 创建好了所有 ...

  3. grandstack 基于graphql&&react&& apollo&& neo4j 的全栈开发工具

    grandstack是一个基于graphql&&react&& apollo&& neo4j 的全栈开发工具. 有篇关于graphql 的5个常见问题的 ...

随机推荐

  1. C# winform 选择文件保存路径

    1.winform 点击按钮选择文件保存的路径,效果如下图: 具体代码如下: private void button8_Click(object sender, EventArgs e) { Fold ...

  2. Python语法注意点

    1. 在Python中定义函数,可以用必选参数.默认参数.可变参数.关键字参数和命名关键字参数,这5种参数都可以组合使用.但是请注意,参数定义的顺序必须是:必选参数.默认参数.可变参数.命名关键字参数 ...

  3. Vmware ESXi 的虚拟机的开机自启动

    ESXi 6.7 以前就注意到虚拟机有个菜单[action->autostart]可以用来自启动(物理机开机之后), 可是设置完之后,总是没成功. 今天重新google了,发觉不但虚拟机,整个物 ...

  4. ajax上传下载自定义圆形滚动条

    demo地址:https://pan.baidu.com/s/1qYNYCFE 因为项目需要在上传文件的时候,知道上传的进度,所以封装了一个方法,在上传文件的时候动态显示上传进度,主要根据XMLHtt ...

  5. 牛客练习赛42 C 出题的诀窍

    题目链接:https://ac.nowcoder.com/acm/contest/393/C 这个题就是对于每个数算贡献,如果有相同的数,只计算先出现的数的贡献 对于数x,若它在前i行的数目分别为a1 ...

  6. Bupt归队赛, gunfight

    只需要关心是否开枪,上个人和当前这个人的位置关系,转移可以前缀和优化 为了不重复,始终认为第一个就是1,最后答案乘以n #include<bits/stdc++.h> using name ...

  7. javascript高级程序设计第3版——第一章概括

    最近发现Xmind思维导图是个好东西,刚好开始看书,被用来归纳最好不过了

  8. [uva P1601] The Morning after Halloween

    [uva P1601] The Morning after Halloween 题目链接 非常经典的一道题目,lrj的书上也有(貌似是紫书?). 其实这题看起来就比较麻烦.. 首先要保证小鬼不能相遇, ...

  9. WIFI 万能钥匙万玉权:团队之中要有跨三界之外的“闲人” [转]

      在团队规模较小时,很多事情都可以变得特别简单.比如架构的选择,大部分情况下,最初的架构越简单越好,随着业务的演进,架构才不断完善. 连尚网络经历了从几人到上百人的管理过程,其自主创新研发的产品 W ...

  10. C++解析九-数据抽象

    数据抽象 数据抽象是指,只向外界提供关键信息,并隐藏其后台的实现细节,即只表现必要的信息而不呈现细节.数据抽象是一种依赖于接口和实现分离的编程(设计)技术.让我们举一个现实生活中的真实例子,比如一台电 ...