Giter VIP home page Giter VIP logo

Comments (6)

rebing avatar rebing commented on August 15, 2024

I haven't worked with UnionTypes, but it should already work, since this package is built on top of the webonyx package that you linked. Have you tried creating a UnionType and adding it as a field?

from graphql-laravel.

DiederikvandenB avatar DiederikvandenB commented on August 15, 2024

Thank you for your response. I have tried the following:
https://gist.github.com/DiederikvandenB/1beee6e88d3671e72f2c639f17d10664

Attached to the gist is also the error message. What am I doing wrong?

I have also tried creating a SearchResultType, adding it to the config and loading it as Type::listOf(GraphQL::type('SearchResult')); but that throws an error saying that there is no toType function available. Which makes sense because the UnionType is not extending your package.

Cheers!

from graphql-laravel.

DiederikvandenB avatar DiederikvandenB commented on August 15, 2024

Months later I am revisiting this issue. Any points you could give me?

from graphql-laravel.

jthomaschewski avatar jthomaschewski commented on August 15, 2024

@DiederikvandenB you can try my PR #91
I added basic support for Unions to the Rebing Type class. It does work despite the WIP flag.

from graphql-laravel.

jthomaschewski avatar jthomaschewski commented on August 15, 2024

Another hint @DiederikvandenB : I think you can't add raw webonyx types to the Facade/graphql config.
But you can indeed reference instances of your custom type in other types and queries or even define new types inline.
e.g:

'fields' => [
  'fieldOther' => [ 'type' => GraphQL::type('SomeRebingType')],
  'fieldUnion' => ['type' => new UnionType([ 'name' => 'MyUniqueUnionName', 'types' => [...]],
]

important: Do not forget the name when defining types inline.

from graphql-laravel.

jthomaschewski avatar jthomaschewski commented on August 15, 2024

@DiederikvandenB You can try the latest Version release 1.12.0, the PR has been merged.
There is also some documentation on https://github.com/rebing/graphql-laravel/blob/master/docs/advanced.md#unions

from graphql-laravel.

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.