Skip to content
New issue

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

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

Already on GitHub? # to your account

Craft Gql deserves to have it's own default routing signature #4975

Closed
narration-sd opened this issue Sep 23, 2019 · 5 comments
Closed

Craft Gql deserves to have it's own default routing signature #4975

narration-sd opened this issue Sep 23, 2019 · 5 comments

Comments

@narration-sd
Copy link
Contributor

Description

Twice in the last week, people new to GraphQL on Craft have been bitten by the default api routing on Gql -- here are the cases: markhuot/craftql#319 (comment) and markhuot/craftql#322 (comment).

Both CraftQL and Gql default to trying to use the route api as default, as why not..., and so also I believe would ElementAPI. The last one setting the route wins, and due to plugin initialzation positioning, that's Gql.

Hence persons who install and set up CraftQL don't reach it, and get mystifying errors.

Suggestion is that Craft Gql would be well placed to own its own default routing, something indicative like simple gql, or whatever you please that communicates well, matched in documentation.

@narration-sd
Copy link
Contributor Author

p.s. the second issue cross-linked is worth reading as the most indicative of how mysterious people find the result of this issue, and also points up something I've thought several times otherwise but forgot to put here initially.

It's that the generic 'Cannot query xxx on type Query' message doesn't particularly help anyone, and that Gql can do better here, by adding the suggestion that "It's likely you're getting this message because the access token you're using doesn't allow permission for the element or field you're trying to fetch...fix via GraphQL>Tokens [etc.]".

The original message I presume comes up from webonyx, but you can do as I do for a other confusing ones within a certain plugin, and string match on the return, to add your own amplification. I know you thought of that...

@brandonkelly
Copy link
Member

Craft actually doesn’t assume an api endpoint; we just use that in the example within the docs (https://docs.craftcms.com/v3/graphql.html#create-your-api-endpoint). You’re free to create whatever URL rule you want though.

@narration-sd
Copy link
Contributor Author

narration-sd commented Sep 29, 2019

Yeah, I was just checking this out on a finally peaceful day, as I missed your note here, and see that:

  • indeed, I followed whatever the early days doc said in initially setting this up -- and got, api
  • indeed, Craft doesn't default that on a composer project install; made one to check that

So, I would conclude that the issue exists, but that it's a doc issue.

It's going to cause problems, as you see from the support issues above.

Propose: just make the doc suggest 'gql' for the route signature. Problem solved?

@brandonkelly
Copy link
Member

@narration-sd
Copy link
Contributor Author

Ha, you rude guy. Really made me laugh :)

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

No branches or pull requests

2 participants