How to use GrahpiQL to upload file in grahpql? - graphql

I am a newbie in graphql and I am trying to create a sever which will take few parameters and a few files (like images) as parameters in mutation.
I am using graphql-yoga and it is very clear how to implement it using graphql-yoga.
My question is how to test it?
How can I test the file upload from graphql playground?
I am going to use react-relay so are there any examples to do it in react-relay.
Thanks.

Neither GraphiQL nor GraphQL Playground support file uploads. You can use a standalone client like Altair.

Related

Server-side request to upload file using Keystone

I have a Keystone list schema that has a field of type 'File'.
So, a GraphQL mutation to update entity has an Upload GraphQL type for argument that corresponds to this field.
I need to execute update mutation using executeGraphql in server environment.
Did not found any plug-and-play solution for that.
One way, we are using for our test environment is to create an instance of ApolloClient and pass a link with createUploadLink from apollo-upload-client library. But, AFAIK, this approach will trigger real HTTP request.
It seems, like better way is to use existing instance of Keystone class on server side…
Any recommendations?
Thank you.
Cheers!

Download Gitlab's graphql schema

I'm trying to get hold of gitlab_schema.graphql, i.e. the schema for Gitlab's graphql API. Can't find it anywhere, does anyone have any pointers?
You can use apollo CLI for this: apollo client:download-schema --endpoint=https://gitlab.yourcompany.com/api/graphql schema.graphql or just omit filename and it will download to JSON
It doesn't look like GitLab shares the schema directly, just this Reference Documentation generated from the schema, and the GraphiQL Explorer / IDE (more info about GraphiQL Explorer here).
I found the schema is an artifact in the Gitlab CI pipe (graphql-schema-dump job), for example here: https://gitlab.com/gitlab-org/gitlab/-/jobs/1602029144.
Not perfect, but works.
Here's alternative, if you are working with Rust lang. For Rust developers, you need to install the crate named graphql_client_cli via cargo. Example: cargo install graphql_client_cli.
Next, you can run the graphql client you just downloaded, to get the schema (either in JSON or GraphQL format). Example: graphql-client --authorization 'Bearer <bearer token>' https://<your gitlab url site>/api/graphql.
See the GraphQL Client CLI for more options.

How to build relationship map?

I like GraphQL and another libraries around GraphQL. I like GraphQL tools. But I found that I need a relation map. I thought that such tool had to exist. But I have not found. Does it exist?
If you are asking for a visual representation of relations, you could use GraphQL introspection to achieve this. Take a look on GraphQL Voyager:
Demo:
https://apis.guru/graphql-voyager/
Copy the introspection query, paste and run it on your GraphQL API endpoint.Copy the results into GraphQL Voyager. You should get a nice visual representation of your data relations available through your GraphQL API.
Github:
https://github.com/APIs-guru/graphql-voyager

Parse Image + Parse httpRequest replacements — migrating from Parse Cloud Code to Parse Server on Node (Heroku / AWS / DO)

I found that when using the parse-node package, you can no longer use Parse.Cloud.httpRequest. I also know that Parse's Image object won't be available.
So far, I've been able to replace some Parse promises with native ones and use axios to make network requests.
However, I'm relatively new to Node, so I'm curious as to what are the most direct replacements for these, and how do I use them?
You should still be able to use Parse.Cloud.httpRequest. But axios is a great library and it's a great idea to start using it if you want to learn nodejs. When it comes to the parse-image it has to be replaced. There is a library which claims 100% compatibilty, check it out here.

How to view the raw XML or Json response using LinqToTwitter?

How can I view the raw XML or Json response when doing a search for users using the LinqToTwitter library? I'm using the SingleUserAuthorizer for oAuth.
If you have any ideas using other libraries or even a simple oAuth framework, I'm open to suggestions.
Thanks.
TwitterContext has a RawResults property you can use.
If this is just for debugging purposes, I'd use Wireshark or Fiddler - that way you get to see the complete HTTP requests/responses.

Resources