GithubHelp home page GithubHelp logo

Comments (7)

dmongeau avatar dmongeau commented on July 29, 2024

Thanks for noticing that. I'm in the process of writing Unit Tests and while I'm doing it, I came accross this irregularity. In my opinion, the name you put in the config should have precedence on the name in the Query, so you could overwrite it and even uses the same Query two times with different name. This is what I'm going to implement for Query, Mutation and Type. So everything works the same.

What you think?

from laravel-graphql.

ChristophP avatar ChristophP commented on July 29, 2024

Hey, thanks for your quick reply. I think the most important thing is that there is one single source of truth (because now both values are used). It doesn't matter that much to me which one gets the precedence but I do have a couple of questions about what you said.
1.
In my opinion, the name you put in the config should have precedence on the name in the Query, so you could overwrite it ....
If you want to override the value form the config that means that normally you don't specify the name in the config. But usually you specify the key all the time when you add a query.

'schema' => [
 'usersQuery' => 'App\GraphQL\Query\UsersQuery', 
]

so if you want to leave that out you might want to add a way to add queries in non-associative arrays and then have the name taken from the name prop of each query object.

'schema' => [
  'App\GraphQL\Query\UsersQuery', 
]

From the source code it didn't look like non-associative arrays are already implemented. So I think you should implement that or do it the other way around, namely use the name prop in the Object to override the key in the config(I think this is already implemented for types in the addType() method). It could be done analogous to that. I hope I don;t sound too confusing :-) What do you think?
2.
... and even uses the same Query two times with different name.
I think using the same query with the different name is not necessary and leads to confusion since I believe the query name should be somewhat unique throughout the GraphQL Service. Or do you have a specific reason for that?

from laravel-graphql.

ChristophP avatar ChristophP commented on July 29, 2024

Hey @dmongeau do you have any more thoughts on my reply? Do you have a rough time frame when this fix will be available in the future?

from laravel-graphql.

dmongeau avatar dmongeau commented on July 29, 2024

Right now it is available on the v1 branch, I'm finishing the unit tests. You can test if the behavior is what you expected. Let me know.

Should be released in a week!

from laravel-graphql.

ChristophP avatar ChristophP commented on July 29, 2024

Ah cool I will check it out.

from laravel-graphql.

ChristophP avatar ChristophP commented on July 29, 2024

So I installed the version v1.x-dev from composer and tried it out. Works, really well.
The only think I could add is that this you could add to the readme which name takes precedence but other than that the version looks really nice overall. Good work. 👍

from laravel-graphql.

ChristophP avatar ChristophP commented on July 29, 2024

I guess I can close this issue. Since the changes with be merged soon.

from laravel-graphql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.