Skip to content
This repository was archived by the owner on Jun 10, 2019. It is now read-only.
This repository was archived by the owner on Jun 10, 2019. It is now read-only.

Use the new GitHub GraphQL API for exporting user contributions #486

Closed

Description

@sethbergman

User Profiles: Subtask for GitHub API

React-Apollo-GraphQL

This is the GraphQL Schema that would integrate with Apollo, which integrates with Redux. I've seen a Redis implementation as well as a kinex, express-graphql, connect, koa, mongoose with a MongoDB memory store and isomorphic fetch. The tooling around this new concept for a REST like implementation is pretty amazing. The ability to visualize data is as easy as installing an extension.

Needs more research

There are ways to connect GraphQL with Rails as well as any other frontend library / framework, and I'm not completely sure which would be the best implementation. This may not even be necessary, but I'd like to know if we're going to move forward with this as I work on fetching data from GitHub. Their newest version of their API uses GraphQL, and I've seen what it's capable of doing. I'll see if I can demo what I have and record it for more clarity on this subject.

  • Schema:
type User implements Node {
  id: ID! @isUnique
  githubUserId: String @isUnique
  createdAt: DateTime!
  updatedAt: DateTime!
  email: String @isUnique
  password: String
  isVerified: Boolean! @defaultValue(value: false)
  secret: String @isUnique
}

type File implements Node {
  contentType: String!
  createdAt: DateTime!
  id: ID! @isUnique
  name: String!
  secret: String! @isUnique
  size: Int!
  updatedAt: DateTime!
  url: String! @isUnique
}

type GithubRepo implements Node {
  createdAt: DateTime!
  id: ID! @isUnique
  name: String @isUnique
  updatedAt: DateTime!
  avatar: String
  changelog: String
  description: String
  homepageUrl: String
  issues: Int
  lastCommit: Json
  lastRelease: Json
  license: String
  owner: String
  primaryLanguage: Json
  pullRequests: Int
  readme: String
  repoUrl: String! @isUnique
  stars: Int
  isVerified: Boolean! @defaultValue(value: false)
  secret: String @isUnique
}

Here is a simple way to connect with both HTTP and Websockets:

import {SubscriptionClient, addGraphQLSubscriptions} from 'subscriptions-transport-ws';
import ApolloClient, {createNetworkInterface} from 'apollo-client';

// Create WebSocket client
const wsClientOptions = {
	reconnect: true,
	connectionParams: {
    // Pass any arguments you want for initialization
	}
};
const wsNetworkInterface = new SubscriptionClient('ws://localhost:3000/graphql', wsClientOptions);

// Create regular NetworkInterface by using apollo-client's API:
const httpNetworkInterface = createNetworkInterface({
 uri: '/graphql' // Your GraphQL endpoint
});

// Create Hybrid interface
const hybridInterface = addGraphQLSubbscriptions(httpNetworkInterface, wsNetworkInterface)

// Finally, create your ApolloClient instance with the modified network interface
// Full websocket: wsNetworkInterface
// Mixed Mode: hybridInterface
const apolloClient = new ApolloClient({
    networkInterface: hybridInterface
});

Activity

  1. sethbergman commented on Sep 8, 2017

    @sethbergman
    ContributorAuthor

    I've added some information to this issue / question. Here's a good resource:
    https://github.com/apollographql/apollo-client/blob/master/README.md

  2. self-assigned this
    on Sep 11, 2017
  3. kylemh commented on Oct 1, 2017

    @kylemh
    Member

    How does this issue differ from #481 ?

  4. sethbergman commented on Nov 25, 2017

    @sethbergman
    ContributorAuthor

    Closing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions