outcaste-io / outserv Goto Github PK
View Code? Open in Web Editor NEWBlockchain Search with GraphQL APIs
Home Page: https://manishrjain.com/outserv-graphql-blockchain-search
License: Other
Blockchain Search with GraphQL APIs
Home Page: https://manishrjain.com/outserv-graphql-blockchain-search
License: Other
It'd be great if Outserv had built-in timestamp functionality that worked similarly to Neo4j's:
This was requested multiple times on the Dgraph forums:
https://discuss.dgraph.io/t/query-sever-timestamps-in-graphql/7091
https://discuss.dgraph.io/t/slash-dgraph-backend-security-field-validation-and-timestamps/13317
This product roadmap is based on the initial ideas during launch. As I get more feedback from users, this roadmap is bound to change.
Importers
GraphQL Query Cache
So, the Todo example works great now that you have added @hasInverse. I even queried the reverse type (not in the example), and it works as expected.
However, the Quickstart Example for product reviews does not work.
schema
type Product {
productID: ID!
name: String @search(by: [term])
reviews: [Review] @hasInverse(field: about)
}
type Customer {
username: String! @id @search(by: [hash, regexp])
reviews: [Review] @hasInverse(field: by)
}
type Review {
id: ID!
about: Product!
by: Customer!
comment: String @search(by: [fulltext])
rating: Int @search
}
First Mutation
mutation {
addProduct(input: [
{ name: "GraphQL on Dgraph"},
{ name: "Dgraph: The GraphQL Database"}
]) {
product {
productID
name
}
}
addCustomer(input: [{ username: "Michael"}]) {
customer {
username
}
}
}
No issues here. The problem is with the second mutation.
Second Mutation
mutation {
addReview(input: [{
by: {username: "Michael"},
about: { productID: "0x2"},
comment: "Fantastic, easy to install, worked great. Best GraphQL server available",
rating: 10}])
{
review {
comment
rating
by { username }
about { name }
}
}
}
The by
and the about
are nested values that should be addable based on the @id field. It is, in reality, an upsert. How you want to handle this may be different than dgraph, but it is a very common use case.
Side Note: Not sure if this is important, but the extensions come back empty on add mutations.
(I imagine you want issues posted here, and features posted under outcaste, so correct me if I'm wrong)
J
We need a solution for renaming a field or a type, without having to rewrite the entire data.
P.S. Have a look at how EdgeDB does this: https://www.edgedb.com/showcase/migrations
We currently use Node.JS to run JS/TS scripts. Research if moving to Deno would make more sense.
Example:
union TextContainer = Word | Phrase
type Paragraph {
id: ID!
textContainers: [TextContainer]
words: [Word!] @hasInverse(field: paragraph)
phrases: [Phrase] @hasInverse(field: paragraph)
}
type Word {
id: ID!
text: String! @search(by: [regexp])
paragraph: Paragraph!
phrase: Phrase
}
type Phrase {
id: ID!
paragraph: Paragraph!
words: [Word!]! @hasInverse(field: phrase)
}
If I run deletePhrase()
to delete one of the Phrase
objects referenced in the Paragraph.textContainers
union list, then the API returns the following:
{
"errors": [
{
"message": "Non-nullable field 'xid' (type String!) was not present in result from Dgraph. GraphQL error propagation triggered.",
"locations": [
{
"line": 12,
"column": 9
}
],
"path": [
"paginateParagraphsWithPhrases",
0,
"textContainers",
3,
"xid"
]
}
],
"data": {
"paginateParagraphsWithPhrases": [
{
"id": "0x42024",
"transcript": {
"id": "0x41f6a"
},
"start": 0.15,
"end": 4.19,
"textContainers": [
{
"__typename": "Word",
"xid": "06dd22c3-3f52-4c4b-aa10-dc177f65e9ee",
"text": "I'm"
},
{
"__typename": "Word",
"xid": "0174abd9-a708-4b6f-8f08-e6ae8f36c427",
"text": "I"
},
{
"__typename": "Phrase",
"words": [
{
"xid": "b42505e7-0379-49c1-95de-64f0ff95212f",
"text": "only"
},
{
"xid": "e5941e95-8078-487b-a750-15e426dcfa0c",
"text": "joking."
}
]
},
null
]
},
Notice that there is a null
in the textContainers
list. Desired behaviour is for deleting the Phrase
to remove it from the list, or at the very least for the API to just ignore null references.
EDIT: The problem I have now is that I have no idea how to remove that null
reference from the list. So the data is effectively corrupted as a result of this simple operation.
This is a problem I'm experiencing in 20.03, I'm assuming it's still an issue in Outserv.
So I am following the guide here: https://dgraph.io/docs/graphql/todo-app-tutorial/todo-schema-design/
I add the data, everything works as expected...
When I query:
query {
queryUser {
username
name
tasks {
title
completed
}
}
}
No problems, I get the expected results:
{
"data": {
"queryUser": [
{
"username": "[email protected]",
"name": "Alice",
"tasks": [
{
"title": "Avoid crowd",
"completed": true
},
{
"title": "Wash your hands often",
"completed": true
},
{
"title": "Avoid touching your face",
"completed": false
},
{
"title": "Stay safe",
"completed": false
}
]
}
]
},
"extensions": {
"touched_uids": 16
}
}
However, when I query the Inverse (from the example), I get this error:
query {
queryTask {
id
title
completed
user {
username
}
}
}
{
"errors": [
{
"message": "Non-nullable field 'user' (type User!) was not present in result from Dgraph. GraphQL error propagation triggered.",
"locations": [
{
"line": 6,
"column": 5
}
],
"path": [
"queryTask",
0,
"user"
]
},
{
"message": "Non-nullable field 'user' (type User!) was not present in result from Dgraph. GraphQL error propagation triggered.",
"locations": [
{
"line": 6,
"column": 5
}
],
"path": [
"queryTask",
1,
"user"
]
},
{
"message": "Non-nullable field 'user' (type User!) was not present in result from Dgraph. GraphQL error propagation triggered.",
"locations": [
{
"line": 6,
"column": 5
}
],
"path": [
"queryTask",
2,
"user"
]
},
{
"message": "Non-nullable field 'user' (type User!) was not present in result from Dgraph. GraphQL error propagation triggered.",
"locations": [
{
"line": 6,
"column": 5
}
],
"path": [
"queryTask",
3,
"user"
]
}
],
"data": {
"queryTask": [
null,
null,
null,
null
]
},
"extensions": {
"touched_uids": 16
}
}
This may be expected if you did not rewrite the @hasInverse
directive. As we discussed, and as the notion says written by Anthony and me, it should be rewritten to use @reverse under-the-hood anyway.
J
The addType
function, e.g. addThing
, addProduct
receives an array of items to add. Always throws me that it's named addType
(singular) but takes an array as input. I think it'd make sense to rename it to addTypes
, e.g. addProducts
, addThings
, addUsers
As it is currently:
type Author {
id: ID!
name: String! @search(by: [hash])
dob: DateTime
posts: [Post]
}
type Post {
postID: ID!
title: String! @search(by: [term, fulltext])
text: String @search(by: [fulltext, term])
datePublished: DateTime
}
addPost(input: [AddPostInput!]!): AddPostPayload
input AddPostInput {
title: String!
text: String
datePublished: DateTime
}
type AddPostPayload {
post(filter: PostFilter, order: PostOrder, first: Int, offset: Int): [Post]
numUids: Int
}
mutation {
addAuthor(input: [{ name: "A.N. Author", posts: []}]) {
author {
id
name
}
}
}
Proposed change:
type Author {
id: ID!
name: String! @search(by: [hash])
dob: DateTime
posts: [Post]
}
type Post {
postID: ID!
title: String! @search(by: [term, fulltext])
text: String @search(by: [fulltext, term])
datePublished: DateTime
}
addPosts(input: [AddPostsInput!]!): AddPostsPayload
input AddPostsInput {
title: String!
text: String
datePublished: DateTime
}
type AddPostsPayload {
post(filter: PostFilter, order: PostOrder, first: Int, offset: Int): [Post]
numUids: Int
}
mutation {
addAuthors(input: [{ name: "A.N. Author", posts: []}]) {
author {
id
name
}
}
}
We directly parse GraphQL queries to the underlying query struct, but then convert it to DQL, before passing it to edgraph. Avoid that conversion to DQL step.
There're a lot of subgraphs that are built for "The Graph". It would be great if we could write a script that can import them automatically to Outserv as well.
Outserv should allow caching the responses of a GraphQL query for a given TTL, specified in the schema.
Outserv really needs a tool or workflow for safely managing migrations.
Ideally it'd have:
Existing migration tools for reference:
https://www.edgedb.com/docs/cli/edgedb_migration/index
https://github.com/fauna-labs/fauna-schema-migrate
https://guides.rubyonrails.org/active_record_migrations.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.