Code Monkey home page Code Monkey logo

Comments (6)

SuNNjek avatar SuNNjek commented on July 21, 2024 1

Is there any examples on how to do this? I'm struggling to do this myself currently but all I could find was this issue

Edit: Ok, I managed to find a test which uses this here:

graphql/definition_test.go

Lines 542 to 561 in 35f78a4

func TestTypeSystem_DefinitionExample_IncludesFieldsThunk(t *testing.T) {
var someObject *graphql.Object
someObject = graphql.NewObject(graphql.ObjectConfig{
Name: "SomeObject",
Fields: (graphql.FieldsThunk)(func() graphql.Fields {
return graphql.Fields{
"f": &graphql.Field{
Type: graphql.Int,
},
"s": &graphql.Field{
Type: someObject,
},
}
}),
})
fieldMap := someObject.Fields()
if !reflect.DeepEqual(fieldMap["s"].Type, someObject) {
t.Fatalf("Unexpected result, Diff: %v", testutil.Diff(fieldMap["s"].Type, someObject))
}
}

from graphql.

hamza72x avatar hamza72x commented on July 21, 2024 1

@SuNNjek

Error in making graphql schema Schema must contain unique named types but contains multiple types named "SomeObject".

from graphql.

bsr203 avatar bsr203 commented on July 21, 2024

Not a complete answer, but, if I understand correctly, Thunks are meant for that. Please check #100

from graphql.

solher avatar solher commented on July 21, 2024

Ok. I tried it and it doesn't overflow anymore but now, when I fetch the doc in graphiql, I get:

{
  "data": null,
  "errors": [
    {
      "message": "Unknown type \"__Type\".",
      "locations": [
        {
          "line": 22,
          "column": 24
        }
      ]
    },
    {
      "message": "Unknown type \"__InputValue\".",
      "locations": [
        {
          "line": 55,
          "column": 26
        }
      ]
    },
    {
      "message": "Unknown type \"__Type\".",
      "locations": [
        {
          "line": 62,
          "column": 23
        }
      ]
    }
  ]
}

These are probably stupid questions but i'm trying to understand the different possibilities and the graphql package organisation and it's quite hard ;)

from graphql.

solher avatar solher commented on July 21, 2024

Ok it works.
The issue came from the fact that I didn't use the same type objects in every field declaration.
I guess the reflection crashed at some point because of that.

from graphql.

bsr203 avatar bsr203 commented on July 21, 2024

great it worked. ya, I use custom resolve method by just typecasting the fields, instead of using the default reflection based handlers.

from 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.