Skip to content

Compability with Apollo #11

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

Closed
DaveDamage opened this issue Oct 15, 2017 · 7 comments
Closed

Compability with Apollo #11

DaveDamage opened this issue Oct 15, 2017 · 7 comments

Comments

@DaveDamage
Copy link

DaveDamage commented Oct 15, 2017

Hi,

first of all let me thank you for ProcessGraphQL qhich has opened new possibilities with Processwire.

Ich have a Processwire Installation with ProcessGraphQL installed and use vuejs with vue-apollo. When I make a call to Graphql, the server responds with with the error message: »Must provide an operation.«.

I guess it has something to with how apollo - more specifically gql - sends the queries:

[{"query":"{ career { list { title id } }", "operationName":null}]

So my question is, if I should catch the query before it is executed and then pass it or is there another solution?

Thank you very much

Dave

@dadish
Copy link
Owner

dadish commented Oct 16, 2017

Is there any chance that your problem is related to #1 issue?

@hns-david
Copy link

hns-david commented Oct 16, 2017

I don't think so, I made sure I gave apollo the url with a trailing slash, but I will double-check this evening and apend a screenshot of the request.

I tried with axiom instead of apollo, and it worked fine.

My suspicion is that apollo or gdl wraps the request in an array which is then rejected by the module.

@DaveDamage
Copy link
Author

Here are the screenshots:

apollo-screenie1
apollo-screenie2

@dadish
Copy link
Owner

dadish commented Oct 16, 2017

The Must provide an operation. error happens when no query is received by the GraphQL library. Let's find out if that is the case. In your template, where you execute ProcessGraphQL, do

<?php namespace ProcessWire;

die('JSON payload is: ' . file_get_contents('php://input'));

echo $modules->get('ProcessGraphQL')->executeGraphQL();

Make a request and then look at the response. This must show us if the JSON payload actually reaches the module.

@DaveDamage
Copy link
Author

DaveDamage commented Oct 16, 2017

Looks like the payload arrives:

apollo-screenie3

But in an array...

@dadish
Copy link
Owner

dadish commented Oct 16, 2017

Sorry, but I realized just now that you are sending an array of queries, instead of one. Which currently is not supported. You need to send one query operation. So instead of

[{ career { list { title __typename } __typename } }]

you should send

{ career { list { title __typename } __typename } }

@DaveDamage
Copy link
Author

I feared as much and will fix it. Thank you for your time.

@dadish dadish closed this as completed Nov 3, 2017
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