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

GraphQL with rack? #60

Closed
joshleblanc opened this issue May 31, 2019 · 14 comments
Closed

GraphQL with rack? #60

joshleblanc opened this issue May 31, 2019 · 14 comments

Comments

@joshleblanc
Copy link

The GraphQL example starts its own server. I'm wondering if I can stick something in a config.ru file to accomplish the same thing.

require 'agoo'


map '/graphql' { run Agoo::GraphQL(some_schema) }

Or something

@ohler55
Copy link
Owner

ohler55 commented May 31, 2019

If I understand correctly you would like to see something like the example/graphql/app.rb but be able to start with Rack. Is that correct?

@joshleblanc
Copy link
Author

I don't see a example/grahpql/app.rb, so I'm not sure.

If you mean the one in the readme, then yes.

@ohler55
Copy link
Owner

ohler55 commented May 31, 2019

oh, my mistake. My local copy only. Let me clean up and push. If you are looking for a config.ru file let me see if I can propose something.

@ohler55
Copy link
Owner

ohler55 commented Jun 1, 2019

Pushed app.rb to the develop branch. It looks like I'll have to make a change or two to use just a config.ru file. I'll get that started though.

@ohler55
Copy link
Owner

ohler55 commented Jun 9, 2019

I was trying to come up with some way to keep the configuration all in the config.ru file but finally settled on having the rackup invocation use the -O option. In the rack branch there is a new example in example/graphql/config.ru. The command to run assuming you want to use the local code for testing is rackup -I ../../ext -I ../../lib -r agoo -s agoo -Ographql=/graphql. Let me know if you have any suggested changes or additions. I'll wait for your feedback before releasing.

@joshleblanc
Copy link
Author

I don't know how the underlying systems work, but I would expect to do something like

# config.ru
map('/graphql') { run Agoo::Graphql.app }

Looking through the examples, it looks like the graphql server is actually integrated with Agoo::Server, so maybe that's not possible.

@ohler55
Copy link
Owner

ohler55 commented Jun 10, 2019

Yes, the graphql server is integrated into the server.

@ohler55
Copy link
Owner

ohler55 commented Jun 10, 2019

Does the approach taken seem reasonable to you as a Rack user?

@joshleblanc
Copy link
Author

Should be fine. Every server has their own way of leveraging rack.

@ohler55
Copy link
Owner

ohler55 commented Jun 11, 2019

Released.

@ohler55
Copy link
Owner

ohler55 commented Jun 21, 2019

No complaints, closing.

@ohler55 ohler55 closed this as completed Jun 21, 2019
@robotex82
Copy link
Contributor

I hope it is ok to reopen this issue.

I have been thinking about using the graphQL implementation in a Rails app. To do this I'll have to mount a graphQL schema inside the rails routes as a rack app:

Rails.application.routes.draw do mount Agoo::GraphQL.schema(Schema.new), at: '/graphql' end

Could this be possible?

My goal would be to write an extensible schema for an existing ruby on rails cms.

@ohler55
Copy link
Owner

ohler55 commented Aug 5, 2020

Better to create a separate issue. There might be a better way to set up the routes than using the rails router. We can discuss to make sure I'm not missing something.

@robotex82
Copy link
Contributor

Ok, thanks! I just opened #93

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