Download Gitlab's graphql schema - graphql

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.

Related

Apollo on android: can't download schema or generate classes

I'm trying Apollo and graphql for the first time and I want to use this api and I'm following the official example here. However
running the schema download task
gradlew :app:downloadApolloSchema --endpoint='https://countries.trevorblades.com/' --schema='app/src/main/graphql/com/trevorblades/countries/schema.json'
results in
Execution failed for task ':app:downloadApolloSchema'.
> Expected URL scheme 'http' or 'https' but no colon was found
with both the repo I want to use and the example's.
If I try to manually download the schema using the button on the repo's page, place it in the correct directory and run
gradlew generateApolloSources
it results in
Failed to parse GraphQL schema introspection query from `[...]app\src\main\graphql\com\trevorblades\countries\schema.json`
again with both my repo and the one from the example.
I've the feeling that I'm missing something really trivial here, but I really can't figure it out.
any help will be appreciated.
Try the JS GraphQL IDEA plugin, which might make life a tad easier. And as it suggested here ...you might not pass a valid endpoint at all. Try --endpoint=https://countries.trevorblades.com/ or in " double-quotes . The error message is definitely concerning the --endpoint and not concerning the --schema. I have the suspicion that Windows might not like these ' single quotes
(obviously the same would also apply to --schema).
gradlew.bat :app:downloadApolloSchema --endpoint=https://countries.trevorblades.com/ --schema=app/src/main/graphql/com/trevorblades/countries/schema.json
or:
gradlew.bat :app:downloadApolloSchema --endpoint="https://countries.trevorblades.com/" --schema="app/src/main/graphql/com/trevorblades/countries/schema.json"

How to get Rest Api endpoints, name and url's, in the way Azure Functions do?

Sometimes you get over a feature that you just like. When creating a Azure Function project and debugs it, it writes out this nice info in the console.
Now that I am writing the frontend, I have found this information very useful.
Functions:
CoWorkers: [GET,POST] http://localhost:7071/api/CoWorkers
GetManager: [GET,POST] http://localhost:7071/api/GetManager
SetManager: [GET,POST] http://localhost:7071/api/SetManager
UserInfo: [GET,POST] http://localhost:7071/api/UserInfo
...
I would like to have this on every asp.net rest api project that I am coding.
Anyone knows how to get it?
EDIT: OpenApi/Swagger is providing this information as pawelek91 says and I should have mentioned that I want it in the console: "Just because I like that feature".
use HttpOption request or swagger (if you can install it on your backend)
For console access to your web API, try the new HttpRepl tool at:
https://learn.microsoft.com/en-us/aspnet/core/web-api/http-repl/
It's a dotnet CLI tool that is installed separately (install using dotnet tool install -g Microsoft.dotnet-httprepl from the CL). Then you can "browse" your API using this command line tool.
As noted in the docs, it requires .Net Core 2.1+.

How to use GrahpiQL to upload file in grahpql?

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.

How to import a file using apiary?

I want to browse a file from my system and want import it using apiray so how I can do that please help me into this.
you can try to use Apiary CLI (https://help.apiary.io/tools/apiary-cli/)
The Apiary CLI gem is a command line tool for developing and previewing API Blueprint documents locally. It can also be used for pushing updated documents to and fetching existing documents from Apiary.io.

Meteor Npm-module client-side?

Is it possible to use Npm-Modules on client-side?
More specifically:
I want to use node.js built-in crypto-module for encrypting a password the user enters and then send the encrypted password with a signature(/hmac) to my server.
I need to do it that way, because I must be able to retrieve the original password server-side, because afterwards I'm going to send it to a ldap-server, because the user should authenticate with the same username/password he is registered with on that server.
This is what I did:
created in packages/crypto/:
-package.js:
Package.on_use(function(api) { api.add_files('crypto.js',['server','client']);});
-crypto.js:
crypto = Npm.require("crypto");
It works fine on the server, but on the client it says "Reference Error: Npm is not defined".
So, is it possible to use the crypto-module on client-side?
Are there any alternatives for achieving this goal?
Thank you!
Edit:
Is there any good alternative for getting the password to the server in a secure way, so that the server can retrieve the original password?
I think doing the ldap()-request on the client-side (like:
if(checkLdap(usrname,password)){<login>} else{fail}) can be easily bypassed?
You can try to add the js-files you need on client-side from .npm folder under crypto's package directory.
So, your package.js file might look like this:
Package.describe({
summary: 'Description of your crypto package'
});
Npm.depends({
'crypto': '1.0.0'
});
Package.on_use(function (api) {
api.add_files('crypto.js', 'server');
api.add_files('.npm/node_modules/crypto/crypto.js', 'client');
});
You can use https://github.com/elidoran/cosmos-browserify now to archive this. I used wrapped packages before and it was real pain to update them and to create new ones. Now with browserify support I can include library with just several lines of code. See their example how to do it. I don't publish it here as it may be subject of change.
Its not possible to use Npm modules on the client side since Npm modules are extensions via node.js which only runs on the server end.
If you want to use a file like crypto you would have to make a client side only version and put it in /client/lib of your Meteor app
While this may be possible officially, Meteor doesn't support this.
You would have to include requirejs manually using this project: https://github.com/apendua/require
You can use browserify to build a .js bundle with all all the Npm modules you want on the client side. See:
2013 Meteor NPM Packages

Resources