Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL? #35

Open
VladimirAlexiev opened this issue Jan 14, 2020 · 8 comments
Open

GraphQL? #35

VladimirAlexiev opened this issue Jan 14, 2020 · 8 comments

Comments

@VladimirAlexiev
Copy link

GraphQL is a big fad nowadays (and http://platform.ontotext.com/ provides GraphQL over RDF data).

Does it have any relevance for the Reconciliation API?
I tend to vote no: it could simplify the API use a bit, but it'd have to support the old (REST) API anyway and there is one main client (OpenRefine), so I'd say it's not worth it.

@wetneb
Copy link
Member

wetneb commented Jan 14, 2020

We thought about GraphQL when we added the Data Extension API.
I was also reluctant to use it, because it did not fit well with the spirit and data model of the existing API, with simple JSON-based REST endpoints. I also thought it would be harder for services to add support for it, since it would need to rely on relatively large third-party libraries which are not necessarily available in many languages and frameworks. Because GraphQL is very expressive it would also be potentially expensive to run. But that being said if we are to make big breaking changes to the API anyway, it might be worth considering. It could be a nice thing to have if the other parts of the service (reconciliation, suggest, preview, extension) could be recast in a GraphQL flavour too.

@VladimirAlexiev
Copy link
Author

@wetneb I'm curious why you thought in particular about Extension.
Could you give an example of Extension request/response in REST and GQL (I could do the latter), so we can compare?

@wetneb
Copy link
Member

wetneb commented Jan 14, 2020

Well, the data extension API is all about "returning user-selected properties from some records", which is what GraphQL is all about too, so this is where we saw a connection.

A sample data extension query is here: https://reconciliation-api.github.io/specs/latest/#example-20

@VladimirAlexiev
Copy link
Author

VladimirAlexiev commented Oct 22, 2020

This is the analog in GraphQL.
The query is simpler (more natural):

query extendData {
 entity (where:{id:{IN:["10662041X","1064905412"]}}) {
   id
   variantName(limit:5)
   geographicAreaCode(limit:1) {id}
   professionOrOccupation {id name}
 }
}

The field params are not standardized.
Each service implements its own version of where, and some services use first instead of limit.

The response has exactly the same form as the query, so there's no meta. (The form is not very different from the current example).

{"data":
 {"entity": [
   {"id":"10662041X",
    "variantName": ["Stryi-Leitgeb, Gerda","Leitgeb, Gerda Stryi-"],
    "geographicAreaCode": ["http://d-nb.info/standards/vocab/gnd/geographic-area-code#XA-DE"],
    "professionOrOccupation": [
      {
        "id": "4037223-6",
        "name": "Malerin"
      },
      {
        "id": "4033430-2",
        "name": "Künstlerin"
      }
    ]
   },
   {"id": "1064905412",
    "variantName": [],
    "geographicAreaCode": ["http://d-nb.info/standards/vocab/gnd/geographic-area-code#XA-DE"],
    "professionOrOccupation": [
      {
        "id": "4002844-6",
        "name": "Architekt"
      }
    ]
   }
 ]
}

GraphQL really shines if you fetch nested (related) objects because then you can specify exactly which fields of those objects to get. But people won't use nested objects to populate an OR column...

@VladimirAlexiev
Copy link
Author

I think GraphQL would be useful if you want to reconcile or fetch data from mutliple entity types.
But that's not the ideology of OR...

@wetneb
Copy link
Member

wetneb commented Oct 22, 2020

What would reconciliation look like with GraphQL? The query above makes sense for data extension, but what about reconciliation itself?

@VladimirAlexiev
Copy link
Author

GraphQL queries are typically small and don't usually carry big arrays of data. So I don't see it as a good fit for Recon

@VladimirAlexiev
Copy link
Author

#84 discusses breaking API changes to fix REST shortcomings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants