Skip to content
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

InputObjects incorrect loop detection with List and 2 levels of nesting #138

Closed
mattdb opened this issue May 17, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@mattdb
Copy link

commented May 17, 2019

The following GraphQL schema results in the GroupInput object being wrapped for circular reference protection (GroupInput GroupInputRaw):

type Mutation {
  createGroup(groupInput: GroupInput!): String
}

input GroupInput {
  products: [ProductInputNewOrId!]
}
input ProductInputNewOrId {
  newProduct: ProductInput
}
input ProductInput {
  name: String!
}

type Query {
  hello: String
}

I believe this is close to the minimum required to duplicate:

  • If the products field of GroupInput is changed to take a single ProductInputNewOrId!, no loop is detected (correctly).
  • if newProduct field of ProductInputNewOrId is set to String!, no loop is detected (correctly)

I think the following test case duplicates the above scenario (in InputObjectLoopsTests.elm):

        , test "deeply nested through list non-circular" <|
            \() ->
                [ TypeDefinition (ClassCaseName.build "GroupInput")
                    (InputObjectType [ fieldListRef "ProductInputNewOrId" "products" ])
                    Nothing
                , TypeDefinition (ClassCaseName.build "ProductInputNewOrId")
                    (InputObjectType [ field "ProductInput" "newProduct" ])
                    Nothing
                , TypeDefinition (ClassCaseName.build "ProductInput")
                    (InputObjectType [ scalarField "name" ])
                    Nothing
                ]
                    |> InputObjectLoops.any
                    |> Expect.equal False

-- ...

scalarField : String -> Field
scalarField fieldName =
    { name = CamelCaseName.build fieldName
    , description = Nothing
    , typeRef = TypeReference (Scalar Scalar.String) NonNullable
    , args = []
    }
@dillonkearns

This comment has been minimized.

Copy link
Owner

commented May 17, 2019

Thank you so much for the minimal failing test case @mattdb! I appreciate you taking the time to report and reproduce the issue!

It's all fixed now, see npm package @dillonkearns/elm-graphql@3.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.