"GRAPHQL Practice" using Apollo (IOS) to access Github's GRAPHQL API

Source: Internet
Author: User

Tag: URL target Electron client client practice date frame get

Recent assistance in investigating whether the code generated by Apollo is likely to share the model across the Query, although the preliminary conclusion is not, is not expected to be the result, but some of the accumulated experience in the research process is necessary to record. If you're also interested in graphql, you might want to start by cutting hands from Github's graphql API.

About GRAPHQL Official website

Although just do some of the client's practice, I would suggest you go through the GRAPHQL official website of the study guide. This will help you understand the concept more quickly. The documentation for some client libraries is mostly about basic usage.

Chinese version, can directly see http://graphql.cn/

Making tokens to access the Github API

There are multiple tokens in Github, and you need to https://github.com/settings/tokens this page. Initial contact with the GitHub API children's shoes, may go a lot of detours, such as the GitHub APP token generation rules as the API access token, after several twists and turns generated, but found completely not good.

curl -H "Authorization: bearer 7b7cc672235587292be65d11d8ae729b14a0d162" https://api.github.com/graphql

The 7b7cc672235587292be65d11d8ae729b14a0d162 is a Token that I generate with almost no private authority, which can be provided to everyone quickly. However, it is not guaranteed to be available all the time, so it is recommended that you create your own exclusive toekn.

Configuring GRAPHIQL--GRAPHQL Debugging Tools

This place is also a variety of pits. The first reaction is to look at the official documents, but the documentation is too outdated and the pits are too deep. If you want to see, I would like to remind you that you need to do in the parent directory is

yarn && npm run build

Or you could simply create a new example of yourself:

yarn add graphiqlyarn add graphql

If you don't understand what I'm saying, you're probably not a Web front-end, just use an APP based on GRAPHIQL:

Https://github.com/skevy/graphiql-app. GitHub even has a dedicated tutorial that uses the APP to access the Github API: https://developer.github.com/v4/guides/using-the-explorer/

Note: This App is based on electron, and the author does not directly mention the support for Windows, but if you do have to look at the electron's compilation tutorial yourself, you can certainly get it done.

Visually view the Github API

Imagine, graphql the data as a concrete figure to deal with, then this figure really draw what is it? Originally wanted to use the Web to draw the effect, but unexpectedly found that the Internet has a relevant tool.

Complete library of tools, see Https://github.com/APIs-guru/graphql-voyager. It would be perfect if it could be aggregated with the graphiql App above.

If you look directly at the effect, you can access the online demo:https://apis.guru/graphql-voyager/directly. There are several examples available. Github's API doesn't seem to be very complicated.

About the Apollo IOS Library

The document must be read first: https://www.apollographql.com/docs/ios/. But the pits, there are several, recorded, may be able to help later children's shoes:

    • iOS compatibility is iOS 9.0. If your project specifies a minimum version of 8.0, you will find that the pod is always installed in the Legacy Apollo library.

    • If you can't find the latest library, you might need to update the next pod:

pod install --repo-update
    • It is not correct to write the script in Xcode. The official website documents are not updated in time and should be written as follows:
APOLLO_FRAMEWORK_PATH="$(eval find $FRAMEWORK_SEARCH_PATHS -name "Apollo.framework" -maxdepth 1)"if [ -z "$APOLLO_FRAMEWORK_PATH" ]; thenecho "error: Couldn‘t find Apollo.framework in FRAMEWORK_SEARCH_PATHS; make sure to add the framework to your project."exit 1ficd "${SRCROOT}/${TARGET_NAME}"$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate "$(find . -name ‘*.graphql‘)" --schema=schema.json --output API.swift
    • "Not verified" if you consider the Apollo custom header or custom HTTPS certificate check, you can look at the https://github.com/apollographql/apollo-ios/issues/37# issuecomment-389843281

"GRAPHQL Practice" using Apollo (IOS) to access Github's GRAPHQL API

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.