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.

support passing metadata at request time

See original GitHub issue

Use case:

I am implementing persisted queries for my own custom backend. To do this, in production I generate a build artifact that goes along with the query. Then I want to write a middleware to modify the request on the way out to simply replace the serialized query with the build artifact. On the server, the artifact gets transformed back into the query.

The problem: there is no (real) way for me to send this artifact through the request for my middleware to consume. The only way I could get this to work is to “smuggle” it through variables as a magic field that gets extracted out by my NetworkInterface.

This would be much nicer if I could just pass that build artifact through the request to have the middleware swap it out.

Could this be a plugin?

Maybe. Middleware comes very close to doing everything I need, I just don’t have a good API to send it the extra bit of data it needs.

Is there a workaround?

Yes, see above about smuggling it through variables. However this is super hacky, I would prefer to do it correctly.

Note: the interface for Request indicates that one can pass in additional key/value pairs, but this data unfortunately does not survive to the NetworkInterface/middleware layer.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vovacodescommented, Jan 11, 2017

@roippi @helfer are we talking about adding metadata field to GraphQLRequest interface? If so, I don’t see any breaking changes here, we are adding new stuff, not removing it, I might not see the whole picture though

@roippi Could you please give an example of a situation when this becomes a problem?

1reaction
vovacodescommented, Jan 5, 2017

@roippi I believe metadata is the ideal place for “custom” information to be stored. I would like to utilize it for marking certain queries as the ones that require the “global” loading spinner. So that I could use that info in a middleware to dispatch the action that will show the spinner.

Do you see any harm in passing metadata all the way to the networkInterface?

Read more comments on GitHub >

github_iconTop Results From Across the Web

4. Metadata Design - REST API Design Rulebook [Book]
This brief chapter suggests a set of rules to help REST API designers work with ... Some time later, client#2 decides to share...
Read more >
Metadata and state - Zendesk Developer Docs
Zendesk Support passes the metadata and state values back to your integration service when making POST requests to your integration service.
Read more >
How do I upload a file with metadata using a REST web service?
One advantage to sending the content first is that by the time the metadata exists, the content is already present. Ultimately the right...
Read more >
meta data format (with http post request) - Google Groups
the following simple request works fine. but when I add meta data it fails ... curl request that would create a charge and...
Read more >
Pass Metadata and Filename as Parameter in Designer
SUPPORT & SERVICES ... Hi, I would like to somehow pass in a filename and metadata to a graph via parameters. I did...
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