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

error when querying both data and count #1

Open
jritsema opened this issue Jul 23, 2020 · 2 comments
Open

error when querying both data and count #1

jritsema opened this issue Jul 23, 2020 · 2 comments

Comments

@jritsema
Copy link

Hi there! Thanks so much for making this library! So far, it's working great, however, I apparently can only query count or data but not both. When I do I query both at the same time, I get the following error.

runtime error: invalid memory address or nil pointer dereference

It never makes it into my code so it looks like it's in the graphql layer or this library. Any ideas or tips for troubleshooting? Thanks again!

@carlosstrand
Copy link
Owner

Hello, @jritsema

Can you share us a full example of library usage?

@jritsema
Copy link
Author

func graphqlSchema() *graphql.Schema {

	jobType = jobObject()

	rootQuery := graphql.ObjectConfig{
		Name:        "RootQuery",
		Description: "",
		Fields: graphql.Fields{
			"job":       jobField(), //deprecated
			"jobs":      pagination.Paginated(jobsField()),
			"extractor": extractorField(),
			"run":       runsField(),
		},
	}

	schemaConfig := graphql.SchemaConfig{
		Query: graphql.NewObject(rootQuery),
		// Mutation: ,
	}

	schema, err := graphql.NewSchema(schemaConfig)
	if err != nil {
		log.Fatalf("failed to create new schema, error: %v", err)
	}
	return &schema
}

func jobsField() *pagination.PaginatedField {
	return &pagination.PaginatedField{
		Name:        "Jobs",
		Type:        jobType,
		Description: "Get workflow Jobs",
		Args: graphql.FieldConfigArgument{
			"jobId": &graphql.ArgumentConfig{
				Type:        graphql.String,
				Description: "Get a Job by ID",
			},
		},
		DataResolve:  jobsResolver,
		CountResolve: jobCountResolver,
	}
}

Does that help?

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

No branches or pull requests

2 participants