question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Correct way to handle unstructured property values

See original GitHub issue

Hi,

First of all, I´d like to thank you for the awesome job you have done with the spec and this reference implementation. It took only couple of hours to build a GraphQL “proxy” server by generating GraphQL schema from a preexisting JSON schema definition we had for our REST API and I’m already experiencing the benefits.

The only question I have is this; We have some abstract field types in our api. For example some responses may contain user supplied JSON metadata. This means I’m unable to define the actual fields and types for the data. Currently I’m using an ugly way to handle these fields by creating a scalar type and using that for the metadata fields.

var GraphQLAnything = new GraphQLScalarType({
  name: 'Anything',
  coerce: function (value) {
    return value;
  },
  coerceLiteral: function (ast) {
    return ast.value;
  }
});

This works as desired (I’m able to receive the data in correct form) but defining something like this as a scalar feels wrong in so many levels. Especially as the spec says that “Scalars cannot have fields.”. Is there a correct way to handle these type of values?

Thanks!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisabramscommented, Apr 15, 2016

@orktes could you provide an example of how you are trying to use this with a query? I tried doing something similar but cannot seem to figure out how to format the query.

1reaction
orktescommented, Jul 8, 2015

Thanks for the quick answer!

“DangerousUserProvidedUnstructuredJSON” inspired me to find a way to convert the old unstructured data into something structured 😄

Closing…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Manage Unstructured Data - CHI Software
With this article, you'll learn how to manage unstructured data. We review technical aspects, challenges, tools, and solutions through our ...
Read more >
4 Ways to Deal With Unstructured Data - Iron Mountain
When deciding how to deal with unstructured data, look to cloud and tape for ideas. Deduplicating data helps minimize how much data is...
Read more >
Processing Unstructured Data in 5 Easy Ways - Srijan
Entity Extraction: You can process the unstructured data by pulling out names of people, organization, location etc. from it. This process will ...
Read more >
4 Easy Ways to Deal with Unstructured Data - Fusion
Clear the Unstructured Data · Evaluate on Keeping or Deleting the Data · Work with Data Experts to Deal with Unstructured Data ·...
Read more >
5 Best Practices for Optimizing Your Unstructured Data
To overcome those hurdles, IT organizations need ways of deriving value from unstructured data while simultaneously addressing priorities ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found