Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple example app using apollo react client #3

Open
hballard opened this issue Mar 1, 2017 · 10 comments
Open

Add simple example app using apollo react client #3

hballard opened this issue Mar 1, 2017 · 10 comments

Comments

@hballard
Copy link
Owner

hballard commented Mar 1, 2017

No description provided.

@ssomnoremac
Copy link

Would love to contribute to this. I'm no python expert, but I have a server I'm working on privately that I've generalized to a schema and added a mutation using sqlAlchemy -> graphene -> flask. It just needs subscriptions. As for the client, that is where I can be more of an assistance. As much as it would be easier for me to create a React Native project-- and that would be cool, I think people aren't going follow as easily as a web React. I think we could probably hack it together over a weekend.

@hballard
Copy link
Owner Author

hballard commented Mar 24, 2017

Thanks! I was working on a simple chatapp...could finish it up over a weekend probably, but my priority right now is getting the tests added. I haven't had much time the last few weeks since I initially published this, but trying to make time to at least start adding tests. Then shift to the simple app and python 3 integration. That said...the README includes all the core code for the subscription server (excluding the schema) and a react component (using apollo client). That was actually the first component of the chatapp I was going to build. If you copy that code and build your server, you will have a real-time component (using subscriptions). I'd be happy to help anyway I can if you want to try a pull request and don't want to wait until I get to the app example. I have a simple mockup built, the server w/ schema, and the one component of the client. I would just need to commit it and you can fork it.

@ssomnoremac
Copy link

ssomnoremac commented Mar 24, 2017

Great, thanks. I've never used Redis, but I'll give it a shot.

@hballard
Copy link
Owner Author

hballard commented Mar 24, 2017

Cool. I'll commit the chatapp code this weekend under a dev branch and let you know when that's done. I'm no Redis expert either, but for this use case, we are only using the pubsub feature--which is internal to the implementation of the subscription service. For the chatapp model / persistence, I'm using Flask-SqlAlchemy. Redis on a Mac is pretty simple (replace Homebrew with particular distro package manager on linux).

Using Homebrew:
$ brew install redis

In a separate process start redis:
$ redis-server

For redis-py:
$ pip install redis

Build you subscription server.

@ssomnoremac
Copy link

Awesome, thanks. I'm starting to understand the role Redis plays better. I have a few things to attend to this weekend so no rush. It seems like a UI for the chat app will be pretty simple. Maybe it would actually be cool to implement it in Native with this

@hballard
Copy link
Owner Author

hballard commented Mar 27, 2017

I added another branch 'chatapp', that has folders with initial server code, some client code, and image mockups. This is very rough and doesn't include any security / auth or anything like that. My plan was to build something simple to showcase the subscription features and integration with graphene server and apollo client library. The client code has only one component at this point...which was mainly used for testing the graphql subscription packages. It is just the start of a simple app...

@happylinks
Copy link

Hi Heath, thanks for the library! I've been testing it with your chatapp branch. I'm getting the error "Subscription timed out - no response from server". Would you have any hints on what might be wrong? The /graphql endpoint is working fine.

@hballard
Copy link
Owner Author

Sure thing...give me a bit and I'll shoot out an update. I have it working fine on my setup, but I was testing pretty extensively before I published the master branch, so I could have something config'ed / installed that I didn't include in chatapp branch. I was in a rush yesterday to push it and didn't try testing it in afresh project environ. I'll do that in a bit and shoot out any changes that may need to be made.

@hballard
Copy link
Owner Author

hballard commented Mar 29, 2017

Didn't have time to fix this last night, but I just pushed a commit that fixes it. When Flask-SqlAlchemy recently updated to version 2.2 they made a change to where the db object now has to be used within an app_context. Here is the version change and specifically on commit #461. I had previously tested this with 2.1 and it was working. Regardless, I added an app_context within the subscription resolver function and that fixed it...or you could use flask-sqlalchemy < 2.2 with the previous code. Here is the commit. Once you install your npm packages for the client code and pip install the requirements file for the server, don't forget to load a python interpreter and:

>>> from api import db
>>> db.create_all()

The currently implemented React component looks for any additional users being added (AddUser) -- so just load a graphiql session in your browser (http://localhost:5000/graphql) and add a new user to test.

@happylinks
Copy link

Awesome! Thank you very much. I'll test it tonight :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants